Skip to content

refactor: unify tsconfig discovery to share resolver cache#8413

Closed
Brooooooklyn wants to merge 1 commit intomainfrom
perf/unify-tsconfig-discovery
Closed

refactor: unify tsconfig discovery to share resolver cache#8413
Brooooooklyn wants to merge 1 commit intomainfrom
perf/unify-tsconfig-discovery

Conversation

@Brooooooklyn
Copy link
Member

@Brooooooklyn Brooooooklyn commented Feb 22, 2026

Replace RawTransformOptions' private oxc_resolver::Resolver with a
TsconfigFinder trait object backed by the main bundler resolver.
This eliminates a redundant resolver instance and shares the
find_tsconfig cache between module resolution and transformation,
avoiding duplicate directory walks when auto-discovering tsconfig.json.

The performance benefit depends on the project having tsconfig.json
files with auto-discovery enabled (the default). Projects without
tsconfig.json or using explicit tsconfig paths see no measurable
difference.

Verified against in-repo criterion benchmarks (threejs, threejs10x)
and external rolldown-benchmark/apps/10000: no statistically
significant change detected (criterion p > 0.3, hyperfine within
noise). These benchmarks either lack tsconfig.json files or use
explicit manual tsconfig paths, so the shared cache is not exercised.

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com


Note

Medium Risk
Touches tsconfig discovery/caching and how per-file transform options are derived, which can subtly affect builds in projects with multiple/edge-case tsconfig.json layouts. The change is mostly a refactor with the same discovery API, but it alters cache ownership and object lifetimes.

Overview
Refactors transform-phase tsconfig discovery to reuse the main bundler resolver’s cached find_tsconfig results instead of constructing a separate oxc_resolver::Resolver inside RawTransformOptions.

Introduces a TsconfigFinder trait (exported via rolldown_common) implemented by rolldown_resolver::Resolver, updates RawTransformOptions to hold an Arc<dyn TsconfigFinder>, and wires prepare_build_context to pass the shared resolver into TransformOptions::new_raw for TsConfig::Auto and referenced TsConfig::Manual cases.

Written by Cursor Bugbot for commit 154a924. This will update automatically on new commits. Configure here.

Copy link
Member Author

Brooooooklyn commented Feb 22, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


How to use the Graphite Merge Queue

Add the label graphite: merge-when-ready to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions
Copy link
Contributor

Benchmarks Rust

  • target: perf/use-flag-based-convergence-detection(50910e2)
  • pr: perf/unify-tsconfig-discovery(c3238dd)
group                                                        pr                                     target
-----                                                        --                                     ------
bundle/bundle@multi-duplicated-top-level-symbol              1.00     63.6±1.99ms        ? ?/sec    1.09     69.3±1.81ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-sourcemap    1.00     69.3±1.18ms        ? ?/sec    1.08     75.1±1.76ms        ? ?/sec
bundle/bundle@rome_ts                                        1.00     98.8±3.24ms        ? ?/sec    1.00     99.1±3.33ms        ? ?/sec
bundle/bundle@rome_ts-sourcemap                              1.00    109.8±2.62ms        ? ?/sec    1.01    110.4±1.61ms        ? ?/sec
bundle/bundle@threejs                                        1.00     35.3±2.17ms        ? ?/sec    1.00     35.2±1.00ms        ? ?/sec
bundle/bundle@threejs-sourcemap                              1.00     39.6±0.61ms        ? ?/sec    1.01     39.8±0.59ms        ? ?/sec
bundle/bundle@threejs10x                                     1.00    355.8±3.71ms        ? ?/sec    1.01    360.2±5.89ms        ? ?/sec
bundle/bundle@threejs10x-sourcemap                           1.00    412.7±4.17ms        ? ?/sec    1.01    416.4±3.85ms        ? ?/sec
scan/scan@rome_ts                                            1.00     77.6±2.32ms        ? ?/sec    1.01     78.3±2.46ms        ? ?/sec
scan/scan@threejs                                            1.00     27.6±1.75ms        ? ?/sec    1.01     27.7±1.67ms        ? ?/sec
scan/scan@threejs10x                                         1.01    279.4±4.19ms        ? ?/sec    1.00    276.7±3.91ms        ? ?/sec

Copy link
Contributor

Copilot AI commented Feb 22, 2026

@hyf0 I've opened a new pull request, #8414, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Member

hyf0 commented Feb 22, 2026

Merge activity

  • Feb 22, 5:15 AM UTC: The merge label 'graphite: merge-when-ready' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Feb 22, 5:15 AM UTC: hyf0 added this pull request to the Graphite merge queue.
  • Feb 22, 5:27 AM UTC: The Graphite merge queue couldn't merge this PR because it was in draft mode.

Replace RawTransformOptions' private oxc_resolver::Resolver with a
TsconfigFinder trait object backed by the main bundler resolver.
This eliminates a redundant resolver instance and shares the
find_tsconfig cache between module resolution and transformation,
avoiding duplicate directory walks when auto-discovering tsconfig.json.

The performance benefit depends on the project having tsconfig.json
files with auto-discovery enabled (the default). Projects without
tsconfig.json or using explicit tsconfig paths see no measurable
difference.

Verified against in-repo criterion benchmarks (threejs, threejs10x)
and external rolldown-benchmark/apps/10000: no statistically
significant change detected (criterion p > 0.3, hyperfine within
noise). These benchmarks either lack tsconfig.json files or use
explicit manual tsconfig paths, so the shared cache is not exercised.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Touches tsconfig discovery/caching and how per-file transform options are derived, which can subtly affect builds in projects with multiple/edge-case `tsconfig.json` layouts. The change is mostly a refactor with the same discovery API, but it alters cache ownership and object lifetimes.
>
> **Overview**
> Refactors transform-phase tsconfig discovery to reuse the main bundler resolver’s cached `find_tsconfig` results instead of constructing a separate `oxc_resolver::Resolver` inside `RawTransformOptions`.
>
> Introduces a `TsconfigFinder` trait (exported via `rolldown_common`) implemented by `rolldown_resolver::Resolver`, updates `RawTransformOptions` to hold an `Arc<dyn TsconfigFinder>`, and wires `prepare_build_context` to pass the shared resolver into `TransformOptions::new_raw` for `TsConfig::Auto` and referenced `TsConfig::Manual` cases.
>
> <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 154a924. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@graphite-app graphite-app bot force-pushed the perf/use-flag-based-convergence-detection branch from 50910e2 to 26d804e Compare February 22, 2026 05:16
@graphite-app graphite-app bot force-pushed the perf/unify-tsconfig-discovery branch from 154a924 to b0b004f Compare February 22, 2026 05:16
@shulaoda shulaoda assigned shulaoda and unassigned Brooooooklyn Feb 22, 2026
Copy link
Member

@shulaoda shulaoda left a comment

Choose a reason for hiding this comment

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

Seems related to #7581, let me review again

@shulaoda shulaoda marked this pull request as draft February 22, 2026 05:21
Base automatically changed from perf/use-flag-based-convergence-detection to main February 22, 2026 05:26
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.

4 participants