-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
WHITESPACE_ONLY mode does non-whitespace-only optimizations #3637
Comments
Following for updates. This is expected if @brad4d, I managed to make progress on running the |
Any language_out above ECMASCRIPT_2015 should avoid this issue. "STABLE" as language_out is ECMASCRIPT5 currently (but for no good reason at this point). I think that I would like to take WHITESPACE_ONLY back to its original intent: simply parse and print. That however, would mean that this would be restricted to a single "module" file input, or any number of scripts (which can be concatenated) but not both. |
@concavelenz After spending a few days diving through the source I found the |
Is that an undocumented option? The flags and options documentation doesn't appear to reference it. |
@AshleyScirra Yeah, I only found it in passing. The only public reference I can find to it is @brad4d's issue #3256. See the output for 'use strict';
{
function foo(p) {
self["external1"](p);
}
console.log(foo());
console.log(foo());
}
; I would submit a PR to add it to the documentation, but Github doesn't support it for wiki pages. =( Another secret flag I've found is the |
What's the difference between NO_TRANSPILE and setting both the input and output language to the same thing? |
@AshleyScirra There isn't supposed to be one - same input/output language should also imply no transpilation. It doesn't end up being 100% coverage, but it does work usually:
'use strict';
{
function foo(p) {
self["external1"](p);
}
console.log(foo());
console.log(foo());
}
; Also works for
{
var foo = function(p) {
self["external1"](p);
};
console.log(foo());
console.log(foo());
}
; Using
'use strict';
{
function foo(p) {
self["external1"](p);
}
console.log(foo());
console.log(foo());
}
; It's definitely a bug, but |
Closure compiler v20200614
in.js:
Command:
java -jar ./closure-compiler.jar --js in.js --js_output_file out.js --compilation_level WHITESPACE_ONLY --formatting PRETTY_PRINT
out.js:
Note that
function foo(p)
was rewritten asvar foo = function(p)
. This is not a whitespace-only change. It also causes a bug (#3623). Therefore even using the lowest tier of WHITESPACE_ONLY optimizations, we cannot escape this bug. I think it is reasonable to expect WHITESPACE_ONLY to only do what it says and not make other adjustments which alter the way scripts work.The text was updated successfully, but these errors were encountered: