diff --git a/src/library_getvalue.js b/src/library_getvalue.js index 26a4bd014aa53..061b797c83a2d 100644 --- a/src/library_getvalue.js +++ b/src/library_getvalue.js @@ -62,7 +62,7 @@ var LibraryMemOps = { #if SAFE_HEAP // The same as the above two functions, but known to the safeHeap pass - // in tools/acorn-optimizer.js. The heap accesses within these two + // in tools/acorn-optimizer.mjs. The heap accesses within these two // functions will *not* get re-written. // Note that we do not use the alias mechanism here since we need separate // instances of above setValueImpl/getValueImpl functions. diff --git a/test/test_other.py b/test/test_other.py index e0c9954641f8b..c71470fc8ec3f 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -2617,7 +2617,7 @@ def test_js_optimizer(self, input, passes): input = test_file(input) expected_file = os.path.splitext(input)[0] + '-output.js' # test calling optimizer - js = self.run_process(config.NODE_JS + [path_from_root('tools/acorn-optimizer.js'), input] + passes, stdin=PIPE, stdout=PIPE).stdout + js = self.run_process(config.NODE_JS + [path_from_root('tools/acorn-optimizer.mjs'), input] + passes, stdin=PIPE, stdout=PIPE).stdout if common.EMTEST_REBASELINE: write_file(expected_file, js) else: diff --git a/third_party/terser/terser.js b/third_party/terser/terser.js index d22224a6aa239..d64f71ea6b4c7 100644 --- a/third_party/terser/terser.js +++ b/third_party/terser/terser.js @@ -6706,7 +6706,7 @@ const _NOINLINE = 0b00000100; const _KEY = 0b00001000; const _MANGLEPROP = 0b00010000; -// XXX Emscripten: export TreeWalker for walking through AST in acorn-optimizer.js. +// XXX Emscripten: export TreeWalker for walking through AST in acorn-optimizer.mjs. exports.TreeWalker = TreeWalker; /*********************************************************************** diff --git a/tools/acorn-optimizer.js b/tools/acorn-optimizer.mjs similarity index 99% rename from tools/acorn-optimizer.js rename to tools/acorn-optimizer.mjs index 4edaec54ba5ec..c62e29f066665 100755 --- a/tools/acorn-optimizer.js +++ b/tools/acorn-optimizer.mjs @@ -1,10 +1,8 @@ #!/usr/bin/env node -'use strict'; - -const acorn = require('acorn'); -const terser = require('../third_party/terser/terser'); -const fs = require('fs'); +import * as acorn from 'acorn'; +import * as terser from '../third_party/terser/terser.js'; +import * as fs from 'fs'; // Utilities diff --git a/tools/building.py b/tools/building.py index 555396eeedd4a..96b4928fca0ed 100644 --- a/tools/building.py +++ b/tools/building.py @@ -349,7 +349,7 @@ def js_optimizer(filename, passes): # run JS optimizer on some JS, ignoring asm.js contents if any - just run on it all def acorn_optimizer(filename, passes, extra_info=None, return_output=False): - optimizer = path_from_root('tools/acorn-optimizer.js') + optimizer = path_from_root('tools/acorn-optimizer.mjs') original_filename = filename if extra_info is not None: temp_files = shared.get_temp_files() @@ -579,7 +579,7 @@ def closure_compiler(filename, advanced=True, extra_closure_args=None): CLOSURE_EXTERNS += [path_from_root('src/closure-externs/minimal_runtime_worker_externs.js')] args = ['--compilation_level', 'ADVANCED_OPTIMIZATIONS' if advanced else 'SIMPLE_OPTIMIZATIONS'] - # Keep in sync with ecmaVersion in tools/acorn-optimizer.js + # Keep in sync with ecmaVersion in tools/acorn-optimizer.mjs args += ['--language_in', 'ECMASCRIPT_2021'] # Tell closure not to do any transpiling or inject any polyfills. # At some point we may want to look into using this as way to convert to ES5 but diff --git a/tools/js_optimizer.py b/tools/js_optimizer.py index b532ec70fe2ca..73eb0956e975f 100755 --- a/tools/js_optimizer.py +++ b/tools/js_optimizer.py @@ -22,7 +22,7 @@ temp_files = shared.get_temp_files() -ACORN_OPTIMIZER = path_from_root('tools/acorn-optimizer.js') +ACORN_OPTIMIZER = path_from_root('tools/acorn-optimizer.mjs') NUM_CHUNKS_PER_CORE = 3 MIN_CHUNK_SIZE = int(os.environ.get('EMCC_JSOPT_MIN_CHUNK_SIZE') or 512 * 1024) # configuring this is just for debugging purposes @@ -65,7 +65,7 @@ def split_funcs(js): class Minifier: """minification support. We calculate minification of - globals here, then pass that into the parallel acorn-optimizer.js runners which + globals here, then pass that into the parallel acorn-optimizer.mjs runners which perform minification of locals. """ @@ -75,7 +75,7 @@ def __init__(self, js): self.profiling_funcs = False def minify_shell(self, shell, minify_whitespace): - # Run through acorn-optimizer.js to find and minify the global symbols + # Run through acorn-optimizer.mjs to find and minify the global symbols # We send it the globals, which it parses at the proper time. JS decides how # to minify all global names, we receive a dictionary back, which is then # used by the function processors