You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Replace require() with await import() in EXPORT_ES6 shell/runtime files
When EXPORT_ES6 is enabled, the generated JS used createRequire() to
polyfill require(), which breaks bundlers (webpack, Rollup, esbuild)
and Electron's renderer process. Since EXPORT_ES6 requires MODULARIZE,
the module body is wrapped in an async function where await is valid.
- shell.js: Remove createRequire block entirely. Use await import()
for worker_threads, fs, path, url, util. Replace __dirname with
import.meta.url for path resolution.
- shell_minimal.js: Same pattern for worker_threads and fs. Replace
__dirname with new URL(..., import.meta.url) for wasm file loading.
- runtime_debug.js: Skip local require() for fs/util when EXPORT_ES6,
reuse outer-scope variables from shell.js instead.
- runtime_common.js: Guard perf_hooks require() with EXPORT_ES6
alternative.
- preamble.js: Hoist await import('node:v8') above instantiateSync()
for NODE_CODE_CACHING since await can't be used inside sync functions.
0 commit comments