Skip to content

Conversation

@sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Nov 13, 2023

When transpiling to ES5 use closure with SIMPLE_OPTIMIZATIONS rather then WHITESPACE_ONLY. This means that polyfills cant be included as needed and removes the limits on what ES6 features we can use.

The downside of this is that is slows down builds for ES5 users but this seems like a reasonable tradeoff. It also makes debugging harder for such users since closure will minify the names of locals in this configuration even though we pass
--formatting=PRETTY_PRINT which seems to prevent minification of global names.

Fixes: #11984

@sbc100 sbc100 requested review from RReverser and kripken November 13, 2023 19:07
@sbc100 sbc100 force-pushed the es5_transpile branch 2 times, most recently from cbb258d to ad1c276 Compare November 13, 2023 20:43
When transpiling to ES5 use closure with `SIMPLE_OPTIMIZATIONS` rather
then `WHITESPACE_ONLY`.  This means that polyfills cant be included
as needed and removes the limits on what ES6 features we can use.

The downside of this is that is slows down builds for ES5 users but
this seems like a reasonable tradeoff.

Fixes: emscripten-core#11984
@sbc100
Copy link
Collaborator Author

sbc100 commented Nov 15, 2023

ping..

@sbc100 sbc100 enabled auto-merge (squash) November 15, 2023 20:30
@sbc100 sbc100 disabled auto-merge November 15, 2023 21:07
@sbc100 sbc100 merged commit 9429b48 into emscripten-core:main Nov 15, 2023
@sbc100 sbc100 deleted the es5_transpile branch November 15, 2023 21:08
- JavaScript library code can now use the full range ES6 features and we rely
on closure compiler to transpile for ES5 when targetting older browsers.
For those that want to would rather perform transpilation seperately outside
of emscripten you can use the `-sPOLYFILL=0` setting. (#20700)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the connection between transpiling and polyfills? That POLYFILLS disables transpiling seems slightly surprising to me and I think might be for other readers.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I kind of lumped them together.

I do think its somewhat logical though since folks who use -sPOLYFILL=0 are basically saying "I promise to install my own polyfills".. otherwise the code simply won't run, and in almost all cases that I know of polyfills are normally installed by transpilers, so what they are really saying is "I promise to my own transpilation" to ES5 (or whatever).

I've not actually heard of anyone using -sPOLYFILL=0 in the wild, but if we hear back from suchusers that they want to use this setting and still have emscripten take care of transpiling we can consider a separate setting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow ES6 in emscripten output

3 participants