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
This uses the new StartExecutionCallbackWithModule embedder API added in #61548 to support ESM entrypoint in SEA via a new configuration field "mainFormat". The behavior currently aligns with the embedder API and is mostly in sync with the CommonJS entry point behavior, except that support for code caching and snapshot is left for follow-ups.
Similar to CommonJS entrypoints, non-builtin access is currently not supported - though the WIP VFS would unlock that. This PR would allow users that are bundling their apps for SEA building to target ESM instead of CommonJS for the bundle output.
// sea.mjs// Static import for builtins is supported.importassertfrom'node:assert';import{pathToFileURL}from'node:url';// Dynamic import() for builtins and top-level await are supportedconst{ strict }=awaitimport('node:assert');assert.strictEqual(strict,assert.strict);// import.meta is supported (mostly)assert.strictEqual(import.meta.url,pathToFileURL(process.execPath).href);assert.strictEqual(import.meta.filename,process.execPath);assert.strictEqual(import.meta.dirname,dirname(process.execPath));assert.strictEqual(import.meta.main,true);// import.meta.resolve is currently unsupported - will depend on something like VFS.
This uses the new StartExecutionCallbackWithModule embedder API added in #61548 to support ESM entrypoint in SEA via a new configuration field
"mainFormat". The behavior currently aligns with the embedder API and is mostly in sync with the CommonJS entry point behavior, except that support for code caching and snapshot is left for follow-ups.Similar to CommonJS entrypoints, non-builtin access is currently not supported - though the WIP VFS would unlock that. This PR would allow users that are bundling their apps for SEA building to target ESM instead of CommonJS for the bundle output.
Build with:
node --build-sea sea-config.json{ "main": "sea.mjs", "output": "sea", "mainFormat": "module", }Note: for follow-ups: