-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Use terser es6+ compatible for JS minification #26531
Conversation
ecma: 5, | ||
safari10: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to docs, this is mangle: { safari10: true }, output: { safari10: true }
. Do we prefer just the mangle safari option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should be setting both. I don't think the output option was available when we added the mangle setting, but maybe we just missed it.
* Enable when the following is resolved: | ||
* https://github.com/mishoo/UglifyJS2/issues/3010 | ||
*/ | ||
collapse_vars: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be fixed in terser.
You can verify that the bug which caused us to disable See #23388 for the PR which originally disabled |
ICFY report is in 😁
Bytes are saved. |
Just to highlight:
|
mangle: { | ||
safari10: true, | ||
}, | ||
terserOptions: { | ||
ecma: 5, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ecma
options are available for parse, compress and output. Would it make sense to keep all of these at the highest ecma
version available, and let babel deal with output?
https://github.com/fabiosantoscode/terser#minify-options
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably? Though if we misconfigure babel, uglify currently acts as a really bad canary...
But bumping it up would allow us to try to transpile to more modern targets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems good! Just needs a rebase to pick up shrinkwrap changes.
771df26
to
60baf77
Compare
Rebased with fresh |
Jetpack e2e tests are reporting failures. @brbrr will have a look tomorrow to see if failures are related. If not, we'll merge then. Thanks everyone! |
I'd say we good to go. Jetpack PR tests are something new, and may not behave :) Failures aren't related to this PR. |
Thanks for checking @brbrr! |
uglify-es is not maintained anymore: mishoo/UglifyJS#3156 (comment) Terser seems to be the replacement of choice, and is also what we use in Calypso: Automattic/wp-calypso#26531 This commit introduces gulp-minify, which uses terser behind the scenes: https://www.npmjs.com/package/gulp-minify
…11079) * New npm module for allowing gulp-uglify to process es6 * remove debug code * Move away from uglify-es. Use terser instead. uglify-es is not maintained anymore: mishoo/UglifyJS#3156 (comment) Terser seems to be the replacement of choice, and is also what we use in Calypso: Automattic/wp-calypso#26531 This commit introduces gulp-minify, which uses terser behind the scenes: https://www.npmjs.com/package/gulp-minify * Update yarn.lock
…11079) * New npm module for allowing gulp-uglify to process es6 * remove debug code * Move away from uglify-es. Use terser instead. uglify-es is not maintained anymore: mishoo/UglifyJS#3156 (comment) Terser seems to be the replacement of choice, and is also what we use in Calypso: Automattic/wp-calypso#26531 This commit introduces gulp-minify, which uses terser behind the scenes: https://www.npmjs.com/package/gulp-minify * Update yarn.lock
Use https://github.com/webpack-contrib/terser-webpack-plugin for JS minification
This appears to be the direction webpack-contrib is taking with regards to the unmaintained es6+ uglify-es minimizer.
See:
This PR is mostly to raise awareness for now. We might like to wait to see how community-wide adoption goes before making the change:
https://www.npmjs.com/package/terser-webpack-plugin