Skip to content

Commit 8b0b7bf

Browse files
authored
Convert acorn-optimizer to JS module. NFC (#20851)
1 parent 3482cd0 commit 8b0b7bf

File tree

7 files changed

+13
-13
lines changed

7 files changed

+13
-13
lines changed

.circleci/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,7 @@ jobs:
753753
test_targets: "
754754
other.test_gen_struct_info
755755
other.test_native_call_before_init
756+
other.test_js_optimizer_verbose
756757
other.test_node_unhandled_rejection
757758
other.test_full_js_library*
758759
core2.test_hello_world"
@@ -768,6 +769,7 @@ jobs:
768769
other.test_gen_struct_info
769770
other.test_native_call_before_init
770771
other.test_node_unhandled_rejection
772+
other.test_js_optimizer_verbose
771773
other.test_min_node_version
772774
other.test_node_emscripten_num_logical_cores
773775
core2.test_pthread_create

src/library_getvalue.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ var LibraryMemOps = {
6262

6363
#if SAFE_HEAP
6464
// The same as the above two functions, but known to the safeHeap pass
65-
// in tools/acorn-optimizer.js. The heap accesses within these two
65+
// in tools/acorn-optimizer.mjs. The heap accesses within these two
6666
// functions will *not* get re-written.
6767
// Note that we do not use the alias mechanism here since we need separate
6868
// instances of above setValueImpl/getValueImpl functions.

test/test_other.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2617,7 +2617,7 @@ def test_js_optimizer(self, input, passes):
26172617
input = test_file(input)
26182618
expected_file = os.path.splitext(input)[0] + '-output.js'
26192619
# test calling optimizer
2620-
js = self.run_process(config.NODE_JS + [path_from_root('tools/acorn-optimizer.js'), input] + passes, stdin=PIPE, stdout=PIPE).stdout
2620+
js = self.run_process(config.NODE_JS + [path_from_root('tools/acorn-optimizer.mjs'), input] + passes, stdin=PIPE, stdout=PIPE).stdout
26212621
if common.EMTEST_REBASELINE:
26222622
write_file(expected_file, js)
26232623
else:

third_party/terser/terser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6706,7 +6706,7 @@ const _NOINLINE = 0b00000100;
67066706
const _KEY = 0b00001000;
67076707
const _MANGLEPROP = 0b00010000;
67086708

6709-
// XXX Emscripten: export TreeWalker for walking through AST in acorn-optimizer.js.
6709+
// XXX Emscripten: export TreeWalker for walking through AST in acorn-optimizer.mjs.
67106710
exports.TreeWalker = TreeWalker;
67116711

67126712
/***********************************************************************

tools/acorn-optimizer.js renamed to tools/acorn-optimizer.mjs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
#!/usr/bin/env node
22

3-
'use strict';
4-
5-
const acorn = require('acorn');
6-
const terser = require('../third_party/terser/terser');
7-
const fs = require('fs');
3+
import * as acorn from 'acorn';
4+
import * as terser from '../third_party/terser/terser.js';
5+
import * as fs from 'fs';
86

97
// Utilities
108

tools/building.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ def js_optimizer(filename, passes):
349349

350350
# run JS optimizer on some JS, ignoring asm.js contents if any - just run on it all
351351
def acorn_optimizer(filename, passes, extra_info=None, return_output=False):
352-
optimizer = path_from_root('tools/acorn-optimizer.js')
352+
optimizer = path_from_root('tools/acorn-optimizer.mjs')
353353
original_filename = filename
354354
if extra_info is not None:
355355
temp_files = shared.get_temp_files()
@@ -579,7 +579,7 @@ def closure_compiler(filename, advanced=True, extra_closure_args=None):
579579
CLOSURE_EXTERNS += [path_from_root('src/closure-externs/minimal_runtime_worker_externs.js')]
580580

581581
args = ['--compilation_level', 'ADVANCED_OPTIMIZATIONS' if advanced else 'SIMPLE_OPTIMIZATIONS']
582-
# Keep in sync with ecmaVersion in tools/acorn-optimizer.js
582+
# Keep in sync with ecmaVersion in tools/acorn-optimizer.mjs
583583
args += ['--language_in', 'ECMASCRIPT_2021']
584584
# Tell closure not to do any transpiling or inject any polyfills.
585585
# At some point we may want to look into using this as way to convert to ES5 but

tools/js_optimizer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
temp_files = shared.get_temp_files()
2323

2424

25-
ACORN_OPTIMIZER = path_from_root('tools/acorn-optimizer.js')
25+
ACORN_OPTIMIZER = path_from_root('tools/acorn-optimizer.mjs')
2626

2727
NUM_CHUNKS_PER_CORE = 3
2828
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):
6565

6666
class Minifier:
6767
"""minification support. We calculate minification of
68-
globals here, then pass that into the parallel acorn-optimizer.js runners which
68+
globals here, then pass that into the parallel acorn-optimizer.mjs runners which
6969
perform minification of locals.
7070
"""
7171

@@ -75,7 +75,7 @@ def __init__(self, js):
7575
self.profiling_funcs = False
7676

7777
def minify_shell(self, shell, minify_whitespace):
78-
# Run through acorn-optimizer.js to find and minify the global symbols
78+
# Run through acorn-optimizer.mjs to find and minify the global symbols
7979
# We send it the globals, which it parses at the proper time. JS decides how
8080
# to minify all global names, we receive a dictionary back, which is then
8181
# used by the function processors

0 commit comments

Comments
 (0)