From 28d65cbe05419d3d229e3435fa05df8a778e5772 Mon Sep 17 00:00:00 2001 From: Omer Akram Date: Thu, 27 Oct 2022 07:18:07 +0500 Subject: [PATCH] make slight adjustments to get things working --- taschenmesser/gclosure.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/taschenmesser/gclosure.py b/taschenmesser/gclosure.py index 63155f2..b9eaf6e 100644 --- a/taschenmesser/gclosure.py +++ b/taschenmesser/gclosure.py @@ -49,6 +49,7 @@ def js_builder(target, source, env): """ clevel = env.get('JS_COMPILATION_LEVEL', None) coutlang = env.get('JS_OUTPUT_LANG', None) + strict = env.get("JS_STRICT_MODE", None) if clevel == 'NONE': outfile = str(target[0]) @@ -68,13 +69,25 @@ def js_builder(target, source, env): if clevel in ['WHITESPACE_ONLY', 'SIMPLE_OPTIMIZATIONS', 'ADVANCED_OPTIMIZATIONS']: cmd.extend(['--compilation_level', clevel]) - if coutlang in ['ES2015', 'ES5', 'ES5_STRICT', 'ES3']: + # see https://github.com/google/closure-compiler/wiki/Flags-and-Options#basic-usage + out_levels = [ + "ECMASCRIPT3", "ECMASCRIPT5", "ECMASCRIPT_2015", "ECMASCRIPT_2016", "ECMASCRIPT_2017", + "ECMASCRIPT_2018", "ECMASCRIPT_2019", "ECMASCRIPT_2020", "ECMASCRIPT_2021", "STABLE", + "ECMASCRIPT_NEXT" + ] + + if coutlang in out_levels: cmd.extend(['--language_out', coutlang]) if env.get('JS_DEFINES'): for define in env['JS_DEFINES']: cmd.append('--define="%s=%s"' % (define, env['JS_DEFINES'][define])) + # allow to disable strict mode to workaround issues like: + # https://github.com/google/closure-compiler/issues/3014 + if strict is not None and strict in ["0", "1"]: + cmd.extend(['--strict_mode_input', "true" if strict == 1 else "false"]) + for file in source: cmd.extend(["--js", str(file)])