closure-compiler icon indicating copy to clipboard operation
closure-compiler copied to clipboard

DISCUSS: Should the default output language be `NO_TRANSPILE`?

Open brad4d opened this issue 5 years ago • 17 comments

It is now possible to output ES_2017 code, and in future we would really prefer to stay more on top of the output language level.

Currently the default output language level is still ES5 to support the most possible browsers by default. Would it now make sense to make the default NO_TRANSPILE, so you get the same language level out as you get in unless you specify otherwise?

Note that we're still almost certain to support new language levels as input before they are supported for output (just with a much smaller gap between). In such cases NO_TRANSPILE wouldn't work and we'd need to generate an error if the output language weren't explicitly specified.

Or would we default to the highest possible? That seems dangerous, since a new release of the compiler that silently switches the output from, say, ES_2019 to ES_2020 would break projects that were unintentionally relying on the fact that the default was ES_2019 just because we hadn't yet added support for ES_2020

brad4d avatar Mar 11 '19 17:03 brad4d

@ChadKillingsworth what is your opinion of this?

brad4d avatar Mar 11 '19 17:03 brad4d

Internal issue created http://b/128311967

brad4d avatar Mar 11 '19 17:03 brad4d

Requiring the --language_out would be "safe" but perhaps not the best user experience.

concavelenz avatar Mar 11 '19 17:03 concavelenz

The vast majority of usage externally is still ES5. I would leave the default there. Once Internet Explorer usage drops substantially I would expect a higher language level to be warrented.

ChadKillingsworth avatar Mar 12 '19 18:03 ChadKillingsworth

@ChadKillingsworth thanks for your input.

brad4d avatar Mar 12 '19 22:03 brad4d

@ChadKillingsworth Why do you feel ES5 is still dominant?

concavelenz avatar Mar 14 '19 04:03 concavelenz

For the output language? I know of zero projects which output ES6+ only. I know several that output ES5 and ES6. But the majority of projects I work with or contact still transpile to ES5 only.

ChadKillingsworth avatar Mar 15 '19 22:03 ChadKillingsworth

All my code is written in ECMA2018 it wouldn't make sense to build for 2018 when I publish for the web because it would break a lot of user-agents like the iPhone iOS 8 that I'm still on because I have no memory to update (please don't hack me), so in general it's would be one more argument to pass if you switched to the NO_TRANSPILE but I think you should keep it 2015 because it's the safest.

zavr-1 avatar Mar 22 '19 02:03 zavr-1

Why can language out not be ECMA2018? This breaks a lot of code. For example, regexp "dotall" support is in ECMA2018. Since closure always must transpilte to ECMA2017 or lower it will break any proper regexp using dotall /s flag

GHLover avatar Mar 27 '19 20:03 GHLover

@GHLover we should be making ES_2018 and ES_2019 output available very soon, possibly the next release. Transpilation happens about mid-way through compilation, after checks but before optimizations. We have to get the optimizations updated for the new language features before we can output them.

brad4d avatar Mar 27 '19 20:03 brad4d

I would definitely say so. Setting both flags to STABLE by default, coupled with the internal difference between STABLE_IN and STABLE_OUT, leads to transpilation by default (even with --WHITESPACE_ONLY flag) as seen in #3637.

I'd say that --NO_TRANSPILE language_out default is the most logically sensible decision, even though most projects are ES5, a user would not end up running into this issue unless they explicitly tried to target a different output language or what have you. The change would effectively solve issues by preventing them in the first place. Seems like all upside.

ctjlewis avatar Jul 27 '20 13:07 ctjlewis

@christiantjl If NO_TRANSPILE were the default, then projects using the default would end up broken when we add new features that are understood only by the front end (checks) of the compiler and not the back end (optimizations) yet.

Also, it would mean that the default output level would change a lot more frequently, likely taking people unpleasantly by surprise.

brad4d avatar Jul 27 '20 15:07 brad4d

@brad4d That's a good point. I would say "maybe just when language_in and language_out are both STABLE," but I suppose that would defeat the purpose of the specialized STABLE_IN feature set, which is presumably designed for the default case?

ctjlewis avatar Jul 27 '20 15:07 ctjlewis

I'm running v20210106 of the compiler and NO_TRANSPILE isn't mentioned in the help. Is it safe to use or is this an internal thing that I (as an end user) shouldn't be using? (I've got a bunch of files that only need whitespaces removal and nothing else; this NO_TRANSPILE option looks perfect for this.)

customcommander avatar Feb 04 '21 20:02 customcommander

@customcommander Use --compilation_level=WHITESPACE_ONLY for that use case. NO_TRANSPILE is a language_out flag.

ctjlewis avatar Feb 04 '21 20:02 ctjlewis

@ctjlewis Sorry I think I should have asked in this thread instead https://github.com/google/closure-compiler/issues/3637 - Thanks for your quick response!

customcommander avatar Feb 04 '21 20:02 customcommander

Oh, that's alright—anyway, NO_TRANSPILE is just an alternative output language, it just uses whatever the input language is, but with some extra caveats that it will not do any kind of transpilation at all.

You're safe to just try it as language_out.

ctjlewis avatar Feb 04 '21 20:02 ctjlewis