Skip to content
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

Add control over JS version used in input and output of emscripten #12629

Closed
wants to merge 1 commit into from

Conversation

sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Oct 28, 2020

This allows users more control of the version of JS they want
to produce and the version they want to use in their input.

It also fixes a bug where we were introducing non-ES5 features into our
output files by using closure with --language_out set to NO_TRANSPILE and
--language_in set to ECMASCRIPT_2020.

Fixes: #12628

@sbc100 sbc100 requested review from RReverser and kripken October 28, 2020 19:00
@sbc100
Copy link
Collaborator Author

sbc100 commented Oct 28, 2020

I know it will probably make @RReverser sad to see this extra setting needed just to use modern JS.. on the other hand we do hope to bump to the default to ES6 in the very near future.

@sbc100 sbc100 force-pushed the es_version_settings branch 2 times, most recently from 6852be0 to e9e0a09 Compare October 28, 2020 19:02
tests/test_other.py Outdated Show resolved Hide resolved
@sbc100 sbc100 force-pushed the es_version_settings branch from b74af05 to 9f00b19 Compare October 28, 2020 20:05
@sbc100
Copy link
Collaborator Author

sbc100 commented Oct 28, 2020

This is first step towards #11984

@sbc100 sbc100 force-pushed the es_version_settings branch from 9f00b19 to 83bc885 Compare October 28, 2020 20:21
@RReverser
Copy link
Collaborator

I know it will probably make @RReverser sad to see this extra setting needed just to use modern JS.. on the other hand we do hope to bump to the default to ES6 in the very near future.

If I understand original issue correctly, Closure Compiler introduces a new syntax even when user didn't write it, and even when using NO_TRANSPILE?

It can be very surprising for users if so, and I agree fixing it is more important for now.

@sbc100
Copy link
Collaborator Author

sbc100 commented Oct 28, 2020

I know it will probably make @RReverser sad to see this extra setting needed just to use modern JS.. on the other hand we do hope to bump to the default to ES6 in the very near future.

If I understand original issue correctly, Closure Compiler introduces a new syntax even when user didn't write it, and even when using NO_TRANSPILE?

It can be very surprising for users if so, and I agree fixing it is more important for now.

Yes, I think my understanding of what NO_TRANSPILE on the output and ES_2020 on the input would do. I guess it makes perfect sense that reducing {foo: foo} to {foo} when the input is ES_2020 is perfectly in line with NO_TRANSPILE since they are both valid in ES_2020.

@sbc100
Copy link
Collaborator Author

sbc100 commented Oct 28, 2020

I spoke with alon about this and he thinks we should be able to do with without adding so many options.

I'm going to try to make this simpler if I can.

@RReverser
Copy link
Collaborator

I guess it makes perfect sense that reducing {foo: foo} to {foo} when the input is ES_2020 is perfectly in line with NO_TRANSPILE since they are both valid in ES_2020.

TBH it doesn't make much sense to me, because I'd expect NO_TRANSPILE to be strictly not transpiling anything at all, and the behaviour you're describing to only apply when someone explicitly sets ES_2020 as both input and output. Instead, it seems they treat NO_TRANSPILE as more of an alias.

@sbc100
Copy link
Collaborator Author

sbc100 commented Oct 29, 2020

Either way I guess NO_TRANSPILE isn't doing what we would need it to do in this case. I guess we want it to mean: don't do any size reduction that depend on any language features at all, even ones that exist in the version specific by the input. I think being explicit about that output version one way or another is the solution.

@RReverser
Copy link
Collaborator

Yeah, sounds fair. It's a shame we already called the ES module option EXPORT_ES6, I feel like now, whatever we add, will be easy to confuse with that one because EXPORT_ES6 sounds like a language version preference too.

@sbc100
Copy link
Collaborator Author

sbc100 commented Oct 29, 2020

Yeah, that options should really be called "EXPORT_MJS"... perhaps we could make that an alias.

Also, by the way the EXPORT_ES6 option is not necessary if your output file ends in ".mjs" or if you pass --oformat=mjs... Perhaps we should completely deprecate EXPORT_ES6 ?

T6his allows users more control of the version of JS they want
to produce and the version they want to use in their input.

It also fixes a bug where were introducing non-ES5 features into our
output files by using closer with --language_out set to NO_TRANSPILE and
--language_in set to ECMASCRIPT_2020.

Fixes: #12628
@sbc100 sbc100 force-pushed the es_version_settings branch from 83bc885 to 81090f5 Compare October 29, 2020 03:40
Base automatically changed from master to main March 8, 2021 23:49
@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant.

@stale stale bot added the wontfix label Apr 16, 2022
@sbc100 sbc100 closed this Jul 13, 2024
@sbc100 sbc100 deleted the es_version_settings branch July 13, 2024 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

closure compiler can introduce non-ES5 constructs
2 participants