Repository navigation
bake: provide every runtime helper from the dev server's bun:wrap module #44688
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,16 +6,7 @@ | |
| // Some build failures from the bundler surface as runtime errors here, such as | ||
| // `require` on a module with transitive top-level await, or a missing export. | ||
| // This was done to make incremental updates as isolated as possible. | ||
| import { | ||
| __callDispose, | ||
| __EARLY_RETURN_SENTINEL, | ||
| __legacyDecorateClassTS, | ||
| __legacyDecorateParamTS, | ||
| __legacyMetadataTS, | ||
| __MEMO_CACHE_SENTINEL, | ||
| __name, | ||
| __using, | ||
| } from "../../runtime.bun"; | ||
| import * as runtimeHelpers from "../../runtime.bun"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟣 pre-existing, not blocking: Browser users of the dev server on engines without Why this was flaggedIf a dev-server client runs in a browser that lacks Verification: Pre-existing and acknowledged in the PR description. A dev-server client page runs in a browser without a global |
||
| // This import is different based on client vs server side. | ||
| // On the server, remapping is done automatically. | ||
| import { type SourceMapURL, derefMapping } from "#stack-trace"; | ||
|
|
@@ -906,17 +897,9 @@ declare global { | |
| } | ||
|
|
||
| // bun:bake/server, bun:bake/client, and bun:wrap are | ||
| // provided by this file instead of the bundler | ||
| registerSynthetic("bun:wrap", { | ||
| __name, | ||
| __legacyDecorateClassTS, | ||
| __legacyDecorateParamTS, | ||
| __legacyMetadataTS, | ||
| __using, | ||
| __callDispose, | ||
| __MEMO_CACHE_SENTINEL, | ||
| __EARLY_RETURN_SENTINEL, | ||
| }); | ||
| // provided by this file instead of the bundler. | ||
| // The transpiler can emit any name in `Imports::ALL` (src/ast/runtime.rs) through `bun:wrap`. | ||
| registerSynthetic("bun:wrap", { ...runtimeHelpers }); | ||
|
|
||
| if (side === "server") { | ||
| registerSynthetic("bun:bake/server", { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟣 pre-existing, not blocking: Pre-existing sibling of this fix: a developer who edits src/runtime.js still gets a stale
bun runhelper module afterbun bd, because only the bake bundles now track it. Theruntime.out.jsstep in scripts/build/codegen.ts:504-525 lists onlysrc/runtime.bun.jsas its input, and theesbuildrule (scripts/build/codegen.ts:144) has no depfile, so an edit toruntime.js(which runtime.bun.js re-exports) never re-runs it. Fix: make every consumer of runtime.js rebuild when it changes, i.e. addresolve(cfg.cwd, "src", "runtime.js")to theinputsofemitRuntimeJsalongside the glob-sources change here, so thebun:wrapmodule served bybun run(src/runtime/jsc_hooks.rs:3599) is regenerated too.A small fix can ride a push you are already making; otherwise a short reply is enough.
Why this was flagged
A developer changes a helper in src/runtime.js and runs an incremental build. scripts/glob-sources.ts:68-69 now adds src/runtime.js and src/runtime.bun.js to bakeRuntime, so bake.client.js and bake.server.js are regenerated. But emitRuntimeJs at scripts/build/codegen.ts:500-529 declares
inputs: [src]where src is only src/runtime.bun.js, and the "esbuild" rule at scripts/build/codegen.ts:144-147 declares no depfile, so ninja does not know runtime.out.js depends on src/runtime.js. runtime.out.js is what src/ast/runtime.rs:21 embeds and what src/runtime/jsc_hooks.rs:3595-3602 serves as thebun:wrapmodule forbun run. The result is a binary whose dev-server helpers are current but whosebun runhelpers are the previous version; tests forbun runbehaviour pass or fail against stale code until a clean build. The base branch has the same gap for runtime.out.js and additionally had it for the bake bundles; this PR closes only the bake half of the class.Verification: src/runtime.bun.js:1 is
export * from "./runtime";, so runtime.out.js is a bundle of runtime.js content. scripts/build/codegen.ts:500-509 declaresinputs: [src]only, and theesbuildrule at scripts/build/codegen.ts:144-147 sets nodepfile/deps. So ninja has no edge from src/runtime.js to runtime.out.js. The base branch already fails the same way for runtime.out.js.