Skip to content

Commit 8b94b9e

Browse files
authored
Convert unsafe_optimizations.js to mjs. NFC (#21504)
1 parent 2ba2078 commit 8b94b9e

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

test/test_other.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13547,7 +13547,7 @@ def test_clock_nanosleep(self):
1354713547

1354813548
# Tests the internal test suite of tools/unsafe_optimizations.js
1354913549
def test_unsafe_optimizations(self):
13550-
self.run_process(config.NODE_JS_TEST + [path_from_root('tools', 'unsafe_optimizations.js'), '--test'])
13550+
self.run_process(config.NODE_JS_TEST + [path_from_root('tools', 'unsafe_optimizations.mjs'), '--test'])
1355113551

1355213552
@requires_v8
1355313553
def test_extended_const(self):

tools/link.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2075,15 +2075,15 @@ def phase_final_emitting(options, state, target, wasm_target):
20752075
# optimize by Closure, or unoptimalities that were left behind by processing
20762076
# steps that occurred after Closure.
20772077
if settings.MINIMAL_RUNTIME == 2 and settings.USE_CLOSURE_COMPILER and settings.DEBUG_LEVEL == 0:
2078-
shared.run_js_tool(utils.path_from_root('tools/unsafe_optimizations.js'), [final_js, '-o', final_js], cwd=utils.path_from_root('.'))
2078+
shared.run_js_tool(utils.path_from_root('tools/unsafe_optimizations.mjs'), [final_js, '-o', final_js], cwd=utils.path_from_root('.'))
20792079
save_intermediate('unsafe-optimizations')
20802080
# Finally, rerun Closure compile with simple optimizations. It will be able
20812081
# to further minify the code. (n.b. it would not be safe to run in advanced
20822082
# mode)
20832083
final_js = building.closure_compiler(final_js, advanced=False, extra_closure_args=options.closure_args)
20842084
# Run unsafe_optimizations.js once more. This allows the cleanup of newly
20852085
# unused things that closure compiler leaves behind (e.g `new Float64Array(x)`).
2086-
shared.run_js_tool(utils.path_from_root('tools/unsafe_optimizations.js'), [final_js, '-o', final_js], cwd=utils.path_from_root('.'))
2086+
shared.run_js_tool(utils.path_from_root('tools/unsafe_optimizations.mjs'), [final_js, '-o', final_js], cwd=utils.path_from_root('.'))
20872087
save_intermediate('unsafe-optimizations2')
20882088

20892089
fix_es6_import_statements(final_js)

tools/unsafe_optimizations.js renamed to tools/unsafe_optimizations.mjs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
/** Implements a set of potentially unsafe JavaScript AST optimizations for aggressive code size optimizations.
44
Enabled when building with -sMINIMAL_RUNTIME=2 linker flag. */
55

6-
'use strict';
7-
8-
const acorn = require('acorn');
9-
const fs = require('fs');
10-
const terser = require('../third_party/terser/terser');
6+
import * as fs from 'fs';
7+
import * as acorn from 'acorn';
8+
import * as terser from '../third_party/terser/terser.js';
119

1210
// Starting at the AST node 'root', calls the given callback function 'func' on all children and grandchildren of 'root'
1311
// that are of any of the type contained in array 'types'.

0 commit comments

Comments
 (0)