diff --git a/.circleci/config.yml b/.circleci/config.yml index a578804df634e..8b4a366125730 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -890,6 +890,8 @@ jobs: core0.test_hello_world core0.test_hello_argc_pthreads core2.test_pthread_create + other.test_esm + other.test_esm_pthreads " test-deno: executor: linux-python @@ -908,6 +910,8 @@ jobs: core0.test_hello_world core0.test_hello_argc_pthreads core2.test_pthread_create + other.test_esm + other.test_esm_pthreads " test-jsc: executor: linux-python diff --git a/src/babel-plugins/strip-node-prefix.mjs b/src/babel-plugins/strip-node-prefix.mjs new file mode 100644 index 0000000000000..191fce47951ee --- /dev/null +++ b/src/babel-plugins/strip-node-prefix.mjs @@ -0,0 +1,48 @@ +/** + * @license + * Copyright 2026 The Emscripten Authors + * SPDX-License-Identifier: MIT + */ + +// A babel plugin to remove the leading `node:` prefix from all imports. + +export default function ({ types: t, targets }) { + // Skip this plugin for Node.js >= 16 + if (+targets().node.split('.')[0] >= 16) { + return {}; + } + + return { + name: 'strip-node-prefix', + visitor: { + // e.g. `import fs from 'node:fs'` + ImportDeclaration({ node }) { + if (node.source.value.startsWith('node:')) { + node.source.value = node.source.value.slice(5); + } + }, + + // e.g. `await import('node:fs')` + // Note: only here for reference, it's mangled with EMSCRIPTEN$AWAIT$IMPORT below. + ImportExpression({ node }) { + if (t.isStringLiteral(node.source) && node.source.value.startsWith('node:')) { + node.source.value = node.source.value.slice(5); + } + }, + + // e.g. `require('node:fs')` or EMSCRIPTEN$AWAIT$IMPORT('node:fs') + CallExpression({ node }) { + if ( + (t.isIdentifier(node.callee, { name: 'require' }) || + // Special placeholder for `await import` + // FIXME: Remove after PR https://github.com/emscripten-core/emscripten/pull/23730 is landed. + t.isIdentifier(node.callee, { name: 'EMSCRIPTEN$AWAIT$IMPORT' })) && + t.isStringLiteral(node.arguments[0]) && + node.arguments[0].value.startsWith('node:') + ) { + node.arguments[0].value = node.arguments[0].value.slice(5); + } + }, + }, + }; +} diff --git a/src/lib/libatomic.js b/src/lib/libatomic.js index e59dcd011b036..e1dbc5bc4b08a 100644 --- a/src/lib/libatomic.js +++ b/src/lib/libatomic.js @@ -161,7 +161,7 @@ addToLibrary({ emscripten_num_logical_cores: () => #if ENVIRONMENT_MAY_BE_NODE - ENVIRONMENT_IS_NODE ? require('os').cpus().length : + ENVIRONMENT_IS_NODE ? require('node:os').cpus().length : #endif navigator['hardwareConcurrency'], }); diff --git a/src/lib/libcore.js b/src/lib/libcore.js index 0ccf09ed67632..1355a7b075863 100644 --- a/src/lib/libcore.js +++ b/src/lib/libcore.js @@ -351,7 +351,7 @@ addToLibrary({ var cmdstr = UTF8ToString(command); if (!cmdstr.length) return 0; // this is what glibc seems to do (shell works test?) - var cp = require('child_process'); + var cp = require('node:child_process'); var ret = cp.spawnSync(cmdstr, [], {shell:true, stdio:'inherit'}); var _W_EXITCODE = (ret, sig) => ((ret) << 8 | (sig)); diff --git a/src/lib/libembind_gen.js b/src/lib/libembind_gen.js index dba519e04078e..c814634f8faa8 100644 --- a/src/lib/libembind_gen.js +++ b/src/lib/libembind_gen.js @@ -922,7 +922,7 @@ var LibraryEmbind = { const printer = new TsPrinter(moduleDefinitions); #endif const output = printer.print(); - var fs = require('fs'); + var fs = require('node:fs'); fs.writeFileSync(process.argv[2], output + '\n'); }, diff --git a/src/lib/libnodepath.js b/src/lib/libnodepath.js index 209b9e9340620..d891bf7339662 100644 --- a/src/lib/libnodepath.js +++ b/src/lib/libnodepath.js @@ -12,7 +12,7 @@ // operations. Hence, using `nodePath` should be safe here. addToLibrary({ - $nodePath: "require('path')", + $nodePath: "require('node:path')", $PATH__deps: ['$nodePath'], $PATH: `{ isAbs: nodePath.isAbsolute, diff --git a/src/lib/libwasi.js b/src/lib/libwasi.js index c9a20616d04fd..55a32db216022 100644 --- a/src/lib/libwasi.js +++ b/src/lib/libwasi.js @@ -571,7 +571,7 @@ var WasiLibrary = { #if ENVIRONMENT_MAY_BE_NODE && MIN_NODE_VERSION < 190000 // This block is not needed on v19+ since crypto.getRandomValues is builtin if (ENVIRONMENT_IS_NODE) { - var nodeCrypto = require('crypto'); + var nodeCrypto = require('node:crypto'); return (view) => nodeCrypto.randomFillSync(view); } #endif // ENVIRONMENT_MAY_BE_NODE diff --git a/src/lib/libwasm_worker.js b/src/lib/libwasm_worker.js index 84df15266aa7b..beea49fe5cd7a 100644 --- a/src/lib/libwasm_worker.js +++ b/src/lib/libwasm_worker.js @@ -286,7 +286,7 @@ if (ENVIRONMENT_IS_WASM_WORKER emscripten_navigator_hardware_concurrency: () => { #if ENVIRONMENT_MAY_BE_NODE - if (ENVIRONMENT_IS_NODE) return require('os').cpus().length; + if (ENVIRONMENT_IS_NODE) return require('node:os').cpus().length; #endif return navigator['hardwareConcurrency']; }, diff --git a/src/parseTools.mjs b/src/parseTools.mjs index 2b6c3865ee666..75d3a9b5cd9a7 100644 --- a/src/parseTools.mjs +++ b/src/parseTools.mjs @@ -1140,9 +1140,9 @@ function nodePthreadDetection() { // Under node we detect that we are running in a pthread by checking the // workerData property. if (EXPORT_ES6) { - return "(await import('worker_threads')).workerData === 'em-pthread'"; + return "(await import('node:worker_threads')).workerData === 'em-pthread'"; } else { - return "require('worker_threads').workerData === 'em-pthread'"; + return "require('node:worker_threads').workerData === 'em-pthread'"; } } @@ -1150,9 +1150,9 @@ function nodeWWDetection() { // Under node we detect that we are running in a wasm worker by checking the // workerData property. if (EXPORT_ES6) { - return "(await import('worker_threads')).workerData === 'em-ww'"; + return "(await import('node:worker_threads')).workerData === 'em-ww'"; } else { - return "require('worker_threads').workerData === 'em-ww'"; + return "require('node:worker_threads').workerData === 'em-ww'"; } } diff --git a/src/postamble.js b/src/postamble.js index ae4d02ceae9b6..7fd23b842370e 100644 --- a/src/postamble.js +++ b/src/postamble.js @@ -322,7 +322,7 @@ if (ENVIRONMENT_IS_NODE #endif ) { - const url = await import('url'); + const url = await import('node:url'); const isMainModule = url.pathToFileURL(process.argv[1]).href === import.meta.url; if (isMainModule) await init(); } diff --git a/src/preamble.js b/src/preamble.js index 78e11633ad8c2..f704fed9e72a9 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -555,7 +555,7 @@ function instantiateSync(file, info) { var binary = getBinarySync(file); #if NODE_CODE_CACHING if (ENVIRONMENT_IS_NODE) { - var v8 = require('v8'); + var v8 = require('node:v8'); // Include the V8 version in the cache name, so that we don't try to // load cached code from another version, which fails silently (it seems // to load ok, but we do actually recompile the binary every time). diff --git a/src/pthread_esm_startup.mjs b/src/pthread_esm_startup.mjs index 319e66086de48..8223489b3b63c 100644 --- a/src/pthread_esm_startup.mjs +++ b/src/pthread_esm_startup.mjs @@ -17,7 +17,7 @@ console.log("Running pthread_esm_startup"); if ({{{ nodeDetectionCode() }}}) { // Create as web-worker-like an environment as we can. globalThis.self = globalThis; - var worker_threads = await import('worker_threads'); + var worker_threads = await import('node:worker_threads'); globalThis.Worker = worker_threads.Worker; var parentPort = worker_threads['parentPort']; // Deno and Bun already have `postMessage` defined on the global scope and diff --git a/src/runtime_debug.js b/src/runtime_debug.js index a6e6a1823aba2..7c1170a3b3010 100644 --- a/src/runtime_debug.js +++ b/src/runtime_debug.js @@ -15,8 +15,8 @@ function dbg(...args) { // See https://github.com/emscripten-core/emscripten/issues/14804 if (ENVIRONMENT_IS_NODE) { // TODO(sbc): Unify with err/out implementation in shell.sh. - var fs = require('fs'); - var utils = require('util'); + var fs = require('node:fs'); + var utils = require('node:util'); function stringify(a) { switch (typeof a) { case 'object': return utils.inspect(a); diff --git a/src/shell.js b/src/shell.js index 58b5b7108ffc7..7a88a9937cfdb 100644 --- a/src/shell.js +++ b/src/shell.js @@ -112,13 +112,13 @@ if (ENVIRONMENT_IS_NODE) { #if EXPORT_ES6 // When building an ES module `require` is not normally available. // We need to use `createRequire()` to construct the require()` function. - const { createRequire } = await import('module'); + const { createRequire } = await import('node:module'); /** @suppress{duplicate} */ var require = createRequire(import.meta.url); #endif #if PTHREADS || WASM_WORKERS - var worker_threads = require('worker_threads'); + var worker_threads = require('node:worker_threads'); global.Worker = worker_threads.Worker; ENVIRONMENT_IS_WORKER = !worker_threads.isMainThread; #if PTHREADS @@ -200,11 +200,11 @@ if (ENVIRONMENT_IS_NODE) { // These modules will usually be used on Node.js. Load them eagerly to avoid // the complexity of lazy-loading. - var fs = require('fs'); + var fs = require('node:fs'); #if EXPORT_ES6 if (_scriptName.startsWith('file:')) { - scriptDirectory = require('path').dirname(require('url').fileURLToPath(_scriptName)) + '/'; + scriptDirectory = require('node:path').dirname(require('node:url').fileURLToPath(_scriptName)) + '/'; } #else scriptDirectory = __dirname + '/'; @@ -376,7 +376,7 @@ if (!ENVIRONMENT_IS_AUDIO_WORKLET) var defaultPrint = console.log.bind(console); var defaultPrintErr = console.error.bind(console); if (ENVIRONMENT_IS_NODE) { - var utils = require('util'); + var utils = require('node:util'); var stringify = (a) => typeof a == 'object' ? utils.inspect(a) : a; defaultPrint = (...args) => fs.writeSync(1, args.map(stringify).join(' ') + '\n'); defaultPrintErr = (...args) => fs.writeSync(2, args.map(stringify).join(' ') + '\n'); diff --git a/src/shell_minimal.js b/src/shell_minimal.js index f4957cafbc38c..40c690061048e 100644 --- a/src/shell_minimal.js +++ b/src/shell_minimal.js @@ -55,7 +55,7 @@ var ENVIRONMENT_IS_WEB = !ENVIRONMENT_IS_NODE; #if ENVIRONMENT_MAY_BE_NODE && (PTHREADS || WASM_WORKERS) if (ENVIRONMENT_IS_NODE) { - var worker_threads = require('worker_threads'); + var worker_threads = require('node:worker_threads'); global.Worker = worker_threads.Worker; } #endif @@ -99,7 +99,7 @@ if (ENVIRONMENT_IS_NODE && ENVIRONMENT_IS_SHELL) { var defaultPrint = console.log.bind(console); var defaultPrintErr = console.error.bind(console); if (ENVIRONMENT_IS_NODE) { - var fs = require('fs'); + var fs = require('node:fs'); defaultPrint = (...args) => fs.writeSync(1, args.join(' ') + '\n'); defaultPrintErr = (...args) => fs.writeSync(2, args.join(' ') + '\n'); } @@ -181,7 +181,7 @@ if (!ENVIRONMENT_IS_PTHREAD) { // Wasm or Wasm2JS loading: if (ENVIRONMENT_IS_NODE) { - var fs = require('fs'); + var fs = require('node:fs'); #if WASM == 2 if (globalThis.WebAssembly) Module['wasm'] = fs.readFileSync(__dirname + '/{{{ TARGET_BASENAME }}}.wasm'); else eval(fs.readFileSync(__dirname + '/{{{ TARGET_BASENAME }}}.wasm.js')+''); diff --git a/test/codesize/test_codesize_cxx_ctors1.json b/test/codesize/test_codesize_cxx_ctors1.json index 1fb6b9839a153..bc9726a9f1592 100644 --- a/test/codesize/test_codesize_cxx_ctors1.json +++ b/test/codesize/test_codesize_cxx_ctors1.json @@ -1,10 +1,10 @@ { - "a.out.js": 19654, - "a.out.js.gz": 8145, + "a.out.js": 19664, + "a.out.js.gz": 8146, "a.out.nodebug.wasm": 133734, "a.out.nodebug.wasm.gz": 51516, - "total": 153388, - "total_gz": 59661, + "total": 153398, + "total_gz": 59662, "sent": [ "__cxa_throw", "_abort_js", diff --git a/test/codesize/test_codesize_cxx_ctors2.json b/test/codesize/test_codesize_cxx_ctors2.json index c9ee2a9ed07ca..498fcf8884df2 100644 --- a/test/codesize/test_codesize_cxx_ctors2.json +++ b/test/codesize/test_codesize_cxx_ctors2.json @@ -1,10 +1,10 @@ { - "a.out.js": 19631, - "a.out.js.gz": 8132, + "a.out.js": 19641, + "a.out.js.gz": 8133, "a.out.nodebug.wasm": 133152, "a.out.nodebug.wasm.gz": 51189, - "total": 152783, - "total_gz": 59321, + "total": 152793, + "total_gz": 59322, "sent": [ "__cxa_throw", "_abort_js", diff --git a/test/codesize/test_codesize_cxx_except.json b/test/codesize/test_codesize_cxx_except.json index 2111fa0e20c1a..b895ed7526507 100644 --- a/test/codesize/test_codesize_cxx_except.json +++ b/test/codesize/test_codesize_cxx_except.json @@ -1,10 +1,10 @@ { - "a.out.js": 23315, - "a.out.js.gz": 9125, + "a.out.js": 23325, + "a.out.js.gz": 9127, "a.out.nodebug.wasm": 175691, "a.out.nodebug.wasm.gz": 59682, - "total": 199006, - "total_gz": 68807, + "total": 199016, + "total_gz": 68809, "sent": [ "__cxa_begin_catch", "__cxa_end_catch", diff --git a/test/codesize/test_codesize_cxx_except_wasm.json b/test/codesize/test_codesize_cxx_except_wasm.json index c5fa65f3bf466..f03a67e819883 100644 --- a/test/codesize/test_codesize_cxx_except_wasm.json +++ b/test/codesize/test_codesize_cxx_except_wasm.json @@ -1,10 +1,10 @@ { - "a.out.js": 19470, - "a.out.js.gz": 8070, + "a.out.js": 19475, + "a.out.js.gz": 8072, "a.out.nodebug.wasm": 149098, "a.out.nodebug.wasm.gz": 56901, - "total": 168568, - "total_gz": 64971, + "total": 168573, + "total_gz": 64973, "sent": [ "_abort_js", "_tzset_js", diff --git a/test/codesize/test_codesize_cxx_except_wasm_legacy.json b/test/codesize/test_codesize_cxx_except_wasm_legacy.json index 02635e9adb3e8..79dedd9454903 100644 --- a/test/codesize/test_codesize_cxx_except_wasm_legacy.json +++ b/test/codesize/test_codesize_cxx_except_wasm_legacy.json @@ -1,10 +1,10 @@ { - "a.out.js": 19539, - "a.out.js.gz": 8089, + "a.out.js": 19549, + "a.out.js.gz": 8091, "a.out.nodebug.wasm": 146681, "a.out.nodebug.wasm.gz": 56474, - "total": 166220, - "total_gz": 64563, + "total": 166230, + "total_gz": 64565, "sent": [ "_abort_js", "_tzset_js", diff --git a/test/codesize/test_codesize_cxx_lto.json b/test/codesize/test_codesize_cxx_lto.json index 23e027a546a99..96c543e9e952a 100644 --- a/test/codesize/test_codesize_cxx_lto.json +++ b/test/codesize/test_codesize_cxx_lto.json @@ -1,10 +1,10 @@ { - "a.out.js": 19001, - "a.out.js.gz": 7824, + "a.out.js": 19011, + "a.out.js.gz": 7826, "a.out.nodebug.wasm": 101673, "a.out.nodebug.wasm.gz": 40413, - "total": 120674, - "total_gz": 48237, + "total": 120684, + "total_gz": 48239, "sent": [ "a (emscripten_resize_heap)", "b (_setitimer_js)", diff --git a/test/codesize/test_codesize_cxx_mangle.json b/test/codesize/test_codesize_cxx_mangle.json index 56d121e05c927..57c68bc43a43d 100644 --- a/test/codesize/test_codesize_cxx_mangle.json +++ b/test/codesize/test_codesize_cxx_mangle.json @@ -1,10 +1,10 @@ { - "a.out.js": 23365, - "a.out.js.gz": 9145, + "a.out.js": 23375, + "a.out.js.gz": 9147, "a.out.nodebug.wasm": 239944, "a.out.nodebug.wasm.gz": 81208, - "total": 263309, - "total_gz": 90353, + "total": 263319, + "total_gz": 90355, "sent": [ "__cxa_begin_catch", "__cxa_end_catch", diff --git a/test/codesize/test_codesize_cxx_noexcept.json b/test/codesize/test_codesize_cxx_noexcept.json index 9dd4bc93427b3..31717d79d9002 100644 --- a/test/codesize/test_codesize_cxx_noexcept.json +++ b/test/codesize/test_codesize_cxx_noexcept.json @@ -1,10 +1,10 @@ { - "a.out.js": 19654, - "a.out.js.gz": 8145, + "a.out.js": 19664, + "a.out.js.gz": 8146, "a.out.nodebug.wasm": 136307, "a.out.nodebug.wasm.gz": 52390, - "total": 155961, - "total_gz": 60535, + "total": 155971, + "total_gz": 60536, "sent": [ "__cxa_throw", "_abort_js", diff --git a/test/codesize/test_codesize_cxx_wasmfs.json b/test/codesize/test_codesize_cxx_wasmfs.json index 0fc4f28818aa7..7fb26eda866bb 100644 --- a/test/codesize/test_codesize_cxx_wasmfs.json +++ b/test/codesize/test_codesize_cxx_wasmfs.json @@ -1,10 +1,10 @@ { - "a.out.js": 7043, - "a.out.js.gz": 3322, + "a.out.js": 7053, + "a.out.js.gz": 3325, "a.out.nodebug.wasm": 174601, "a.out.nodebug.wasm.gz": 65335, - "total": 181644, - "total_gz": 68657, + "total": 181654, + "total_gz": 68660, "sent": [ "__cxa_throw", "_abort_js", diff --git a/test/codesize/test_codesize_file_preload.expected.js b/test/codesize/test_codesize_file_preload.expected.js index 0b5c62f89b9ef..1030cbe8fad3a 100644 --- a/test/codesize/test_codesize_file_preload.expected.js +++ b/test/codesize/test_codesize_file_preload.expected.js @@ -190,7 +190,7 @@ var readAsync, readBinary; if (ENVIRONMENT_IS_NODE) { // These modules will usually be used on Node.js. Load them eagerly to avoid // the complexity of lazy-loading. - var fs = require("fs"); + var fs = require("node:fs"); scriptDirectory = __dirname + "/"; // include: node_shell_read.js readBinary = filename => { @@ -603,7 +603,7 @@ var PATH = { var initRandomFill = () => { // This block is not needed on v19+ since crypto.getRandomValues is builtin if (ENVIRONMENT_IS_NODE) { - var nodeCrypto = require("crypto"); + var nodeCrypto = require("node:crypto"); return view => nodeCrypto.randomFillSync(view); } return view => crypto.getRandomValues(view); diff --git a/test/codesize/test_codesize_file_preload.json b/test/codesize/test_codesize_file_preload.json index 3a486bce4d356..f3f9b8b4c2060 100644 --- a/test/codesize/test_codesize_file_preload.json +++ b/test/codesize/test_codesize_file_preload.json @@ -1,10 +1,10 @@ { - "a.out.js": 22561, - "a.out.js.gz": 9336, + "a.out.js": 22571, + "a.out.js.gz": 9339, "a.out.nodebug.wasm": 1681, "a.out.nodebug.wasm.gz": 960, - "total": 24242, - "total_gz": 10296, + "total": 24252, + "total_gz": 10299, "sent": [ "a (fd_write)" ], diff --git a/test/codesize/test_codesize_files_js_fs.json b/test/codesize/test_codesize_files_js_fs.json index 1e6532c6790b5..394c9faa62526 100644 --- a/test/codesize/test_codesize_files_js_fs.json +++ b/test/codesize/test_codesize_files_js_fs.json @@ -1,10 +1,10 @@ { - "a.out.js": 18273, - "a.out.js.gz": 7462, + "a.out.js": 18283, + "a.out.js.gz": 7464, "a.out.nodebug.wasm": 381, "a.out.nodebug.wasm.gz": 260, - "total": 18654, - "total_gz": 7722, + "total": 18664, + "total_gz": 7724, "sent": [ "a (fd_write)", "b (fd_read)", diff --git a/test/codesize/test_codesize_files_wasmfs.json b/test/codesize/test_codesize_files_wasmfs.json index 511872e65bbb0..f48848f5be360 100644 --- a/test/codesize/test_codesize_files_wasmfs.json +++ b/test/codesize/test_codesize_files_wasmfs.json @@ -1,10 +1,10 @@ { - "a.out.js": 5465, - "a.out.js.gz": 2576, + "a.out.js": 5475, + "a.out.js.gz": 2578, "a.out.nodebug.wasm": 51053, "a.out.nodebug.wasm.gz": 18176, - "total": 56518, - "total_gz": 20752, + "total": 56528, + "total_gz": 20754, "sent": [ "a (emscripten_date_now)", "b (emscripten_err)", diff --git a/test/codesize/test_codesize_hello_O0.json b/test/codesize/test_codesize_hello_O0.json index 1937b4808b565..ae1c3e5fc6f88 100644 --- a/test/codesize/test_codesize_hello_O0.json +++ b/test/codesize/test_codesize_hello_O0.json @@ -1,10 +1,10 @@ { - "a.out.js": 24220, - "a.out.js.gz": 8700, + "a.out.js": 24225, + "a.out.js.gz": 8703, "a.out.nodebug.wasm": 15138, "a.out.nodebug.wasm.gz": 7455, - "total": 39358, - "total_gz": 16155, + "total": 39363, + "total_gz": 16158, "sent": [ "fd_write" ], diff --git a/test/codesize/test_codesize_hello_O1.json b/test/codesize/test_codesize_hello_O1.json index 9525cad3cc8c3..9c4d7260067b2 100644 --- a/test/codesize/test_codesize_hello_O1.json +++ b/test/codesize/test_codesize_hello_O1.json @@ -1,10 +1,10 @@ { - "a.out.js": 6345, - "a.out.js.gz": 2460, + "a.out.js": 6350, + "a.out.js.gz": 2462, "a.out.nodebug.wasm": 2675, "a.out.nodebug.wasm.gz": 1491, - "total": 9020, - "total_gz": 3951, + "total": 9025, + "total_gz": 3953, "sent": [ "fd_write" ], diff --git a/test/codesize/test_codesize_hello_O2.json b/test/codesize/test_codesize_hello_O2.json index c0f30e38d682c..c22ad426dd9a4 100644 --- a/test/codesize/test_codesize_hello_O2.json +++ b/test/codesize/test_codesize_hello_O2.json @@ -1,10 +1,10 @@ { - "a.out.js": 4319, - "a.out.js.gz": 2131, + "a.out.js": 4324, + "a.out.js.gz": 2134, "a.out.nodebug.wasm": 1927, "a.out.nodebug.wasm.gz": 1138, - "total": 6246, - "total_gz": 3269, + "total": 6251, + "total_gz": 3272, "sent": [ "fd_write" ], diff --git a/test/codesize/test_codesize_hello_O3.json b/test/codesize/test_codesize_hello_O3.json index 1b9f5f4d33fd2..29437d2ab4ab1 100644 --- a/test/codesize/test_codesize_hello_O3.json +++ b/test/codesize/test_codesize_hello_O3.json @@ -1,10 +1,10 @@ { - "a.out.js": 4261, - "a.out.js.gz": 2091, + "a.out.js": 4266, + "a.out.js.gz": 2093, "a.out.nodebug.wasm": 1681, "a.out.nodebug.wasm.gz": 960, - "total": 5942, - "total_gz": 3051, + "total": 5947, + "total_gz": 3053, "sent": [ "a (fd_write)" ], diff --git a/test/codesize/test_codesize_hello_Os.json b/test/codesize/test_codesize_hello_Os.json index 560a05125f5ce..5f6563e9658b4 100644 --- a/test/codesize/test_codesize_hello_Os.json +++ b/test/codesize/test_codesize_hello_Os.json @@ -1,10 +1,10 @@ { - "a.out.js": 4261, - "a.out.js.gz": 2091, + "a.out.js": 4266, + "a.out.js.gz": 2093, "a.out.nodebug.wasm": 1671, "a.out.nodebug.wasm.gz": 964, - "total": 5932, - "total_gz": 3055, + "total": 5937, + "total_gz": 3057, "sent": [ "a (fd_write)" ], diff --git a/test/codesize/test_codesize_hello_Oz.json b/test/codesize/test_codesize_hello_Oz.json index 257881bb2e175..cbddd1fb6b2ae 100644 --- a/test/codesize/test_codesize_hello_Oz.json +++ b/test/codesize/test_codesize_hello_Oz.json @@ -1,10 +1,10 @@ { - "a.out.js": 3896, - "a.out.js.gz": 1895, + "a.out.js": 3901, + "a.out.js.gz": 1899, "a.out.nodebug.wasm": 1205, "a.out.nodebug.wasm.gz": 740, - "total": 5101, - "total_gz": 2635, + "total": 5106, + "total_gz": 2639, "sent": [ "a (fd_write)" ], diff --git a/test/codesize/test_codesize_hello_dylink.json b/test/codesize/test_codesize_hello_dylink.json index 6ce5218a1b710..e3faee66565a1 100644 --- a/test/codesize/test_codesize_hello_dylink.json +++ b/test/codesize/test_codesize_hello_dylink.json @@ -1,10 +1,10 @@ { - "a.out.js": 26695, - "a.out.js.gz": 11394, + "a.out.js": 26705, + "a.out.js.gz": 11396, "a.out.nodebug.wasm": 17730, "a.out.nodebug.wasm.gz": 8957, - "total": 44425, - "total_gz": 20351, + "total": 44435, + "total_gz": 20353, "sent": [ "__syscall_stat64", "emscripten_resize_heap", diff --git a/test/codesize/test_codesize_hello_dylink_all.json b/test/codesize/test_codesize_hello_dylink_all.json index 3a678da0d8a35..bf6f4b1fa04e0 100644 --- a/test/codesize/test_codesize_hello_dylink_all.json +++ b/test/codesize/test_codesize_hello_dylink_all.json @@ -1,7 +1,7 @@ { - "a.out.js": 244863, + "a.out.js": 244878, "a.out.nodebug.wasm": 577876, - "total": 822739, + "total": 822754, "sent": [ "IMG_Init", "IMG_Load", diff --git a/test/codesize/test_codesize_hello_export_nothing.json b/test/codesize/test_codesize_hello_export_nothing.json index a5690f5c08997..fbfe75ffeaff4 100644 --- a/test/codesize/test_codesize_hello_export_nothing.json +++ b/test/codesize/test_codesize_hello_export_nothing.json @@ -1,10 +1,10 @@ { - "a.out.js": 3172, - "a.out.js.gz": 1479, + "a.out.js": 3177, + "a.out.js.gz": 1483, "a.out.nodebug.wasm": 43, "a.out.nodebug.wasm.gz": 59, - "total": 3215, - "total_gz": 1538, + "total": 3220, + "total_gz": 1542, "sent": [], "imports": [], "exports": [ diff --git a/test/codesize/test_codesize_hello_single_file.json b/test/codesize/test_codesize_hello_single_file.json index 14add49122037..531826ef78b44 100644 --- a/test/codesize/test_codesize_hello_single_file.json +++ b/test/codesize/test_codesize_hello_single_file.json @@ -1,6 +1,6 @@ { - "a.out.js": 5366, - "a.out.js.gz": 2982, + "a.out.js": 5371, + "a.out.js.gz": 2984, "sent": [ "a (fd_write)" ] diff --git a/test/codesize/test_codesize_hello_wasmfs.json b/test/codesize/test_codesize_hello_wasmfs.json index 1b9f5f4d33fd2..29437d2ab4ab1 100644 --- a/test/codesize/test_codesize_hello_wasmfs.json +++ b/test/codesize/test_codesize_hello_wasmfs.json @@ -1,10 +1,10 @@ { - "a.out.js": 4261, - "a.out.js.gz": 2091, + "a.out.js": 4266, + "a.out.js.gz": 2093, "a.out.nodebug.wasm": 1681, "a.out.nodebug.wasm.gz": 960, - "total": 5942, - "total_gz": 3051, + "total": 5947, + "total_gz": 3053, "sent": [ "a (fd_write)" ], diff --git a/test/codesize/test_codesize_libcxxabi_message_O3.json b/test/codesize/test_codesize_libcxxabi_message_O3.json index 0f93dc4a08eca..bb31d9d714f0f 100644 --- a/test/codesize/test_codesize_libcxxabi_message_O3.json +++ b/test/codesize/test_codesize_libcxxabi_message_O3.json @@ -1,10 +1,10 @@ { - "a.out.js": 3523, - "a.out.js.gz": 1666, + "a.out.js": 3528, + "a.out.js.gz": 1668, "a.out.nodebug.wasm": 89, "a.out.nodebug.wasm.gz": 98, - "total": 3612, - "total_gz": 1764, + "total": 3617, + "total_gz": 1766, "sent": [], "imports": [], "exports": [ diff --git a/test/codesize/test_codesize_libcxxabi_message_O3_standalone.json b/test/codesize/test_codesize_libcxxabi_message_O3_standalone.json index 6ba822d4f6864..7c642202b392d 100644 --- a/test/codesize/test_codesize_libcxxabi_message_O3_standalone.json +++ b/test/codesize/test_codesize_libcxxabi_message_O3_standalone.json @@ -1,10 +1,10 @@ { - "a.out.js": 3570, - "a.out.js.gz": 1701, + "a.out.js": 3575, + "a.out.js.gz": 1704, "a.out.nodebug.wasm": 132, "a.out.nodebug.wasm.gz": 140, - "total": 3702, - "total_gz": 1841, + "total": 3707, + "total_gz": 1844, "sent": [ "proc_exit" ], diff --git a/test/codesize/test_codesize_mem_O3.json b/test/codesize/test_codesize_mem_O3.json index ece3f64d2aef4..9624d708670c0 100644 --- a/test/codesize/test_codesize_mem_O3.json +++ b/test/codesize/test_codesize_mem_O3.json @@ -1,10 +1,10 @@ { - "a.out.js": 4350, - "a.out.js.gz": 2094, + "a.out.js": 4355, + "a.out.js.gz": 2096, "a.out.nodebug.wasm": 5260, "a.out.nodebug.wasm.gz": 2419, - "total": 9610, - "total_gz": 4513, + "total": 9615, + "total_gz": 4515, "sent": [ "a (emscripten_resize_heap)" ], diff --git a/test/codesize/test_codesize_mem_O3_grow.json b/test/codesize/test_codesize_mem_O3_grow.json index 66585626670b6..ad537a5e34f18 100644 --- a/test/codesize/test_codesize_mem_O3_grow.json +++ b/test/codesize/test_codesize_mem_O3_grow.json @@ -1,10 +1,10 @@ { - "a.out.js": 4635, - "a.out.js.gz": 2243, + "a.out.js": 4640, + "a.out.js.gz": 2246, "a.out.nodebug.wasm": 5261, "a.out.nodebug.wasm.gz": 2419, - "total": 9896, - "total_gz": 4662, + "total": 9901, + "total_gz": 4665, "sent": [ "a (emscripten_resize_heap)" ], diff --git a/test/codesize/test_codesize_mem_O3_grow_standalone.json b/test/codesize/test_codesize_mem_O3_grow_standalone.json index 1c403f7649388..0ff54ce0ef04b 100644 --- a/test/codesize/test_codesize_mem_O3_grow_standalone.json +++ b/test/codesize/test_codesize_mem_O3_grow_standalone.json @@ -1,10 +1,10 @@ { - "a.out.js": 4102, - "a.out.js.gz": 1990, + "a.out.js": 4107, + "a.out.js.gz": 1992, "a.out.nodebug.wasm": 5547, "a.out.nodebug.wasm.gz": 2598, - "total": 9649, - "total_gz": 4588, + "total": 9654, + "total_gz": 4590, "sent": [ "args_get", "args_sizes_get", diff --git a/test/codesize/test_codesize_mem_O3_standalone.json b/test/codesize/test_codesize_mem_O3_standalone.json index d47c439e4f8c3..d861394930631 100644 --- a/test/codesize/test_codesize_mem_O3_standalone.json +++ b/test/codesize/test_codesize_mem_O3_standalone.json @@ -1,10 +1,10 @@ { - "a.out.js": 4035, - "a.out.js.gz": 1954, + "a.out.js": 4040, + "a.out.js.gz": 1956, "a.out.nodebug.wasm": 5472, "a.out.nodebug.wasm.gz": 2539, - "total": 9507, - "total_gz": 4493, + "total": 9512, + "total_gz": 4495, "sent": [ "args_get", "args_sizes_get", diff --git a/test/codesize/test_codesize_mem_O3_standalone_lib.json b/test/codesize/test_codesize_mem_O3_standalone_lib.json index 0b146e54484df..7d7fbbd10778e 100644 --- a/test/codesize/test_codesize_mem_O3_standalone_lib.json +++ b/test/codesize/test_codesize_mem_O3_standalone_lib.json @@ -1,10 +1,10 @@ { - "a.out.js": 3563, - "a.out.js.gz": 1689, + "a.out.js": 3568, + "a.out.js.gz": 1692, "a.out.nodebug.wasm": 5239, "a.out.nodebug.wasm.gz": 2359, - "total": 8802, - "total_gz": 4048, + "total": 8807, + "total_gz": 4051, "sent": [], "imports": [], "exports": [ diff --git a/test/codesize/test_codesize_mem_O3_standalone_narg.json b/test/codesize/test_codesize_mem_O3_standalone_narg.json index d69a63960fdb0..6a8940ba4291f 100644 --- a/test/codesize/test_codesize_mem_O3_standalone_narg.json +++ b/test/codesize/test_codesize_mem_O3_standalone_narg.json @@ -1,10 +1,10 @@ { - "a.out.js": 3570, - "a.out.js.gz": 1701, + "a.out.js": 3575, + "a.out.js.gz": 1704, "a.out.nodebug.wasm": 5265, "a.out.nodebug.wasm.gz": 2396, - "total": 8835, - "total_gz": 4097, + "total": 8840, + "total_gz": 4100, "sent": [ "proc_exit" ], diff --git a/test/codesize/test_codesize_mem_O3_standalone_narg_flto.json b/test/codesize/test_codesize_mem_O3_standalone_narg_flto.json index f94ad7a45f75b..e20a8e385dfc4 100644 --- a/test/codesize/test_codesize_mem_O3_standalone_narg_flto.json +++ b/test/codesize/test_codesize_mem_O3_standalone_narg_flto.json @@ -1,10 +1,10 @@ { - "a.out.js": 3570, - "a.out.js.gz": 1701, + "a.out.js": 3575, + "a.out.js.gz": 1704, "a.out.nodebug.wasm": 4207, "a.out.nodebug.wasm.gz": 2104, - "total": 7777, - "total_gz": 3805, + "total": 7782, + "total_gz": 3808, "sent": [ "proc_exit" ], diff --git a/test/codesize/test_codesize_minimal_64.json b/test/codesize/test_codesize_minimal_64.json index 2fcaae6dada80..a3efe1f7f92d7 100644 --- a/test/codesize/test_codesize_minimal_64.json +++ b/test/codesize/test_codesize_minimal_64.json @@ -1,10 +1,10 @@ { - "a.out.js": 2604, - "a.out.js.gz": 1247, + "a.out.js": 2609, + "a.out.js.gz": 1250, "a.out.nodebug.wasm": 75, "a.out.nodebug.wasm.gz": 88, - "total": 2679, - "total_gz": 1335, + "total": 2684, + "total_gz": 1338, "sent": [], "imports": [], "exports": [ diff --git a/test/codesize/test_codesize_minimal_O0.expected.js b/test/codesize/test_codesize_minimal_O0.expected.js index 23e18a65970cc..a836e1a0420a9 100644 --- a/test/codesize/test_codesize_minimal_O0.expected.js +++ b/test/codesize/test_codesize_minimal_O0.expected.js @@ -107,7 +107,7 @@ if (ENVIRONMENT_IS_NODE) { // These modules will usually be used on Node.js. Load them eagerly to avoid // the complexity of lazy-loading. - var fs = require('fs'); + var fs = require('node:fs'); scriptDirectory = __dirname + '/'; diff --git a/test/codesize/test_codesize_minimal_O0.json b/test/codesize/test_codesize_minimal_O0.json index f1861463b354a..64dd7944fbd5b 100644 --- a/test/codesize/test_codesize_minimal_O0.json +++ b/test/codesize/test_codesize_minimal_O0.json @@ -1,10 +1,10 @@ { - "a.out.js": 19493, - "a.out.js.gz": 7010, + "a.out.js": 19498, + "a.out.js.gz": 7013, "a.out.nodebug.wasm": 1136, "a.out.nodebug.wasm.gz": 656, - "total": 20629, - "total_gz": 7666, + "total": 20634, + "total_gz": 7669, "sent": [], "imports": [], "exports": [ diff --git a/test/codesize/test_codesize_minimal_O1.json b/test/codesize/test_codesize_minimal_O1.json index 392b4ac27d486..1ee812afcbccf 100644 --- a/test/codesize/test_codesize_minimal_O1.json +++ b/test/codesize/test_codesize_minimal_O1.json @@ -1,10 +1,10 @@ { - "a.out.js": 3061, - "a.out.js.gz": 1300, + "a.out.js": 3066, + "a.out.js.gz": 1302, "a.out.nodebug.wasm": 449, "a.out.nodebug.wasm.gz": 337, - "total": 3510, - "total_gz": 1637, + "total": 3515, + "total_gz": 1639, "sent": [], "imports": [], "exports": [ diff --git a/test/codesize/test_codesize_minimal_O2.json b/test/codesize/test_codesize_minimal_O2.json index afc724bf811ee..ab0eb13fd26e5 100644 --- a/test/codesize/test_codesize_minimal_O2.json +++ b/test/codesize/test_codesize_minimal_O2.json @@ -1,10 +1,10 @@ { - "a.out.js": 2352, - "a.out.js.gz": 1171, + "a.out.js": 2357, + "a.out.js.gz": 1175, "a.out.nodebug.wasm": 280, "a.out.nodebug.wasm.gz": 226, - "total": 2632, - "total_gz": 1397, + "total": 2637, + "total_gz": 1401, "sent": [], "imports": [], "exports": [ diff --git a/test/codesize/test_codesize_minimal_O3.json b/test/codesize/test_codesize_minimal_O3.json index b7ab6c28df39a..2bc3eca6c115a 100644 --- a/test/codesize/test_codesize_minimal_O3.json +++ b/test/codesize/test_codesize_minimal_O3.json @@ -1,10 +1,10 @@ { - "a.out.js": 2293, - "a.out.js.gz": 1137, + "a.out.js": 2298, + "a.out.js.gz": 1140, "a.out.nodebug.wasm": 75, "a.out.nodebug.wasm.gz": 87, - "total": 2368, - "total_gz": 1224, + "total": 2373, + "total_gz": 1227, "sent": [], "imports": [], "exports": [ diff --git a/test/codesize/test_codesize_minimal_Os.json b/test/codesize/test_codesize_minimal_Os.json index b7ab6c28df39a..2bc3eca6c115a 100644 --- a/test/codesize/test_codesize_minimal_Os.json +++ b/test/codesize/test_codesize_minimal_Os.json @@ -1,10 +1,10 @@ { - "a.out.js": 2293, - "a.out.js.gz": 1137, + "a.out.js": 2298, + "a.out.js.gz": 1140, "a.out.nodebug.wasm": 75, "a.out.nodebug.wasm.gz": 87, - "total": 2368, - "total_gz": 1224, + "total": 2373, + "total_gz": 1227, "sent": [], "imports": [], "exports": [ diff --git a/test/codesize/test_codesize_minimal_Os_mr.json b/test/codesize/test_codesize_minimal_Os_mr.json index ba8b6e7923c80..2f947a492386e 100644 --- a/test/codesize/test_codesize_minimal_Os_mr.json +++ b/test/codesize/test_codesize_minimal_Os_mr.json @@ -1,10 +1,10 @@ { - "a.out.js": 497, - "a.out.js.gz": 297, + "a.out.js": 502, + "a.out.js.gz": 299, "a.out.nodebug.wasm": 75, "a.out.nodebug.wasm.gz": 87, - "total": 572, - "total_gz": 384, + "total": 577, + "total_gz": 386, "sent": [], "imports": [], "exports": [ diff --git a/test/codesize/test_codesize_minimal_Oz-ctors.json b/test/codesize/test_codesize_minimal_Oz-ctors.json index d60fdef1cca9b..f299e2edd82f8 100644 --- a/test/codesize/test_codesize_minimal_Oz-ctors.json +++ b/test/codesize/test_codesize_minimal_Oz-ctors.json @@ -1,10 +1,10 @@ { - "a.out.js": 2272, - "a.out.js.gz": 1122, + "a.out.js": 2277, + "a.out.js.gz": 1126, "a.out.nodebug.wasm": 64, "a.out.nodebug.wasm.gz": 80, - "total": 2336, - "total_gz": 1202, + "total": 2341, + "total_gz": 1206, "sent": [], "imports": [], "exports": [ diff --git a/test/codesize/test_codesize_minimal_Oz.json b/test/codesize/test_codesize_minimal_Oz.json index b7ab6c28df39a..2bc3eca6c115a 100644 --- a/test/codesize/test_codesize_minimal_Oz.json +++ b/test/codesize/test_codesize_minimal_Oz.json @@ -1,10 +1,10 @@ { - "a.out.js": 2293, - "a.out.js.gz": 1137, + "a.out.js": 2298, + "a.out.js.gz": 1140, "a.out.nodebug.wasm": 75, "a.out.nodebug.wasm.gz": 87, - "total": 2368, - "total_gz": 1224, + "total": 2373, + "total_gz": 1227, "sent": [], "imports": [], "exports": [ diff --git a/test/codesize/test_codesize_minimal_esm.json b/test/codesize/test_codesize_minimal_esm.json index 71dc359fe1e37..5a870e26915e3 100644 --- a/test/codesize/test_codesize_minimal_esm.json +++ b/test/codesize/test_codesize_minimal_esm.json @@ -1,10 +1,10 @@ { - "a.out.js": 2429, - "a.out.js.gz": 1168, + "a.out.js": 2449, + "a.out.js.gz": 1174, "a.out.nodebug.wasm": 75, "a.out.nodebug.wasm.gz": 87, - "total": 2504, - "total_gz": 1255, + "total": 2524, + "total_gz": 1261, "sent": [], "imports": [], "exports": [ diff --git a/test/codesize/test_codesize_minimal_pthreads.json b/test/codesize/test_codesize_minimal_pthreads.json index fff2a19e079f4..2152bb03bba02 100644 --- a/test/codesize/test_codesize_minimal_pthreads.json +++ b/test/codesize/test_codesize_minimal_pthreads.json @@ -1,9 +1,9 @@ { - "a.out.js": 7755, + "a.out.js": 7770, "a.out.js.gz": 3820, "a.out.nodebug.wasm": 19604, "a.out.nodebug.wasm.gz": 9079, - "total": 27359, + "total": 27374, "total_gz": 12899, "sent": [ "a (memory)", diff --git a/test/codesize/test_codesize_minimal_pthreads_memgrowth.json b/test/codesize/test_codesize_minimal_pthreads_memgrowth.json index 944a1ce6196f9..e87560bf5d7ad 100644 --- a/test/codesize/test_codesize_minimal_pthreads_memgrowth.json +++ b/test/codesize/test_codesize_minimal_pthreads_memgrowth.json @@ -1,9 +1,9 @@ { - "a.out.js": 8178, + "a.out.js": 8193, "a.out.js.gz": 4022, "a.out.nodebug.wasm": 19605, "a.out.nodebug.wasm.gz": 9080, - "total": 27783, + "total": 27798, "total_gz": 13102, "sent": [ "a (memory)", diff --git a/test/codesize/test_codesize_minimal_wasmfs.json b/test/codesize/test_codesize_minimal_wasmfs.json index b7ab6c28df39a..2bc3eca6c115a 100644 --- a/test/codesize/test_codesize_minimal_wasmfs.json +++ b/test/codesize/test_codesize_minimal_wasmfs.json @@ -1,10 +1,10 @@ { - "a.out.js": 2293, - "a.out.js.gz": 1137, + "a.out.js": 2298, + "a.out.js.gz": 1140, "a.out.nodebug.wasm": 75, "a.out.nodebug.wasm.gz": 87, - "total": 2368, - "total_gz": 1224, + "total": 2373, + "total_gz": 1227, "sent": [], "imports": [], "exports": [ diff --git a/test/codesize/test_unoptimized_code_size.json b/test/codesize/test_unoptimized_code_size.json index e6509de000c32..a4009eca4b79a 100644 --- a/test/codesize/test_unoptimized_code_size.json +++ b/test/codesize/test_unoptimized_code_size.json @@ -1,16 +1,16 @@ { - "hello_world.js": 56901, - "hello_world.js.gz": 17707, + "hello_world.js": 56906, + "hello_world.js.gz": 17709, "hello_world.wasm": 15138, "hello_world.wasm.gz": 7455, - "no_asserts.js": 26571, - "no_asserts.js.gz": 8878, + "no_asserts.js": 26576, + "no_asserts.js.gz": 8881, "no_asserts.wasm": 12187, "no_asserts.wasm.gz": 5984, - "strict.js": 54876, - "strict.js.gz": 17043, + "strict.js": 54881, + "strict.js.gz": 17045, "strict.wasm": 15138, "strict.wasm.gz": 7450, - "total": 180811, - "total_gz": 64517 + "total": 180826, + "total_gz": 64524 } diff --git a/test/core/test_esm_integration.expected.mjs b/test/core/test_esm_integration.expected.mjs index 72bb4ce245601..8f52d97866f3f 100644 --- a/test/core/test_esm_integration.expected.mjs +++ b/test/core/test_esm_integration.expected.mjs @@ -8,7 +8,7 @@ export { default, _foo, _main, err, stringToNewUTF8 } from './hello_world.suppor import init from './hello_world.support.mjs'; const isNode = globalThis.process?.versions?.node && globalThis.process?.type != 'renderer'; if (isNode) { - const url = await import('url'); + const url = await import('node:url'); const isMainModule = url.pathToFileURL(process.argv[1]).href === import.meta.url; if (isMainModule) await init(); } diff --git a/test/test_other.py b/test/test_other.py index d6a7a88e74821..57a1c81815e2f 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -13305,6 +13305,15 @@ def check_for_es6(filename, expect): self.do_runf('test.c', expected, cflags=['--closure=1'], output_basename='test_closure') check_for_es6('test_closure.js', False) + def test_node_prefix_transpile(self): + self.run_process([EMCC, test_file('hello_world.c'), '-sEXPORT_ES6']) + content = read_file('a.out.js') + self.assertContained('node:', content) + + self.run_process([EMCC, test_file('hello_world.c'), '-sEXPORT_ES6', '-sMIN_NODE_VERSION=150000', '-Wno-transpile']) + content = read_file('a.out.js') + self.assertNotContained('node:', content) + def test_gmtime_noleak(self): # Confirm that gmtime_r does not leak when called in isolation. self.cflags.append('-fsanitize=leak') diff --git a/tools/building.py b/tools/building.py index 42e237a11893d..d1f065d94bf36 100644 --- a/tools/building.py +++ b/tools/building.py @@ -545,7 +545,13 @@ def transpile(filename): config = { 'sourceType': 'script', 'presets': ['@babel/preset-env'], + 'plugins': [], 'targets': {}, + 'parserOpts': { + # FIXME: Remove when updating to Babel 8, see: + # https://babeljs.io/docs/v8-migration-api#javascript-nodes + 'createImportExpressions': True, + }, } if settings.MIN_CHROME_VERSION != UNSUPPORTED: config['targets']['chrome'] = str(settings.MIN_CHROME_VERSION) @@ -555,6 +561,7 @@ def transpile(filename): config['targets']['safari'] = version_split(settings.MIN_SAFARI_VERSION) if settings.MIN_NODE_VERSION != UNSUPPORTED: config['targets']['node'] = version_split(settings.MIN_NODE_VERSION) + config['plugins'] = [path_from_root('src/babel-plugins/strip-node-prefix.mjs')] config_json = json.dumps(config, indent=2) outfile = shared.get_temp_files().get('babel.js').name config_file = shared.get_temp_files().get('babel_config.json').name diff --git a/tools/file_packager.py b/tools/file_packager.py index f9d896d278d2b..f02d6835aed0c 100755 --- a/tools/file_packager.py +++ b/tools/file_packager.py @@ -621,7 +621,7 @@ def generate_preload_js(data_target, data_files, metadata): if options.support_node and options.export_es6: ret += '''if (isNode) { - const { createRequire } = await import('module'); + const { createRequire } = await import('node:module'); /** @suppress{duplicate} */ var require = createRequire(import.meta.url); }\n''' diff --git a/tools/link.py b/tools/link.py index 08e7d05f372fe..c6dc8e39f9353 100644 --- a/tools/link.py +++ b/tools/link.py @@ -2161,7 +2161,7 @@ def create_esm_wrapper(wrapper_file, support_target, wasm_target): import init from '{support_url}'; const isNode = {node_detection_code()}; if (isNode) {{ - const url = await import('url'); + const url = await import('node:url'); const isMainModule = url.pathToFileURL(process.argv[1]).href === import.meta.url; if (isMainModule) await init(); }}''')