feat(bun): unlock Phase C selective plugin reload via bun#39426 - #2
Open
ebowwa wants to merge 6 commits into
Open
feat(bun): unlock Phase C selective plugin reload via bun#39426#2ebowwa wants to merge 6 commits into
ebowwa wants to merge 6 commits into
Conversation
added 6 commits
August 17, 2026 09:25
Our upstream PR (a file:// URL's query is part of the module key) is the missing public-API primitive for per-module reload on Bun — the capability @cordisjs/plugin-hmr gets on Node from --expose-internals internals. - tests/bun/fixtures/selective-reload-driver.ts + selective-reload.spec.ts: capability-gated spec proving the full swap contract — fresh module instance per ?gen=N, old fiber disposed only after the new applies, root effects survive unduplicated, single disposal at shutdown. Probes the runner binary (BUN_QUERY_BUSTING_BIN or a local .upstream/bun debug build); stock Bun skips cleanly. - repros/selective-reload.ts: manual narrative version. - docs: Phase C section rewritten from 'deferred' to 'primitive done'; suite now 69 tests (68 + the gated one); Phase 10 status recorded. Verified: 69/69 with the bun#39426 debug build present; the full Cordis suite also runs green on that build; skip path exercised on stock Bun.
build/release/bun (the ~60-90MB usable binary) checked before the debug build; env override unchanged.
…dling - build:release from the PR branch → 1.4.0-canary.1+c16333e9e; preserved at .upstream/bin/bun-39426 (59 MB, git-excluded); build dir reclaimed - verified: selective-reload spec + full 69/69 suite against it; real-app smoke (bin.bun.js boots, loads plugin, SIGINT root disposal, exit 0) - spec: resolve() the BUN_QUERY_BUSTING_BIN override — the driver child runs from a temp cwd, so a relative path silently broke spawn (caught during release verification) - docs: 'Running Cordis on the contributed Bun today' usage section; Phase 10 binary record incl. prior-art note re #35601
The release binary (1.4.0-canary.1+c16333e9e) that Cordis is verified to run on: checksum recorded for verification, rebuild path documented.
ebowwa
pushed a commit
that referenced
this pull request
Aug 21, 2026
ebowwa
pushed a commit
that referenced
this pull request
Aug 21, 2026
… + disclosure Our #39426 partially duplicates robobun's earlier #35601 (same diagnosis, broader coverage, also fixes #13391, but stalled/dirty since Jul 26). Disclosed on both PRs; Cordis PR #2 unaffected (capability gating). Lesson: run the is:pr <issue> prior-art search before opening a fix.
ebowwa
pushed a commit
that referenced
this pull request
Aug 21, 2026
…lter, history, adjacent issues) Map: #35601 (our dup, stalled), #35703 (fragments, claimed), #37702 (plugin prefilter vs query dots, adjacent non-conflicting), #16456 (merged Jan 2025 — introduced relative+query), #13391 (astro, covered), #35345 (lcov re-import bug — becomes reachable via file:// queries once either fix lands; cross-reference kept local), #7823 (mock.restore). Verdict: neighborhood fully occupied by the Bun team's in-flight work; no uncontested target remains. Our plays: fresh-on-main #39426, downstream validation, Cordis PR #2 capability gating.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Unlocks Phase C — selective plugin reload on Bun — using the public-API primitive fixed by our upstream PR oven-sh/bun#39426 ("keep a
file://URL's query in module keys", fixes #21346).Before #39426,
import(url + "?v=N")returned the same cached module instance for every query on Bun, so per-module reload via public APIs was impossible — the reason selective HMR was deferred to Phase C indocs/BUN_COMPATIBILITY.md.@cordisjs/plugin-hmrgets this capability on Node only through--expose-internalsmodule-loader internals, which Bun does not expose.With the fix, the whole primitive is two public calls:
What's included
tests/bun/selective-reload.spec.ts(+fixtures/selective-reload-driver.ts) — asserts the full swap contract from the child process transcript:?gen=N(captured=reloadedproves a new evaluation)tests/bun/repros/selective-reload.ts— manual narrative version (README updated)BUN_COMPATIBILITY.mdrewritten from "deferred" to "primitive done" (remaining production gaps honestly listed: fs-watch → generations, config preservation, rollback); Phase 10 recorded inBUN_PORT_STATUS.mdCapability gating (not version gating)
The spec probes the runner binary for query-busting behavior and skips cleanly when absent — so:
hot.spec.ts(#32856-gated)Test plan
bun test tests/bun/selective-reload.spec.tsagainst a release build of the PR branch (1.4.0-canary.1+c16333e9e) — 1 pass / 14 expects (transcript-ordering assertions); also verified against the debug buildbin.bun.jsboots Cordis, loads a plugin, SIGINT disposes the root, exit 0BUN_QUERY_BUSTING_BIN(nowresolve()d — the driver child runs from a temp cwd) →.upstream/bun/build/release/bun→build/debug/bun-debug→ skipNotes
feat/bun-compat(feat: first-class Bun compatibility (core, timer, logger-console, loader, include) #1); merge feat: first-class Bun compatibility (core, timer, logger-console, loader, include) #1 first, then this (or rebase freely — one commit).