Skip to content

Closure Compiler doesn't respect --emit_use_strict #3508

@je-mos

Description

@je-mos

The current version of Closure Compiler v20191111 doesn't respect --emit_use_strict option.

java -jar closure-compiler.jar --compilation_level SIMPLE_OPTIMIZATIONS --strict_mode_input --language_out ECMASCRIPT3 --emit_use_strict --js cc_strict_test.js

Expected behaviour: The command should generate a file beginning with the line: "use strict';
Actual behaviour: --emit_use_strict is ignored and the produced file doesn't begin with 'use strict";

According to the changelog of version v20170521 --emit_use_strict should be supported in combination with ES3:

Allow --emit_use_strict flag to work in all language modes, including ES3.

But unfortunately this isn't the case. --emit_use_strict also does not work with other output language modes. For ECMASCRIPT5 we can instead use ECMASCRIPT5_STRICT as a workaround and newer language versions automatically enable Strict Mode (which can be disabled by using --emit_use_strict=false). For ES3 there are no such workarounds unfortunately.

Could you please fix this regression bug?

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    internal-issue-createdAn internal Google issue has been created to track this GitHub issuetriage-doneHas been reviewed by someone on triage rotation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions