New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build fails at minification while processing packages/modules.js #11721
Comments
hi @gischer, do you have any variable called Identifier 'o' has already been declared Or this error is coming from a minified var? It seems a problem in the minifier or in your code duplicating a variable. If the problem is in the minifier it should be a specific case that you have in your code as this is not happening to everyone. We would need to narrow down this use case. |
I just grepped through the whole thing (it's pretty big) and found no instance of any variable named 'o'. This matches with my recollection. I'm cautious, because it's kinda big at this point, but the answer is no. I've built it many, many times with no issue (with minification or the meteor build in general) but for now. So I'm kinda mystified. |
Thinking about my most recent changes, I think the biggest one is that I started using isolated-vm. This has led to code (that should only be used in testing) that looks like this:
It doesn't seem like this would lead to my problem, but I don't really know. Because
|
I have a question about how the minifier works. My guess is that it uses "import" and "require" to figure out which files to process and include. (I stick to "import"). But it could instead just grab everything that is a *.js (or whatever) in the project. If I'm going to cut this down, I really do need to know what to do. I'm gonna assume for now that it follows "import" references. |
Hi @gischer it depends on how you are using Meteor, if you are using mainModules in your package.json or not, for example. This document explains somethings that could be useful https://docs.meteor.com/packages/modules.html Have you tried to remove the isolated-vm part of your code to see if the problem still happens? |
Here is the relevant bit of my package.json:
I believe this means it loads those files first and then pulls in references. Is that right? I have removed all references to isolated-vm (it was only imported in one file). I haven't uninstalled it, though. |
I have discovered more information, but I'm not sure what to do with it. By commenting out "import" statements and using stubs to replace the imports, I've narrowed things down to file A.js and B.js. File A, under normal operation, imports 5 functions from file B.js thus:
(Those aren't the names in my files, but the names don't seem to matter here.) Under this condition, the build breaks with the error above (at some point it started referencing the variable 's' instead of the variable 'o'. Don't know what that means. It all looks kind of the same though.). If I eliminate any one of them, touching only A.js thus:
Everything minifies just fine, and the build succeeds. UNFORTUNATELY, when I tried to create a brand-new Meteor app and reproduce this error directly, it works just fine. I don't really know what to do with this information. I'll keep poking at it and trying things as I think of them. |
Oh, FWIW, the previous comment describes a situation where "isolated-vm" has been removed from the project. |
@gischer the first step here would be to have a reproduction, otherwise, we don't have a way to analyze the issue and try to identify the root cause. As you can't reproduce in a new project, you should try to remove other parts of your code to see if the error stops and then narrow down the root cause. |
@filipenevola I have, in fact, been able to make the error stop via commenting out code, producing the situation I described above. In another full repository, I have done something similar, but without removing any other code. I have found a certain file in which I must now remove two of five imported functions to get it to work. That is,
fails, but if I eliminate ANY two of the imported functions and stub them locally, like this,
it works. I change nothing else. This strongly suggests to me that this is some sort of buffer overflow. I can well appreciate that you can't do much without reproducing the problem. AND, it turns out my repository is proprietary, and it isn't hosted on github, so I'm not sure there's a good way to share it with you. I post this because of my hope that it will inspire you or someone else to suggest a course of action I hadn't already thought of. I will work on figuring out how to share the repository with you. |
Ok, I appreciate your explanation and I hope you can create a reproduction. |
Ok, I have a repository that reproduces the problem. It is |
Hi @gischer, I tried to run your project but there is a lot of imports failing because the files don't exist. Maybe we don't need to run the project to see the problem you're having, but we need to know how you're reproducing the error. Can you add a readme to the repository explaining step by step how to reproduce the error? Also if this error does not block the app from running, maybe it's also good if you fix the imports so we can run the app as well. Thanks. |
I will add a README. The project in the example repository does not run. It does reproduce the error if you type "meteor build ../output" |
I have added a README as asked. I am assuming that the project does not need to run (the problem reproduces when you do "meteor build"). Let me know if that is not the case. I will work on making it start up cleanly. |
You can now type The repository definitely reproduces the error. |
Possibly related to #11930 |
We narrowed down the problem to the package terser (that we use to minify our code). We opened an issue there terser/terser#1155. We are studying the replacement of terser by esbuild. Soon we'll create a PR with a proposal. |
Hi, This should be fixed now with the new version 2.7. I'm closing this for now. |
I don't know how to reproduce this. The app runs fine. This was on Meteor 1.10.2, where I first got the problem. I upgraded to current (2.5) with no change.
Here is the error message (apologies for how long it is):
Having looked at #8020, I tried using abernix:standard-minifier-js. It failed with this error message:
While minifying app code:
This looks to be a problem with a generated file (packages/modules.js) but I'm not sure which one, since there are more than one under my source tree, or what to do about it. And it seems a lot different than the other error.
The text was updated successfully, but these errors were encountered: