Repository navigation
Conversation
|
Updated 1:19 PM PT - May 4th, 2026
❌ @robobun, your commit bc3bd6f has 2 failures in
🧪 To try this PR locally: bunx bun-pr 28606That installs a local version of the PR into your bun-28606 --bun |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughPer-file TypeScript/transpile parse options are now resolved by locating the nearest enclosing Changes
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/bun.js/RuntimeTranspilerStore.zig (1)
378-404: 🧹 Nitpick | 🔵 TrivialAdd one post-startup
import()regression for this path.Both new fixtures use only static imports from the entry module.
Bun__transpileFile()only routes non-main modules throughRuntimeTranspilerStoreaftervm.has_loadedis true, so these tests likely validateModuleLoader.transpileSourceCode()but never executeTranspilerJob.run(). A smallawait import("./packages/ui/component.tsx")case after startup would pin the worker-thread merge too.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/bun.js/RuntimeTranspilerStore.zig` around lines 378 - 404, Tests only use static imports so Bun__transpileFile routes modules before vm.has_loaded and never exercises RuntimeTranspilerStore/TranspilerJob.run; add a post-startup dynamic import to the fixture entry to force runtime transpilation—e.g., after startup await import("./packages/ui/component.tsx")—so Bun__transpileFile will route the module through RuntimeTranspilerStore and exercise ModuleLoader.transpileSourceCode and TranspilerJob.run; update the test fixture entry module (the file that currently only does static imports) to include this single await import line.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@src/bun.js/RuntimeTranspilerStore.zig`:
- Around line 378-404: Tests only use static imports so Bun__transpileFile
routes modules before vm.has_loaded and never exercises
RuntimeTranspilerStore/TranspilerJob.run; add a post-startup dynamic import to
the fixture entry to force runtime transpilation—e.g., after startup await
import("./packages/ui/component.tsx")—so Bun__transpileFile will route the
module through RuntimeTranspilerStore and exercise
ModuleLoader.transpileSourceCode and TranspilerJob.run; update the test fixture
entry module (the file that currently only does static imports) to include this
single await import line.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 2c1dd150-aa3f-4177-aee3-cdf33c38059b
📒 Files selected for processing (3)
src/bun.js/ModuleLoader.zigsrc/bun.js/RuntimeTranspilerStore.zigtest/regression/issue/28605.test.ts
There was a problem hiding this comment.
LGTM — straightforward bug fix that mirrors the bundler's existing per-file tsconfig resolution, with regression tests.
Extended reasoning...
Overview
This PR adds per-file JSX and decorator settings resolution to the runtime transpiler paths (ModuleLoader.zig and RuntimeTranspilerStore.zig). Before each file is transpiled, it now calls readDirInfo on the file's directory, finds the nearest enclosing tsconfig.json, and merges its JSX/decorator settings using the same mergeJSX + boolean-OR pattern the bundler already uses in finalizeResult. Two regression tests in test/regression/issue/28605.test.ts cover the no-root-tsconfig and nested-override scenarios.
Security risks
None. This change only affects compile-time transpilation settings (JSX transform mode and decorator flags). No user-controlled data flows into security-sensitive paths.
Level of scrutiny
Low. The code change is small (~15 lines duplicated in two symmetric locations), follows a well-established pattern already present in the resolver, and the DirInfo cache means the extra readDirInfo call is effectively free.
Other factors
The only noted concern — decorator boolean-OR preventing a nested tsconfig from disabling root-enabled decorators — is a pre-existing limitation that predates this PR and matches the bundler's long-standing behavior. Fixing it properly would require a broader TSConfigJSON data-model change. The PR improves the important case (nested enables what root omits) without regressing the edge case.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@test/regression/issue/28605.test.ts`:
- Around line 64-122: The dynamic import in entry.ts currently re-imports the
same module (packages/ui/component.tsx) so Bun may return a cached transpiled
module and not exercise the RuntimeTranspilerStore path; create a new TSX module
(e.g., packages/ui/dynamic-component.tsx) exporting Component (same
implementation as packages/ui/component.tsx) and update entry.ts to dynamically
import "./packages/ui/dynamic-component.tsx" for the post-startup import so the
dynamic path transpires a distinct file.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 38687bf6-f840-4adb-b22e-f2fce02507d3
📒 Files selected for processing (1)
test/regression/issue/28605.test.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@test/regression/issue/28605.test.ts`:
- Around line 31-35: The test only covers merging of JSX-related tsconfig fields
(jsx and jsxImportSource) but not the decorator branch; update the test to also
exercise merging of experimentalDecorators and emitDecoratorMetadata by adding a
nested tsconfig fixture that sets those two flags (similar to the existing
nested tsconfig JSON snippet with jsx) or alternatively refactor the runtime
merge logic out so the decorator-path is tested separately; ensure the new
nested tsconfig uses experimentalDecorators: true and emitDecoratorMetadata:
true and update the corresponding assertion block (the other similar JSON
snippet later in the test) so both branches are validated.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 1318da5c-d613-4813-b681-596a5815e38e
📒 Files selected for processing (1)
test/regression/issue/28605.test.ts
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/bun.js/ModuleLoader.zig`:
- Around line 226-239: The current code seeds
jsx/emit_decorator_metadata/experimental_decorators from
jsc_vm.transpiler.options (e.g., jsc_vm.transpiler.options.jsx) which lets the
root tsconfig leak into nested files; change the initialization to use default
values (or only explicit process-wide overrides) instead of
jsc_vm.transpiler.options, then apply the enclosing tsconfig merge
(tsconfig.mergeJSX and the
tsconfig.emit_decorator_metadata/tsconfig.experimental_decorators) so that an
enclosing tsconfig can only set or clear fields relative to fresh defaults; make
the identical change in the twin block in RuntimeTranspilerStore.zig to ensure
consistent nearest-enclosing precedence.
In `@src/bun.js/RuntimeTranspilerStore.zig`:
- Around line 378-391: The tsconfig lookup inside RuntimeTranspilerStore's async
job hot path (the block calling transpiler.resolver.readDirInfo and reading
dir_info.enclosing_tsconfig_json to mergeJSX and set
emit_decorator_metadata/experimental_decorators) is causing resolver mutex
contention; move that lookup out of the worker-thread transpile job by resolving
and stashing the enclosing tsconfig during module resolution (where the resolver
already runs), compute the derived JSX and decorator booleans there (using
tsconfig.mergeJSX, tsconfig.emit_decorator_metadata,
tsconfig.experimental_decorators), and pass those derived values into the async
transpile job interface instead of calling readDirInfo from inside
RuntimeTranspilerStore.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 62083a18-35c2-4a66-b6e1-db103182154c
📒 Files selected for processing (2)
src/bun.js/ModuleLoader.zigsrc/bun.js/RuntimeTranspilerStore.zig
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/bun.js/RuntimeTranspilerCache.zig (1)
1-18:⚠️ Potential issue | 🟡 MinorAdd a Version 19 ledger entry above
expected_version.Line 18 bumps the format version, but the in-file version history still stops at Version 18. Please add a Version 19 note so stale-cache investigations stay traceable.
🧾 Suggested patch
/// Version 18: Include ESM record (module info) with an ES Module, see `#15758` +/// Version 19: Include JSX runtime in runtime-transpiler feature hashing (per-file JSX runtime cache separation). const expected_version = 19;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/bun.js/RuntimeTranspilerCache.zig` around lines 1 - 18, Add a "Version 19" ledger entry immediately above the expected_version constant in RuntimeTranspilerCache.zig to match the bumped format number; update the comment block that lists previous versions (the multiline history above expected_version) to include a new line beginning with "Version 19:" and a short note describing the change that caused the bump so the in-file history stays in sync with the expected_version symbol.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@src/bun.js/RuntimeTranspilerCache.zig`:
- Around line 1-18: Add a "Version 19" ledger entry immediately above the
expected_version constant in RuntimeTranspilerCache.zig to match the bumped
format number; update the comment block that lists previous versions (the
multiline history above expected_version) to include a new line beginning with
"Version 19:" and a short note describing the change that caused the bump so the
in-file history stays in sync with the expected_version symbol.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: d24a94a7-4995-4ec8-a6d8-093df5b96931
📒 Files selected for processing (4)
src/bun.js/ModuleLoader.zigsrc/bun.js/RuntimeTranspilerCache.zigsrc/bun.js/RuntimeTranspilerStore.zigsrc/options.zig
There was a problem hiding this comment.
LGTM — all reported issues have been addressed.
Extended reasoning...
Overview
PR fixes issue #28605: runtime transpiler (ModuleLoader.zig, RuntimeTranspilerStore.zig) now resolves per-file JSX/decorator settings from the nearest enclosing tsconfig.json, matching the bundler's existing finalizeResult behavior. Changes touch RuntimeTranspilerCache.zig (version bump 18→19) and options.zig (hash improvements).
Security risks
No security-sensitive code paths (auth, crypto, permissions) are touched. The readDirInfo call acquires the resolver mutex but only performs a cached hash-map lookup. No injection vectors introduced.
Level of scrutiny
High — this is production-critical transpilation code. The PR went through multiple fix iterations:
- Accidental revert of the core fix was caught and restored
- Empty-path crash for worker/blob scripts (bun.assertf panic that catch null cannot intercept) was caught and fixed with the path.name.dir.len > 0 guard
- Production mode JSX corruption (mergeJSX overwriting development=false with true) was caught and fixed with the force_node_env correction
- Cache hash collisions (missing runtime and development fields) were caught and both fields were added
All four issues have been addressed in dccddaf and 413117b. The fix correctly mirrors the bundler path in resolver.zig:finalizeResult.
Other factors
Two regression tests cover both the static import path (ModuleLoader.zig) and the dynamic import path (RuntimeTranspilerStore.zig) with distinct files to avoid module cache interference. CI retriggers appear to be infrastructure-related (TLS certificate issue per commit f396fa2 message), not code failures. All inline reviewer comments are resolved.
38e5744 to
63e9e2b
Compare
63e9e2b to
8b4b466
Compare
There was a problem hiding this comment.
No new issues found — all prior feedback has been addressed in 8b4b466. Deferring to human review since this modifies the runtime transpilation hot path (every bun run file load) and went through several correctness iterations; worth a maintainer sanity-check on the final shape before merge.
Extended reasoning...
Overview
This PR makes the runtime transpiler (ModuleLoader.zig sync path and RuntimeTranspilerStore.zig async path) resolve per-file JSX/decorator settings from the nearest enclosing tsconfig.json via readDirInfo + mergeJSX, mirroring the bundler's existing finalizeResult behavior. It also adds runtime and development to Pragma.hashForRuntimeTranspiler and bumps the transpiler cache version to 21. A regression test covers both the static and dynamic import paths.
Security risks
None. The change reads already-cached resolver DirInfo for absolute filesystem paths only (guarded by std.fs.path.isAbsolute), and merges config into local parse options. No new I/O surface, no untrusted input handling.
Level of scrutiny
High. This sits on the hot path of bun run for every transpiled file and interacts with the on-disk RuntimeTranspilerCache. The PR's review history surfaced and fixed several non-obvious issues: an accidental full revert, a hard-panic on non-absolute path.name.dir (40+ CI failures), a NODE_ENV=production → jsxDEV regression, a cache-hash collision on runtime/development, and a too-weak guard for plugin virtual modules. All are now resolved and the current diff looks correct, but the number of iterations suggests a maintainer should confirm the final shape — particularly the force_node_env correction semantics and the resolver-mutex acquisition from the worker thread.
Other factors
- All prior inline review threads (mine and CodeRabbit's) are resolved.
- The implementation now exactly mirrors
resolver.zigfinalizeResult+ thebundle_v2.zigforce_node_envcorrection, which is the right reference. - Two known pre-existing limitations (decorator
orsemantics,package_namenot merged bymergeJSX) were discussed and correctly deferred as out-of-scope bundler-parity gaps. - CI build #46936 on 8b4b466 was still in progress at review time.
There was a problem hiding this comment.
All prior feedback has been addressed and the dedupe into perFileFeatures is clean, but this changes the per-file transpile path that runs for every module load — worth a maintainer's eyes before merging.
Extended reasoning...
Overview
This PR makes the runtime transpiler (ModuleLoader.zig sync path and RuntimeTranspilerStore.zig async path) resolve JSX/decorator settings from the nearest enclosing tsconfig.json per file, instead of using only the root config. The lookup is centralized in a new Transpiler.perFileFeatures() helper in transpiler.zig. Supporting changes: JSX.Pragma.hashForRuntimeTranspiler now includes runtime and development so per-file JSX differences don't collide in the on-disk cache, and the cache version is bumped 20→21. Two regression tests cover the workspace-root and nested-override scenarios.
Security risks
None. The change reads already-cached DirInfo via the resolver (guarded by path.isFile() and std.fs.path.isAbsolute(path.name.dir)) and merges tsconfig fields into parse options. No new I/O surface, no untrusted-input parsing, no auth/crypto.
Level of scrutiny
High. transpileSourceCode and the RuntimeTranspilerStore job run for every module loaded at runtime, and this PR inserts a resolver call and rewrites three ParseOptions fields on that path. The iteration history bears this out — earlier revisions hit a 40+-test panic from readDirInfo(""), a NODE_ENV/development override regression, a cache-key collision on runtime, and an accidental full revert of the Zig changes. All of those are now fixed (the final guard uses std.fs.path.isAbsolute, force_node_env is reapplied after mergeJSX, the hash includes runtime+development, and the cache version is bumped), but the blast radius of a mistake here is every bun run invocation.
Other factors
- All inline review threads (mine and CodeRabbit's) are resolved; the latest commit 93bbe56 only adjusted test assertion ordering.
- Two known pre-existing limitations were explicitly scoped out as bundler-parity (decorator
orsemantics,mergeJSXnot propagatingpackage_name); those are reasonable to leave for follow-up. - The change is small and well-factored now, but it's a behavior change in a hot, correctness-critical path — not a mechanical/config tweak. A human maintainer should confirm the
perFileFeaturesplacement and theforce_node_envpost-merge override match intended semantics forbun run/bun test.
… runtime Fixes #28605 Runtime transpilation (bun run) was using global JSX settings derived from the root directory's tsconfig.json for all files. When a source file had a closer tsconfig.json with a different jsxImportSource, it was ignored. Look up the enclosing tsconfig.json for each file's directory during runtime transpilation in ModuleLoader and RuntimeTranspilerStore, matching the behavior already used by the bundler path via finalizeResult. Hardening: - Guard readDirInfo against empty paths (prevents crash with worker blobs/eval) - Preserve NODE_ENV=production jsx.development flag after mergeJSX (matches bundle_v2.zig pattern) - Include JSX runtime + development flag in hashForRuntimeTranspiler and bump cache version to prevent cross-config cache collisions
eacf2ee to
bc3bd6f
Compare
There was a problem hiding this comment.
All prior review feedback has been addressed and no new issues were found, but this touches the runtime module loader hot path (per-file resolver lookup on every transpile) and went through several correctness iterations, so it's worth a human sign-off.
Extended reasoning...
Overview
This PR makes the runtime transpiler (bun run) resolve JSX and decorator settings from the nearest enclosing tsconfig.json per file, instead of using only the root config. It adds Transpiler.perFileFeatures() in src/bundler/transpiler.zig, calls it from both ModuleLoader.zig (sync path) and RuntimeTranspilerStore.zig (async worker path), adds runtime and development to JSX.Pragma.hashForRuntimeTranspiler, bumps the runtime transpiler cache version 20→21, and adds two regression tests.
Security risks
None identified. The change reads tsconfig.json files via the existing resolver readDirInfo cache (already used by the bundler), guarded by path.isFile() and std.fs.path.isAbsolute(path.name.dir). No new untrusted-input parsing, no auth/crypto/permissions surface.
Level of scrutiny
High. ModuleLoader.transpileSourceCode and RuntimeTranspilerStore are the core hot path for every module loaded by bun run. The review history bears this out — earlier revisions introduced (and subsequently fixed) an assert-panic on worker/blob/virtual-module specifiers, a NODE_ENV=production regression where mergeJSX clobbered development=false, and a cache-key collision on JSX runtime. All of those are now resolved in the current diff (the isAbsolute guard, the force_node_env switch, and the hash/version bump respectively), and the logic now lives in a single deduped helper rather than two copies.
Other factors
All inline review threads are resolved and the bug-hunting pass on the current revision found nothing. The 3 CI failures reported by robobun (webview-chrome, bun-types ASAN exception, bun-install SIGILL) are unrelated to the changed files. The implementation mirrors the bundler's existing finalizeResult semantics at resolver.zig:1001-1005, which limits the design risk. Still, given the criticality of the module loader path and the number of subtle issues caught during iteration, I'd prefer a human reviewer give the final approval rather than auto-approving.
|
Closing: this PR's implementation lives entirely in Zig source files that have since been removed from the tree as part of the Rust migration. The change can no longer merge cleanly and the files it edits no longer exist on If the underlying issue is still present, it will need a fresh fix against the Rust implementation. |
Fixes #28605
Problem
When running
bun run ./services/connect/src/app.tsfrom a workspace root that has notsconfig.json, Bun ignoredjsxImportSource: "chat"from the nestedservices/connect/tsconfig.jsonand fell back to the defaultreact, causing:Cause
Runtime transpilation in
ModuleLoader.zigandRuntimeTranspilerStore.zigalways used the globaltranspiler.options.jsxsettings — derived once at startup from the root directory's tsconfig.json — for every file. The per-file tsconfig resolution viaenclosing_tsconfig_json(which walks up from the file's directory) was only used in the bundler code path, not the runtimebun runpath.Fix
Before transpiling each file at runtime, look up its directory's
DirInfoviareadDirInfoand merge theenclosing_tsconfig_json's JSX/decorator settings, matching the behavior the bundler already uses infinalizeResult.Verification
USE_SYSTEM_BUN=1 bun test test/regression/issue/28605.test.ts→ 2 fail (bug exists)bun bd test test/regression/issue/28605.test.ts→ 2 pass (fix works)chat/jsx-dev-runtime