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
Multiple passes produce incorrect code #308
Labels
Comments
What I've found: command: Case 1: After removing
|
I'm not sure, but it looks a little like #294 |
Workaround is to add I'll try to fix it |
apvarun
added a commit
to apvarun/react-onboarding-pro
that referenced
this issue
Nov 17, 2019
STRML
added a commit
to react-grid-layout/react-draggable
that referenced
this issue
May 12, 2020
There is nothing special in the browser build that is actually practical for modern use. The "browser" field, as defined in https://github.com/defunctzombie/package-browser-field-spec#overview, indicates that you should use it if you are directly accessing globals, using browser-specific features, dom manipulation, etc. React components like react-draggable are built to do minimal raw DOM manipulation, and to always gate this behind conditionals to ensure that server-side rendering still works. We don't make any changes to any of that for the "browser" build, so it's entirely redundant. Hoping this also fixes the "Super expression must either be null or a function" error (#472) that some users have experienced with particular bundler configurations. The browser build may still be imported at "build/web/react-draggable.min.js". This is to prevent breakage only. The file is no longer minified to prevent possible [terser bugs](terser/terser#308).
MaciejCzyzewsk
pushed a commit
to MaciejCzyzewsk/react-draggable
that referenced
this issue
Feb 20, 2023
There is nothing special in the browser build that is actually practical for modern use. The "browser" field, as defined in https://github.com/defunctzombie/package-browser-field-spec#overview, indicates that you should use it if you are directly accessing globals, using browser-specific features, dom manipulation, etc. React components like react-draggable are built to do minimal raw DOM manipulation, and to always gate this behind conditionals to ensure that server-side rendering still works. We don't make any changes to any of that for the "browser" build, so it's entirely redundant. Hoping this also fixes the "Super expression must either be null or a function" error (#472) that some users have experienced with particular bundler configurations. The browser build may still be imported at "build/web/react-draggable.min.js". This is to prevent breakage only. The file is no longer minified to prevent possible [terser bugs](terser/terser#308).
ludarkhorse
added a commit
to ludarkhorse/ReactGrid
that referenced
this issue
Feb 21, 2023
There is nothing special in the browser build that is actually practical for modern use. The "browser" field, as defined in https://github.com/defunctzombie/package-browser-field-spec#overview, indicates that you should use it if you are directly accessing globals, using browser-specific features, dom manipulation, etc. React components like react-draggable are built to do minimal raw DOM manipulation, and to always gate this behind conditionals to ensure that server-side rendering still works. We don't make any changes to any of that for the "browser" build, so it's entirely redundant. Hoping this also fixes the "Super expression must either be null or a function" error (#472) that some users have experienced with particular bundler configurations. The browser build may still be imported at "build/web/react-draggable.min.js". This is to prevent breakage only. The file is no longer minified to prevent possible [terser bugs](terser/terser#308).
Karasu0888
pushed a commit
to Karasu0888/react-draggable
that referenced
this issue
Sep 12, 2023
There is nothing special in the browser build that is actually practical for modern use. The "browser" field, as defined in https://github.com/defunctzombie/package-browser-field-spec#overview, indicates that you should use it if you are directly accessing globals, using browser-specific features, dom manipulation, etc. React components like react-draggable are built to do minimal raw DOM manipulation, and to always gate this behind conditionals to ensure that server-side rendering still works. We don't make any changes to any of that for the "browser" build, so it's entirely redundant. Hoping this also fixes the "Super expression must either be null or a function" error (#472) that some users have experienced with particular bundler configurations. The browser build may still be imported at "build/web/react-draggable.min.js". This is to prevent breakage only. The file is no longer minified to prevent possible [terser bugs](terser/terser#308).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug report or Feature request?
Bug.
Version (complete output of
terser -V
)terser 3.16.1
Complete CLI command or
minify()
options usedterser -m -c passes=4 --toplevel test.js
terser
inputterser
output or errorterser -m -c passes=3 --toplevel test.js
exports.withStyles=function(){!function(n){throw new TypeError("Super expression must be a function, not undefined")}(EXTERNAL())};
terser -m -c passes=1 --toplevel test.js
exports.withStyles=function(){return function(t){!function(t){if("function"!=typeof t)throw new TypeError("Super expression must be a function, not "+typeof t);Object.create(t)}(t)}(EXTERNAL())};
Expected result
The multi-pass output should not produce invalid code.
Further information
When we moved to up our passes of terser in our production builds this week, we discovered that this triggered an invalid optimization in the code that is bundled by 'react-with-styles' combined with babel's _inherits helper. (See: airbnb/react-with-styles#151)
I've reduced this down as best I can to a minimal test case, as seen above. Best I can guess this is a failure in the IIFE argument pushdown pre-emptively marking a variable as unused.
It's also worth noting that setting the
keep_fnames
option opts out of this bug, at an obvious optimization cost, even though there's no use of function names in this code:terser -m -c passes=3,keep_fnames --toplevel test.js
exports.withStyles=function t(){!function t(e){if("function"!=typeof e)throw new TypeError("Super expression must be a function, not "+typeof e);Object.create(e)}(EXTERNAL())};
The text was updated successfully, but these errors were encountered: