Skip to content

feat(codemode): Ship QuickJS files in Nitro Function output - #2531

Merged
thomasjiangcy merged 1 commit into
mainfrom
codemode/bundle-quickjs
Nov 2, 2026
Merged

thomasjiangcy merged 1 commit into
mainfrom
codemode/bundle-quickjs

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Prep work for Code Mode (#1987). This adds @earendil-works/[email protected] to @sentry/junior and makes Nitro builds ship the files it loads at run time. Nothing runs Code Mode yet.

At run time, pi-codemode reads quickjs-wasi/quickjs.wasm through createRequire and starts ./worker.js with new URL(..., import.meta.url). If Rolldown inlines the package, neither path resolves and the Function fails with Cannot find module 'quickjs-wasi/quickjs.wasm'. juniorNitro() now adds @earendil-works/pi-codemode* and quickjs-wasi* to traceDeps. Nitro then keeps both packages external and copies them whole into each Function. Because this happens in juniorNitro(), every app that uses it gets the change, including junior-prod. In the example build it adds about 1.6 MB to each of the 4 Functions.

Nitro traces only packages that the server bundle actually imports. With traceDeps and no import, the build output had neither file. So app.ts now has a bare import "@earendil-works/pi-codemode" as a placeholder until the Code Mode tool adds the real import. It loads the JS modules at cold start (about 15 ms locally) but does not load the wasm. The example Vercel output check now fails if quickjs.wasm or the pi-codemode worker.js is missing from the primary or queue Function.

traceDeps and its pkg* full-trace syntax have the same handling in every Nitro beta in the nitro peer range, from 3.0.260415 to 3.0.260903. I compared the published dist files, but I only ran a build with 3.0.260522-beta.

Open question for the Code Mode track: keep the bare import at startup, or replace it with a lazy import() at the tool's call site. Both work with this tracing. The output check guards the change either way.

via @thomasjiangcy.

--

View Session [Sentry]

Add @earendil-works/pi-codemode to @sentry/junior and trace it and
quickjs-wasi as whole packages from juniorNitro(), so every app that uses
juniorNitro() ships quickjs.wasm and the pi-codemode worker. The example
Vercel output check now fails when either file is missing.

Refs #1987

Co-Authored-By: Thomas Jiang <[email protected]>
@vercel

vercel Bot commented Nov 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Nov 2, 2026 9:57am UTC

Request Review

@sentry-junior
sentry-junior Bot marked this pull request as ready for review November 2, 2026 10:57
@github-actions github-actions Bot added the risk: high PR risk score: high label Nov 2, 2026
@thomasjiangcy
thomasjiangcy merged commit f1e57dd into main Nov 2, 2026
50 checks passed
@thomasjiangcy
thomasjiangcy deleted the codemode/bundle-quickjs branch November 2, 2026 11:10

This branch was successfully deployed

1 active deployment
Preview – junior-docs — 3ed34b68 Deployed Nov 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant