-
Notifications
You must be signed in to change notification settings - Fork 285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Snapshotting ES Modules #3981
Comments
I'm not sure you posted this in the correct repository. Moving this to /help 🙂 |
It was intentionally limited to the single file script as userland module loaders (both CJS and ESM) are not available at the time of building the startup snapshot. This is documented behavior. /cc @joyeecheung |
Can that script use top-level await somehow? |
Not for now. The script is not a module, while TLA is a module thing. We could implement support for snapshotting a single file module but that still requires snapshot support for the module loader (even just an internal one) which is a fair bit of work, though I plan to get it done some time this year. For now as the documentation suggests, users need to bundle their application first before building a snapshot (in the case of modules, transpilation needs to be done to convert it into a script with require() instead of import) |
This may be relevant: denoland/deno#17460 |
main.mjs 10mb 🕐 bootstrap need 40s 😭 SpringBoot era of nodejs without |
xref nodejs/node#35711 |
There has been no activity on this issue for 11 months. The help repository works best when sustained engagement moves conversation forward. The issue will be closed in 1 month. If you are still experiencing this issue on the latest supported versions of Node.js, please leave a comment. |
Tested with Node 20.10.0, issue still exists:
|
@krk have you tried using the new |
It seems there has been no activity on this issue for a while, and it is being closed in 30 days. If you believe this issue should remain open, please leave a comment. |
This fell through the cracks although with the recent require(esm) work paving the way I think this would be relatively straightforward to implement now. Will give it a look soon. |
ES Modules cannot be snapshotted now, the configure time parameter
--node-snapshot-main
fails with the errorwhich in turn points to https://github.com/nodejs/node/blob/v18.9.0/src/node_snapshotable.cc#L1198-L1224.
I was wondering if this is expected and is supporting ES Module snapshots viable.
The text was updated successfully, but these errors were encountered: