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 match the input we accept when running the acorn compiler.

Since we still want to output ES5 by default, also set language
out to ES5 for now.

See #11984
  • Loading branch information
sbc100 committed Sep 8, 2020
1 parent 1eb50fb commit 6031cba
Show file tree
Hide file tree
Showing 2 changed files with 10 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
6 changes: 4 additions & 2 deletions tools/building.py
Original file line number Diff line number Diff line change
Expand Up @@ -1089,8 +1089,10 @@ 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']

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

0 comments on commit 6031cba

Please sign in to comment.