Nisbor
Nisbor

Reputation: 41

Google Closure Compiler addes "use strict" to result file when --language_out is set to ECMASCRIPT_2015

Google Closure Compiler addes "use strict" to result file when --language_out is set to ECMASCRIPT_2015

For some unknown reason, when setting the "--language_out ECMASCRIPT_2015" param, the program forces the use of strict mode and adds “use strict” at the beginning of the result file.

Neither "--jscomp_off es5Strict" no any undocumented params help. It looks like GCC in ECMASCRIPT_2015-compatible mode uses "strict mode" as default.

Anybody knows how to turn it off?

I use the last GCC version for java via bat-file command:

java -jar %USERPROFILE%\OneDrive\Portable\ClosureCompiler\cc.jar --js %1.%2 --js_output_file %1.min.%2 --language_in ECMASCRIPT_2015 --language_out ECMASCRIPT_2015 --jscomp_off es5Strict

Upvotes: 4

Views: 699

Answers (2)

If you are developing and working with Google Closure Compiler, you can disable strict mode with the following code:

CompilerOptions compilerOptions = new CompilerOptions();
compilerOptions.setEmitUseStrict(false);

List<SourceFile> externs = CommandLineRunner.getDefaultExterns();
compiler.compile(externs, Lists.newArrayList(input), compilerOptions);

Upvotes: 0

Alon Zakai
Alon Zakai

Reputation: 1048

There is now an option for this, --emit_use_strict=false

Upvotes: 3

Related Questions