Skip to content

Commit 2a546ac

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 3ffc9a0 commit 2a546ac

12 files changed

+16
-51
lines changed

ChangeLog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ See docs/process.md for more on how version tagging works.
2020

2121
3.1.75 (in development)
2222
-----------------------
23+
- The `USE_ES6_IMPORT_META` settings was removed. This setting was always
24+
on by default, but now it cannot be disabled. This setting was originally
25+
added in 2019 as a temporary measure while engines and bundlers learned to
26+
deal with `import meta`. (#23171)
2327

2428
3.1.74 - 12/14/24
2529
-----------------

site/source/docs/tools_reference/settings_reference.rst

Lines changed: 0 additions & 12 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 7 deletions
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
];
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
53980
1+
53979
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
29400
1+
29399
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
52776
1+
52775

test/test_other.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -403,16 +403,6 @@ def test_emcc_output_mjs_closure(self):
403403
self.assertContained('new URL("hello_world.wasm", import.meta.url)', src)
404404
self.assertContained('hello, world!', self.run_js('hello_world.mjs'))
405405

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

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

0 commit comments

Comments
 (0)