lib: include ESM loader in the built-in snapshot#61769
lib: include ESM loader in the built-in snapshot#61769joyeecheung wants to merge 4 commits intonodejs:mainfrom
Conversation
|
Review requested:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #61769 +/- ##
==========================================
+ Coverage 89.74% 89.79% +0.04%
==========================================
Files 675 674 -1
Lines 204735 204688 -47
Branches 39348 39333 -15
==========================================
+ Hits 183737 183795 +58
+ Misses 13269 13191 -78
+ Partials 7729 7702 -27
🚀 New features to boost your workflow:
|
watilde
left a comment
There was a problem hiding this comment.
One question for my understanding: I noticed defaultResolve and defaultLoadSync are still lazy-loaded with ??= while translators was moved to pre-loading. Is this because:
- These are only used when there are no custom loader hooks (less common path)?
- Their dependencies are heavier and would hurt startup more?
- Or is this something that could be optimized similarly in the future?
Just curious about the design rationale
Did you mean in |
|
My code base in my local was very old, nvm. Thank you! |
Commit Queue failed- Loading data for nodejs/node/pull/61769 ✔ Done loading data for nodejs/node/pull/61769 ----------------------------------- PR info ------------------------------------ Title lib: include ESM loader in the built-in snapshot (#61769) Author Joyee Cheung <joyeec9h3@gmail.com> (@joyeecheung) Branch joyeecheung:esm-in-snapshot -> nodejs:main Labels lib / src, needs-ci, commit-queue-rebase Commits 3 - lib: remove top-level getOptionValue() calls in lib/internal/modules - lib: reduce cycles in esm loader and load it in snapshot - benchmark: add startup benchmark for ESM entrypoint Committers 1 - Joyee Cheung <joyeec9h3@gmail.com> PR-URL: https://github.com/nodejs/node/pull/61769 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/61769 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> -------------------------------------------------------------------------------- ℹ This PR was created on Wed, 11 Feb 2026 04:52:49 GMT ✔ Approvals: 3 ✔ - Matteo Collina (@mcollina) (TSC): https://github.com/nodejs/node/pull/61769#pullrequestreview-3782914586 ✔ - Daijiro Wachi (@watilde): https://github.com/nodejs/node/pull/61769#pullrequestreview-3784562017 ✔ - Geoffrey Booth (@GeoffreyBooth): https://github.com/nodejs/node/pull/61769#pullrequestreview-3787902819 ✘ Last GitHub CI failed ℹ Last Full PR CI on 2026-02-12T15:02:50Z: https://ci.nodejs.org/job/node-test-pull-request/71322/ - Querying data for job/node-test-pull-request/71322/ ✔ Build data downloaded - Querying failures of job/node-test-commit/85439/ ✔ Data downloaded ✘ 44 failure(s) on the last Jenkins CI run -------------------------------------------------------------------------------- ✔ Aborted `git node land` session in /home/runner/work/node/node/.ncuhttps://github.com/nodejs/node/actions/runs/21975249143 |
71c535a to
9cd87a2
Compare
|
Looks like this got broken by #61665 which added filtering of internal frames but the regex couldn't understand async frames. Updated the regex to handle async frames. cc @legendecas |
Benchmark number from an ARM64 Linux machine: empty/minimal CJS startup is now slightly slower in worker but other metrics get a slight boost (because they all incur ESM loader initialization). In reality ESM loading is likely to happen at some point in the lifetime of an application especially with the growing adoption of ESM and
require(esm), so real-world applications that are more than just an empty script should get a bit of speed up from being able to just deserialize the ESM loader instead of initializing it from scrach.