diff --git a/src/babel-plugins/strip-node-prefix.mjs b/src/babel-plugins/strip-node-prefix.mjs new file mode 100644 index 0000000000000..24cdb7ed7c14f --- /dev/null +++ b/src/babel-plugins/strip-node-prefix.mjs @@ -0,0 +1,37 @@ +import { types as t } from '@babel/core'; + +export default function () { + 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 093a593df1be1..ed063b9dcd0f9 100644 --- a/src/lib/libatomic.js +++ b/src/lib/libatomic.js @@ -156,7 +156,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 958aa1e5a9eae..b0fa13981bda9 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 23bab958f3bbe..68e98e75ad8dc 100644 --- a/src/lib/libembind_gen.js +++ b/src/lib/libembind_gen.js @@ -907,7 +907,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 d26aa31728e67..291c223b0acf3 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 786c028d5a902..046fe70ba0c1c 100644 --- a/src/parseTools.mjs +++ b/src/parseTools.mjs @@ -1115,9 +1115,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'"; } } @@ -1125,9 +1125,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 ee63c96be8a17..846892b595c89 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 dba0aa4e9fc8c..c7fb3ee610c30 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": 129455, "a.out.nodebug.wasm.gz": 49210, - "total": 149109, - "total_gz": 57355, + "total": 149119, + "total_gz": 57356, "sent": [ "__cxa_throw", "_abort_js", diff --git a/test/codesize/test_codesize_cxx_ctors2.json b/test/codesize/test_codesize_cxx_ctors2.json index 4ac37d943f09e..51bb0101384da 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": 128882, "a.out.nodebug.wasm.gz": 48854, - "total": 148513, - "total_gz": 56986, + "total": 148523, + "total_gz": 56987, "sent": [ "__cxa_throw", "_abort_js", diff --git a/test/codesize/test_codesize_cxx_except.json b/test/codesize/test_codesize_cxx_except.json index 15cb284562627..b065f8233d12a 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": 171263, "a.out.nodebug.wasm.gz": 57315, - "total": 194578, - "total_gz": 66440, + "total": 194588, + "total_gz": 66442, "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 617b3ba6f4c9d..afd0bc39e3036 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": 144623, "a.out.nodebug.wasm.gz": 54880, - "total": 164093, - "total_gz": 62950, + "total": 164098, + "total_gz": 62952, "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 9b485ecfe69ea..2871a90de0a15 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": 142212, "a.out.nodebug.wasm.gz": 54344, - "total": 161751, - "total_gz": 62433, + "total": 161761, + "total_gz": 62435, "sent": [ "_abort_js", "_tzset_js", diff --git a/test/codesize/test_codesize_cxx_lto.json b/test/codesize/test_codesize_cxx_lto.json index f940e9bb676e5..d79f825fb708d 100644 --- a/test/codesize/test_codesize_cxx_lto.json +++ b/test/codesize/test_codesize_cxx_lto.json @@ -1,10 +1,10 @@ { - "a.out.js": 18993, - "a.out.js.gz": 7823, + "a.out.js": 19003, + "a.out.js.gz": 7825, "a.out.nodebug.wasm": 106448, "a.out.nodebug.wasm.gz": 42638, - "total": 125441, - "total_gz": 50461, + "total": 125451, + "total_gz": 50463, "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 a7dc6f34822f3..3c4a33bcb7c61 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": 235290, "a.out.nodebug.wasm.gz": 78917, - "total": 258655, - "total_gz": 88062, + "total": 258665, + "total_gz": 88064, "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 04ad444871798..3ec0e9711c96a 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": 131872, "a.out.nodebug.wasm.gz": 50209, - "total": 151526, - "total_gz": 58354, + "total": 151536, + "total_gz": 58355, "sent": [ "__cxa_throw", "_abort_js", diff --git a/test/codesize/test_codesize_cxx_wasmfs.json b/test/codesize/test_codesize_cxx_wasmfs.json index 273f67c8ec3e1..45f5678e3b516 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": 170045, "a.out.nodebug.wasm.gz": 62927, - "total": 177088, - "total_gz": 66249, + "total": 177098, + "total_gz": 66252, "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 6f271cf72afc0..133664706cd2c 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 92c970d70925d..0d99686c8764b 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": 50590, "a.out.nodebug.wasm.gz": 18089, - "total": 56055, - "total_gz": 20665, + "total": 56065, + "total_gz": 20667, "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 0ba509a1d7f0c..9f55fc56fedce 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": 244848, + "a.out.js": 244863, "a.out.nodebug.wasm": 577782, - "total": 822630, + "total": 822645, "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 7f5e25905054a..fa80bc9356d67 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 f8a4d00f4cb4e..0358131d79bc2 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": 659, - "total": 20629, - "total_gz": 7669, + "total": 20634, + "total_gz": 7672, "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 e1047891f0a3e..145521a29e4ec 100644 --- a/test/codesize/test_codesize_minimal_pthreads.json +++ b/test/codesize/test_codesize_minimal_pthreads.json @@ -1,9 +1,9 @@ { - "a.out.js": 7722, + "a.out.js": 7737, "a.out.js.gz": 3812, "a.out.nodebug.wasm": 19604, "a.out.nodebug.wasm.gz": 9079, - "total": 27326, + "total": 27341, "total_gz": 12891, "sent": [ "a (memory)", diff --git a/test/codesize/test_codesize_minimal_pthreads_memgrowth.json b/test/codesize/test_codesize_minimal_pthreads_memgrowth.json index 5439f3a922107..180082becb0af 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": 8145, + "a.out.js": 8160, "a.out.js.gz": 4011, "a.out.nodebug.wasm": 19605, "a.out.nodebug.wasm.gz": 9080, - "total": 27750, + "total": 27765, "total_gz": 13091, "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 b1c6db56dd000..f17d61b3d3268 100644 --- a/test/codesize/test_unoptimized_code_size.json +++ b/test/codesize/test_unoptimized_code_size.json @@ -1,16 +1,16 @@ { - "hello_world.js": 56957, - "hello_world.js.gz": 17711, + "hello_world.js": 56962, + "hello_world.js.gz": 17713, "hello_world.wasm": 15138, "hello_world.wasm.gz": 7455, - "no_asserts.js": 26627, - "no_asserts.js.gz": 8882, + "no_asserts.js": 26632, + "no_asserts.js.gz": 8885, "no_asserts.wasm": 12187, "no_asserts.wasm.gz": 5984, - "strict.js": 54932, - "strict.js.gz": 17044, + "strict.js": 54937, + "strict.js.gz": 17046, "strict.wasm": 15138, "strict.wasm.gz": 7450, - "total": 180979, - "total_gz": 64526 + "total": 180994, + "total_gz": 64533 } 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 e0aa5d1f442ca..cbbc1cfb21aad 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -13301,6 +13301,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 dcdc03fc458ef..69f788b0412e7 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 7533f563d67f5..c6b11c8657f59 100644 --- a/tools/link.py +++ b/tools/link.py @@ -2156,7 +2156,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(); }}''')