Skip to content

fix(transform): reuse TsconfigCache's answer when no tsconfig owns the file - #11265

Merged
sapphi-red merged 4 commits into
rolldown:mainfrom
sarankumar1325:fix/tsconfig-cache-none
Nov 6, 2026
Merged

sapphi-red merged 4 commits into
rolldown:mainfrom
sarankumar1325:fix/tsconfig-cache-none

Conversation

@sarankumar1325

Copy link
Copy Markdown
Contributor

Fixes the TsconfigCache part of #11264.

What

When transform/transformSync gets a TsconfigCache and the cache's resolver finds that no tsconfig owns the file (Ok(None)), resolve_tsconfig_from_cache left options.tsconfig on auto. enhanced_transform then built a new oxc_resolver::Resolver with 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 .svg files compiled to JSX). It also meant a broken tsconfig in an unrelated project made those transforms fail.

Change

resolve_tsconfig_from_cache now treats the cache's Ok(None) as final and sets TsconfigOption::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 as tsconfig), found no tsconfig either, and reported no tsconfigFilePaths.

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

  • New test in packages/rolldown/tests/utils/transform.test.ts: a solution root whose two projects only include .ts files, a .svg file transformed with lang: 'jsx' and a shared TsconfigCache, then the unrelated project's tsconfig.json is overwritten with invalid JSON. On main the second transform fails with [TSCONFIG_ERROR]. With this change it succeeds with the same output.
  • The issue's repro (351 references, debug build, ms per call): shared TsconfigCache goes from 19.6 on main to 0.22 with this change. default (no cache) stays about 19, and tsconfig: false stays 0.21.
  • packages/rolldown/tests test:main: 1356 passed. The 5 dev/* files fail to load locally because @rolldown/test-dev-server isn't built in my environment. They aren't related to this change.
  • cargo fmt --check, cargo clippy -p rolldown_binding, vp fmt --check and vp lint are 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.

sapphi-red pushed a commit that referenced this pull request Oct 29, 2026
…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.
@hyfdev hyfdev self-assigned this Nov 6, 2026
@hyfdev
hyfdev marked this pull request as ready for review November 6, 2026 04:34
Copilot AI balanced review requested due to automatic review settings November 6, 2026 04:34
@netlify

netlify Bot commented Nov 6, 2026

Copy link
Copy Markdown

✅ Deploy Preview for rolldown-rs ready!

Name Link
🔨 Latest commit e5c60cb
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/6aed58e88218f6de1940d67d
😎 Deploy Preview https://deploy-preview-11265--rolldown-rs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

@codspeed

codspeed Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ 4 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 7 untouched benchmarks
⏩ 10 skipped benchmarks1


Comparing sarankumar1325:fix/tsconfig-cache-none (83f5cc7) with main (3ad9d79)2

Open in CodSpeed

Footnotes

  1. 10 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on main (b61d96c) during the generation of this report, so 3ad9d79 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@hyfdev hyfdev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@sapphi-red
sapphi-red merged commit 6e233b5 into rolldown:main Nov 6, 2026
32 checks passed
This was referenced Nov 9, 2026
shulaoda added a commit that referenced this pull request Nov 9, 2026
## [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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: transformSync re-runs tsconfig discovery on every call for a file no tsconfig owns, bypassing TsconfigCache (perf regression since 1.1.2)

4 participants