Open codefactor opened 1 year ago
Any ideas on this one? Is this the right repository for this type of issue?
I wasn't sure about it because I don't know where the actual minify mistake occurs.
At the moment our solution is to just disable minify on certain files. But this is obviously not ideal.
Describe the bug
Some minified JS code is not functionally equivalent to original, and it produces runtime errors when the minified code is executed. Some extra unexpected string variable is injected into the minified JS code and then later that variable is used as a function which throws.
To Reproduce
Minimal code to reproduce the bug
Using package.json like this:
Execute code like this:
Actual Output
The console will output this:
This is prettified like this (but not very pretty)
Expected Output
This is my best guess what it should look like instead:
NOTE:
Configuration
All configuration is provided above in the package.json and JS code snippet.
I'm using babel-minify to minify a JS file just as shown above, though in my example I'm reading from constant using only a small JS snippet from the bigger file that has the issue.
Possible solution
Additional context
As background, I'm trying to replace a google closure implementation that works fine with babel-minify, and mostly works fine - but this one really old JS file is not compressing correctly. I can work around the problem by making minor adjustments to the JS code being minified, which is fine; however, I'd like to know more about the problem. The example JS being minified is from YUI, and I believe the file has been prettified and then minify again - but please just ignore that.