Skip to content

Commit

Permalink
Allow ES2018 as input when running closure compiler
Browse files Browse the repository at this point in the history
This matches the input we accept when running the acorn compiler.

See #11984
  • Loading branch information
sbc100 committed Sep 8, 2020
1 parent bf9352b commit 97fed3b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
8 changes: 6 additions & 2 deletions tests/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -7760,7 +7760,11 @@ def build():
self.assertIdentical(normal, tiny)
self.assertIdentical(normal, huge)

def test_EM_ASM_ES6(self):
@parameterized({
'': ([],), # noqa
'closure': (['--closure', '1'],), # noqa
})
def test_EM_ASM_ES6(self, args):
create_test_file('src.cpp', r'''
#include <emscripten.h>
int main() {
Expand All @@ -7771,7 +7775,7 @@ def test_EM_ASM_ES6(self):
});
}
''')
self.run_process([EMCC, 'src.cpp', '-O2'])
self.run_process([EMCC, 'src.cpp'] + args)
self.assertContained('hello!', self.run_js('a.out.js'))

def test_check_sourcemapurl(self):
Expand Down
12 changes: 10 additions & 2 deletions tools/building.py
Original file line number Diff line number Diff line change
Expand Up @@ -1089,8 +1089,16 @@ def add_to_path(dirname):
outfile = filename + '.cc.js'
configuration.get_temp_files().note(outfile)

args = ['--compilation_level', 'ADVANCED_OPTIMIZATIONS' if advanced else 'SIMPLE_OPTIMIZATIONS',
'--language_in', 'ECMASCRIPT5']
args = ['--compilation_level', 'ADVANCED_OPTIMIZATIONS' if advanced else 'SIMPLE_OPTIMIZATIONS']
# Keep in sync with ecmaVersion in tools/acorn-optimizer.js
args += ['--language_in', 'ECMASCRIPT_2018']
# Tell closure not to do any tranpiling or inject any polyfills.
# At some point we may want to look into using this as way to convert to ES5 but
# babel is perhaps a better tool for that.
args += ['--language_out', 'NO_TRANSPILE']
# Tell closure never to inject the 'use strict' directive.
args += ['--emit_use_strict=false']

for e in CLOSURE_EXTERNS:
args += ['--externs', e]
args += ['--js_output_file', outfile]
Expand Down

0 comments on commit 97fed3b

Please sign in to comment.