Skip to content

Commit 79f3fef

Browse files
committed
Remove USE_ES6_IMPORT_META setting
This setting was added (IIUC) as a temporary workaround for the lack or support for `import.meta` in browser and tooling. However `import.meta` has been at stage 4 for almost 5 years now: tc39/proposal-import-meta#21 Webback (released in 2020) also has builtin support for `import.meta`, so I would hope the use case for disabling this setting no longer exists. See #9234 and #8729
1 parent 2ac4c4f commit 79f3fef

File tree

9 files changed

+13
-48
lines changed

9 files changed

+13
-48
lines changed

ChangeLog.md

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ See docs/process.md for more on how version tagging works.
2525
`PATH.basename("a/b/..")` returns `".."` instead of `"a"`. This is in line with
2626
the behaviour of both node and coreutils, and is already the case when using
2727
NODERAWFS". (#23180)
28+
- The `USE_ES6_IMPORT_META` settings was removed. This setting was always
29+
on by default, but now it cannot be disabled. This setting was originally
30+
added in 2019 as a temporary measure while engines and bundlers learned to
31+
deal with `import meta`. (#23171)
2832

2933
3.1.74 - 12/14/24
3034
-----------------

site/source/docs/tools_reference/settings_reference.rst

-12
Original file line numberDiff line numberDiff line change
@@ -1977,18 +1977,6 @@ This is implicitly enabled if the output suffix is set to 'mjs'.
19771977

19781978
Default value: false
19791979

1980-
.. _use_es6_import_meta:
1981-
1982-
USE_ES6_IMPORT_META
1983-
===================
1984-
1985-
Use the ES6 Module relative import feature 'import.meta.url'
1986-
to auto-detect WASM Module path.
1987-
It might not be supported on old browsers / toolchains. This setting
1988-
may not be disabled when Node.js is targeted (-sENVIRONMENT=*node*).
1989-
1990-
Default value: true
1991-
19921980
.. _export_name:
19931981

19941982
EXPORT_NAME

src/library_pthread.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ var LibraryPThread = {
412412
#endif
413413
#endif
414414
};
415-
#if EXPORT_ES6 && USE_ES6_IMPORT_META
415+
#if EXPORT_ES6
416416
// If we're using module output, use bundler-friendly pattern.
417417
#if PTHREADS_DEBUG
418418
dbg(`Allocating a new web worker from ${import.meta.url}`);
@@ -434,7 +434,7 @@ var LibraryPThread = {
434434
// the first case in their bundling step. The latter ends up producing an invalid
435435
// URL to import from the server (e.g., for webpack the file:// path).
436436
worker = new Worker(new URL('{{{ TARGET_JS_NAME }}}', import.meta.url), workerOptions);
437-
#else
437+
#else // EXPORT_ES6
438438
var pthreadMainJs = _scriptName;
439439
#if expectToReceiveOnModule('mainScriptUrlOrBlob')
440440
// We can't use makeModuleReceiveWithVar here since we want to also
@@ -457,7 +457,7 @@ var LibraryPThread = {
457457
} else
458458
#endif
459459
worker = new Worker(pthreadMainJs, workerOptions);
460-
#endif // EXPORT_ES6 && USE_ES6_IMPORT_META
460+
#endif // EXPORT_ES6
461461
PThread.unusedWorkers.push(worker);
462462
},
463463

src/parseTools.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function processMacros(text, filename) {
4444
// Also handles #include x.js (similar to C #include <file>)
4545
export function preprocess(filename) {
4646
let text = read(filename);
47-
if (EXPORT_ES6 && USE_ES6_IMPORT_META) {
47+
if (EXPORT_ES6) {
4848
// `eval`, Terser and Closure don't support module syntax; to allow it,
4949
// we need to temporarily replace `import.meta` and `await import` usages
5050
// with placeholders during preprocess phase, and back after all the other ops.

src/preamble.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ var wasmBinaryFile = '{{{ WASM_BINARY_FILE }}}';
609609
#else
610610
var wasmBinaryFile;
611611
function findWasmBinary() {
612-
#if EXPORT_ES6 && USE_ES6_IMPORT_META && !AUDIO_WORKLET
612+
#if EXPORT_ES6 && !AUDIO_WORKLET
613613
if (Module['locateFile']) {
614614
#endif
615615
var f = '{{{ WASM_BINARY_FILE }}}';
@@ -619,7 +619,7 @@ function findWasmBinary() {
619619
}
620620
#endif
621621
return f;
622-
#if EXPORT_ES6 && USE_ES6_IMPORT_META && !AUDIO_WORKLET // In single-file mode, repeating WASM_BINARY_FILE would emit the contents again. For an Audio Worklet, we cannot use `new URL()`.
622+
#if EXPORT_ES6 && !AUDIO_WORKLET // In single-file mode, repeating WASM_BINARY_FILE would emit the contents again. For an Audio Worklet, we cannot use `new URL()`.
623623
}
624624
#if ENVIRONMENT_MAY_BE_SHELL
625625
if (ENVIRONMENT_IS_SHELL)

src/settings.js

+1-7
Original file line numberDiff line numberDiff line change
@@ -1353,13 +1353,6 @@ var MODULARIZE = false;
13531353
// [link]
13541354
var EXPORT_ES6 = false;
13551355

1356-
// Use the ES6 Module relative import feature 'import.meta.url'
1357-
// to auto-detect WASM Module path.
1358-
// It might not be supported on old browsers / toolchains. This setting
1359-
// may not be disabled when Node.js is targeted (-sENVIRONMENT=*node*).
1360-
// [link]
1361-
var USE_ES6_IMPORT_META = true;
1362-
13631356
// Global variable to export the module as for environments without a
13641357
// standardized module loading system (e.g. the browser and SM shell).
13651358
// [link]
@@ -2267,4 +2260,5 @@ var LEGACY_SETTINGS = [
22672260
['MIN_IE_VERSION', [0x7FFFFFFF], 'No longer supported'],
22682261
['WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG', [0], 'No longer supported'],
22692262
['AUTO_ARCHIVE_INDEXES', [0, 1], 'No longer needed'],
2263+
['USE_ES6_IMPORT_META', [1], 'Disabling is no longer supported'],
22702264
];

test/test_other.py

-15
Original file line numberDiff line numberDiff line change
@@ -401,16 +401,6 @@ def test_emcc_output_mjs_closure(self):
401401
self.assertContained('new URL("hello_world.wasm", import.meta.url)', src)
402402
self.assertContained('hello, world!', self.run_js('hello_world.mjs'))
403403

404-
def test_emcc_output_mjs_web_no_import_meta(self):
405-
# Ensure we don't emit import.meta.url at all for:
406-
# ENVIRONMENT=web + EXPORT_ES6 + USE_ES6_IMPORT_META=0
407-
self.run_process([EMCC, '-o', 'hello_world.mjs',
408-
test_file('hello_world.c'),
409-
'-sENVIRONMENT=web', '-sUSE_ES6_IMPORT_META=0'])
410-
src = read_file('hello_world.mjs')
411-
self.assertNotContained('import.meta.url', src)
412-
self.assertContained('export default Module;', src)
413-
414404
def test_export_es6_implies_modularize(self):
415405
self.run_process([EMCC, test_file('hello_world.c'), '-sEXPORT_ES6'])
416406
src = read_file('a.out.js')
@@ -420,11 +410,6 @@ def test_export_es6_requires_modularize(self):
420410
err = self.expect_fail([EMCC, test_file('hello_world.c'), '-sEXPORT_ES6', '-sMODULARIZE=0'])
421411
self.assertContained('EXPORT_ES6 requires MODULARIZE to be set', err)
422412

423-
def test_export_es6_node_requires_import_meta(self):
424-
err = self.expect_fail([EMCC, test_file('hello_world.c'),
425-
'-sENVIRONMENT=node', '-sEXPORT_ES6', '-sUSE_ES6_IMPORT_META=0'])
426-
self.assertContained('EXPORT_ES6 and ENVIRONMENT=*node* requires USE_ES6_IMPORT_META to be set', err)
427-
428413
def test_export_es6_allows_export_in_post_js(self):
429414
self.run_process([EMCC, test_file('hello_world.c'), '-O3', '-sEXPORT_ES6', '--post-js', test_file('export_module.js')])
430415
src = read_file('a.out.js')

tools/link.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -1440,11 +1440,6 @@ def phase_linker_setup(options, state, newargs): # noqa: C901, PLR0912, PLR0915
14401440
if 'MODULARIZE' in user_settings:
14411441
exit_with_error('EXPORT_ES6 requires MODULARIZE to be set')
14421442
settings.MODULARIZE = 1
1443-
if settings.ENVIRONMENT_MAY_BE_NODE and not settings.USE_ES6_IMPORT_META:
1444-
# EXPORT_ES6 + ENVIRONMENT=*node* requires the use of import.meta.url
1445-
if 'USE_ES6_IMPORT_META' in user_settings:
1446-
exit_with_error('EXPORT_ES6 and ENVIRONMENT=*node* requires USE_ES6_IMPORT_META to be set')
1447-
settings.USE_ES6_IMPORT_META = 1
14481443

14491444
if settings.MODULARIZE and not settings.DECLARE_ASM_MODULE_EXPORTS:
14501445
# When MODULARIZE option is used, currently requires declaring all module exports
@@ -2074,7 +2069,7 @@ def phase_source_transforms(options):
20742069
# both main code and libraries.
20752070
# See also: `preprocess` in parseTools.js.
20762071
def fix_es6_import_statements(js_file):
2077-
if not settings.EXPORT_ES6 or not settings.USE_ES6_IMPORT_META:
2072+
if not settings.EXPORT_ES6:
20782073
return
20792074

20802075
src = read_file(js_file)
@@ -2426,7 +2421,7 @@ def modularize():
24262421
# In EXPORT_ES6 + PTHREADS the 'thread' is actually an ES6 module
24272422
# webworker running in strict mode, so doesn't have access to 'document'.
24282423
# In this case use 'import.meta' instead.
2429-
if settings.EXPORT_ES6 and settings.USE_ES6_IMPORT_META:
2424+
if settings.EXPORT_ES6:
24302425
script_url = 'import.meta.url'
24312426
else:
24322427
script_url = "typeof document != 'undefined' ? document.currentScript?.src : undefined"

tools/settings.py

-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
'HEADLESS',
6868
'MODULARIZE',
6969
'EXPORT_ES6',
70-
'USE_ES6_IMPORT_META',
7170
'EXPORT_NAME',
7271
'DYNAMIC_EXECUTION',
7372
'PTHREAD_POOL_SIZE',

0 commit comments

Comments
 (0)