-
-
Notifications
You must be signed in to change notification settings - Fork 27k
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
[next] Revert to use ecma 5 in uglifyOptions #4234
Conversation
This will impact parsing of newer browser syntax, no? I believe #4221 is related. There is probably an uglify option we can shut off to disable this behavior -- I'd rather do that instead. |
Ah, yes, a closer look into the docs reveals that you can place the ecma option for each of {
parse: {ecma: 8,...},
compress: {ecma: 5,...},
output: {ecma: 5,...},
} which are the default values already. So I think the simplest thing is to not have any explicit ecma setting on our end. |
The defaults are already what we want
Output is not necessarily going to be Can you provide a sample output of something using newer features against this setting? e.g. |
Oh, I just toyed with this and it appears Let's be explicit and do to prevent any upstream changes by accident: {
parse: {ecma: 8,...},
compress: {ecma: 5,...},
output: {ecma: 5,...},
} And add an explanation for why the values are as such (and a link to this issue preceding it all). |
Alright, done :) |
Perfect, thanks for this! |
parse: { | ||
// we want uglify-js to parse ecma 8 code. However we want it to output | ||
// ecma 5 compliant code, to avoid issues with older browsers, this is | ||
// whey we put `ecma: 5` to the compress and output section |
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.
"why"
I'm a bit confused. Didn't we want to let people ship uncompiled code in production too if they don't care about older browsers per their browserlist? |
uglify-es is currently not configured to consider the browserlist settings. Also: this setting won't transpile your code down to es5, it will just avoid minification steps that only work for es6+.
|
Thanks for explaining. |
Yeah, it's a little counter-intuitive -- setting @danielberndt did you want to send a follow up to tweak the docs / fix that "why"? Also, how about we open an issue with uglify about supporting browserslist? |
Sure, will put a short version of my explanation as a code comment :) |
Ah now I see! The "why" was referring to a typo, and not a question 😅 |
Hi guys, could we release a fix for v2? |
I'd appreciate this as well. When can it be expected? |
It's already released :) you can check it here: https://unpkg.com/react-scripts@2.0.0-next.66cc7a90/config/webpack.config.prod.js |
Be sure you always install |
* Revert to use ecma 5 in uglifyOptions * remove explicit ecma version from uglifyOptions settings The defaults are already what we want * be explicit of where we use ecma: 8 and ecma: 5
Building my app using the [next] version of react-scripts lead to issues when trying to open the minified results on IE11.
It's a combination of using the commonmark.js library and using the
{ecma: 8}
in the uglifyOptions. That led to unicode characters in the output that can't be parsed by IE11. Also the Google crawler bot is yellingUnexpected token ILLEGAL
at the resulting code.Look here for another discussion about the same issue: rails/webpacker#1235