google / google/closure-compiler
WHITESPACE_ONLY mode does non-whitespace-only optimizations
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
Closure compiler v20200614
in.js:
```js
{
function foo(p) { self["external1"](p) }
console.log(foo());
console.log(foo());
}
```
Command: `java -jar ./closure-compiler.jar --js in.js --js_output_file out.js --compilation_level WHITESPACE_ONLY --formatting PRETTY_PRINT`
out.js:
```js
{
var foo = function(p) {
self["external1"](p);
};
console.log(foo());
console.log(foo());
}
;
```
Note that `function foo(p)` was rewritten as `var 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.
Contributor guide
Assessment
This issue has not been assessed yet.