Skip to content

WHITESPACE_ONLY mode does non-whitespace-only optimizations #3637

@AshleyScirra

Description

@AshleyScirra

Closure compiler v20200614

in.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:

 {
  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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions