Repository navigation
sea: add test and update docs for import() with code cache - #62678
Conversation
|
Review requested:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #62678 +/- ##
==========================================
+ Coverage 89.81% 92.48% +2.66%
==========================================
Files 699 809 +110
Lines 216235 299477 +83242
Branches 41336 80051 +38715
==========================================
+ Hits 194216 276977 +82761
+ Misses 14129 12978 -1151
- Partials 7890 9522 +1632
🚀 New features to boost your workflow:
|
Signed-off-by: Ali Hassan <ali-hassan27@outlook.com>
c3bb922 to
ead9914
Compare
…amic-import.js Co-authored-by: Joyee Cheung <joyeec9h3@gmail.com>
|
This pull request has been marked as stale due to 90 days of inactivity. |
|
This pull request has been automatically closed after 30 days of inactivity following its stale status (no activity for a total of 120 days). |
|
Reopening since this still seems relevant on current main. |
|
Landed in 7d79ed3 |
Signed-off-by: Ali Hassan <ali-hassan27@outlook.com> PR-URL: #62678 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Signed-off-by: Ali Hassan <ali-hassan27@outlook.com> PR-URL: nodejs#62678 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Signed-off-by: Ali Hassan <ali-hassan27@outlook.com> PR-URL: #62678 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Node.js binaries compiled their whole bundle on every start. tsdown passes seaConfig through to `node --build-sea`, so the build now sets useCodeCache, which makes the SEA load the main module from a V8 code cache instead: a 30-command CLI runs ~15 M fewer instructions per start (~5.5%, 1 to 2 ms), for ~60 KB. The cache is written by the Node running --build-sea (the node on PATH) and V8 rejects it, printing "Code cache data rejected." on every start, unless the embedded binary is that exact build with the same V8 flags. Matching platform and version is not enough: a Nix build of Node 26.10 produced a cache the official 26.10 binary rejected, although both report the same v8.cachedDataVersionTag(). So the build enables it only when the node on PATH is byte-identical to the official binary tsdown embeds for the target (which implies the host target) and NODE_OPTIONS is unset (--jitless there also gets the cache rejected); every other build stays as before. import() of built-ins works with the cache for ESM main scripts, which is what Crust builds (Node 26 docs dropped the old import() caveat in nodejs/node#62678); the integration fixture now exercises it.
Node.js binaries compiled their whole bundle on every start. tsdown passes seaConfig through to `node --build-sea`, so the build now sets useCodeCache, which makes the SEA load the main module from a V8 code cache instead: a 30-command CLI runs ~15 M fewer instructions per start (~5.5%, 1 to 2 ms), for ~60 KB. The cache is written by the Node running --build-sea (the node on PATH) and V8 rejects it, printing "Code cache data rejected." on every start, unless the embedded binary is that exact build with the same V8 flags. Matching platform and version is not enough: a Nix build of Node 26.10 produced a cache the official 26.10 binary rejected, although both report the same v8.cachedDataVersionTag(). So the build enables it only when the node on PATH is byte-identical to the official binary tsdown embeds for the target (which implies the host target) and NODE_OPTIONS is unset (--jitless there also gets the cache rejected); every other build stays as before. import() of built-ins works with the cache for ESM main scripts, which is what Crust builds (Node 26 docs dropped the old import() caveat in nodejs/node#62678); the integration fixture now exercises it.
**Note:** import() does not work when useCodeCache is true.restriction from the API documentation.Assisted by: Claude Opus 4.6