Repository navigation
fix(transform): reuse TsconfigCache's answer when no tsconfig owns the file - #11265
Conversation
…rough `TsconfigCache` (#11346) Fixes #11345. `transform`/`transformSync` with a `TsconfigCache` return `tsconfigFilePaths: []` even when a tsconfig applies to the file. Without a cache, and from `resolveTsconfig` with the same cache, the path is reported. Vite's `transformWithOxc` always passes its cache and watches these paths, so in dev a tsconfig outside the Vite root is never watched. Cause: `resolve_tsconfig_from_cache` hands the cached config to `enhanced_transform` as `TsconfigOption::Config`, and that branch reports no paths. It now reports the config's path. Unchanged: - a raw config object from JS has an empty path and still reports nothing (covered by the existing "should not report tsconfigFilePaths when using raw tsconfig" test); - as without a cache, only the tsconfig itself is reported, not the files it `extends`; - the binding is not touched. Merges cleanly with #11265. Tests in `packages/rolldown/tests/utils/transform.test.ts`, both fail on `main` with `[]`: - auto discovery through a cache: the first call and later `transformSync`/`transform` calls return the same code and paths as without a cache; - explicit `tsconfig` path with `new TsconfigCache(path)`: two calls, both report `[path]`. Both use a class field with the fixture's `useDefineForClassFields: false`, so the output also shows the cached config was applied. Also ran `test:main`, `cargo fmt --check`, `cargo clippy -p rolldown_common -p rolldown_binding`. The field doc ("Paths to tsconfig files that were loaded during transformation") doesn't mention the cache. I left it because the `.d.cts` files are generated; happy to reword it. AI disclosure: I used an AI coding assistant to investigate this and write the fix and tests. I reviewed the change and ran the tests locally.
✅ Deploy Preview for rolldown-rs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the change to avoid repeated tsconfig discovery for files with no owning configuration.
No open issues 🎉
What changed in this PR
Fixes the shared TsconfigCache behavior from #11264 by treating “no tsconfig owns this file” as a final answer, avoiding repeated discovery during transforms. Behavior without a shared cache is unchanged.
Changes:
- Disables further tsconfig discovery when the shared cache returns
Ok(None). - Adds a regression test confirming that an unowned JSX input still transforms successfully after an unrelated tsconfig becomes invalid.
| File | Description |
|---|---|
packages/rolldown/tests/utils/transform.test.ts |
Tests reuse of the cached “no owner” result in a solution-style project. |
crates/rolldown_binding/src/transform.rs |
Prevents fresh discovery after the cache finds no owning tsconfig. |
Review effort: Balanced
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
Co-authored-by: 翠 <[email protected]> Signed-off-by: 翠 <[email protected]>
## [1.3.1] - 2026-11-09 ### 🚀 Features - inline-common-chunks: inline chunks using `import.meta.ROLLDOWN_FILE_URL_*` (#11543) by @mattlewis92 ### 🐛 Bug Fixes - cli: apply --environment before loading the binding (#11553) by @Brooooooklyn - rolldown_plugin_vite_resolve: escape module names in generated error stubs (#11584) by @sapphi-red - add the code location to transform logs and errors at position 0 (#11568) by @chinmayajha - match sticky regexes only at the start of the string (#11569) by @chinmayajha - iife/umd: skip namespace markers when the entry has no exports (#11567) by @lazerg - keep a declaration's name when it clashes with an external import (#11052) by @Nic-Polumeyv - drop top-level statements made dead by imported constants before chunk linking (#11053) by @elliott-with-the-longest-name-on-github - keep `this.resolve` custom options apart for overlapping calls (#11505) by @wan9chi - transform: reuse TsconfigCache's answer when no tsconfig owns the file (#11265) by @sarankumar1325 - treat top-level `this` of a required module without module syntax as its exports (#11271) by @sarankumar1325 - keep side effects of a module whose exported constant is inlined (#11440) by @hyfdev - leave same-chunk dynamic imports out of `dynamicImports` (#11156) by @kkkhs ### 🚜 Refactor - prepend transferred imports as AST fragments (#11464) by @Dunqing ### 📚 Documentation - show `vp` first in setup commands (#11503) by @IWANABETHATGUY ### ⚡ Performance - incremental: reuse link-time facade symbols across rebuilds (#11542) by @mattlewis92 - incremental: share module sourcemap chains across cache clones (#11540) by @mattlewis92 - chunk_optimizer: answer runtime-merge reachability from one chunk-level graph (#11541) by @mattlewis92 - send only changed chunk properties back to Rust from output hooks (#11488) by @anonrig ### 🧪 Testing - remove review fixtures committed by mistake in #11052 (#11574) by @hyfdev - wasi: cover raw context destruction (#11561) by @Brooooooklyn ### ⚙️ Miscellaneous Tasks - deps: update rust crates (#11573) by @renovate[bot] - deps: update mimalloc-safe to 0.1.70 (#11589) by @shulaoda - renovate: update GitHub Actions that are pinned to a commit (#11583) by @hyfdev - skip Playwright browser downloads in Prepare Release (#11579) by @shulaoda - pin the rolldown crates to exact versions of each other on release (#11577) by @shulaoda - update `CodSpeedHQ/action` to v5.6.3 for Ubuntu 26.04 (#11575) by @hyfdev - remove stale entries from `.typos.toml` (#11571) by @iiio2 - pick the Prepare Release target branch from the version (#11525) by @shulaoda - run every OS on pushes to maintenance branches (#11520) by @shulaoda - rebase maintenance Vite branches onto their Vite minor (#11515) by @shulaoda - run CI on pushes to maintenance branches (#11516) by @shulaoda - support patch releases from maintenance branches (#11393) by @shulaoda ### ❤️ New Contributors * @chinmayajha made their first contribution in [#11568](#11568) * @lazerg made their first contribution in [#11567](#11567) * @elliott-with-the-longest-name-on-github made their first contribution in [#11053](#11053) * @sarankumar1325 made their first contribution in [#11265](#11265) * @anonrig made their first contribution in [#11488](#11488) * @kkkhs made their first contribution in [#11156](#11156) Co-authored-by: shulaoda <[email protected]>
Fixes the
TsconfigCachepart of #11264.What
When
transform/transformSyncgets aTsconfigCacheand the cache's resolver finds that no tsconfig owns the file (Ok(None)),resolve_tsconfig_from_cacheleftoptions.tsconfigon auto.enhanced_transformthen built a newoxc_resolver::Resolverwith an empty cache and discovered again on every call. In a solution-style monorepo this re-reads the root tsconfig and every referenced tsconfig per call, so the shared cache stopped helping for files no project owns (for example.svgfiles compiled to JSX). It also meant a broken tsconfig in an unrelated project made those transforms fail.Change
resolve_tsconfig_from_cachenow treats the cache'sOk(None)as final and setsTsconfigOption::Disabled. The cache's resolver already memoises that answer, so later calls don't touch the reference set. The result is the same as before: the rediscovery used the same discovery mode (the docs ask callers to build the cache with the same path they pass astsconfig), found no tsconfig either, and reported notsconfigFilePaths.This PR doesn't change the default path without a cache (item 2 in the issue's suggestions). That needs a decision about a process-wide cache and its invalidation, so I left it out.
Tests
packages/rolldown/tests/utils/transform.test.ts: a solution root whose two projects only include.tsfiles, a.svgfile transformed withlang: 'jsx'and a sharedTsconfigCache, then the unrelated project'stsconfig.jsonis overwritten with invalid JSON. Onmainthe second transform fails with[TSCONFIG_ERROR]. With this change it succeeds with the same output.TsconfigCachegoes from 19.6 onmainto 0.22 with this change.default(no cache) stays about 19, andtsconfig: falsestays 0.21.packages/rolldown/teststest:main: 1356 passed. The 5dev/*files fail to load locally because@rolldown/test-dev-serverisn't built in my environment. They aren't related to this change.cargo fmt --check,cargo clippy -p rolldown_binding,vp fmt --checkandvp lintare clean.AI disclosure: I used an AI coding assistant to investigate this and write the fix and the test. I reviewed the change and ran the tests locally.