Skip to content

Comments

feat!: support top-level tsconfig#5842

Merged
hyf0 merged 1 commit intomainfrom
08-22-feat_support_resolve.tsconfig
Aug 24, 2025
Merged

feat!: support top-level tsconfig#5842
hyf0 merged 1 commit intomainfrom
08-22-feat_support_resolve.tsconfig

Conversation

@shulaoda
Copy link
Member

@shulaoda shulaoda commented Aug 22, 2025

Related to #5839

Copy link
Member Author

shulaoda commented Aug 22, 2025

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

@shulaoda shulaoda changed the title feat: support resolve.tsconfig feat: support resolve.tsconfig Aug 22, 2025
@shulaoda shulaoda marked this pull request as ready for review August 22, 2025 06:27
@netlify
Copy link

netlify bot commented Aug 22, 2025

Deploy Preview for rolldown-rs ready!

Name Link
🔨 Latest commit d30ccc3
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/68a8cda6d02d490008a7e9bd
😎 Deploy Preview https://deploy-preview-5842--rolldown-rs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@github-actions
Copy link
Contributor

github-actions bot commented Aug 22, 2025

Benchmarks Rust

  • target: main(47223b8)
  • pr: 08-22-feat_support_resolve.tsconfig(d30ccc3)
group                                                        pr                                     target
-----                                                        --                                     ------
bundle/bundle@multi-duplicated-top-level-symbol              1.00     77.0±1.41ms        ? ?/sec    1.01     78.0±1.66ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-sourcemap    1.00     86.5±1.53ms        ? ?/sec    1.01     87.4±1.76ms        ? ?/sec
bundle/bundle@rome_ts                                        1.00    119.0±1.96ms        ? ?/sec    1.00    119.4±2.06ms        ? ?/sec
bundle/bundle@rome_ts-sourcemap                              1.00    138.8±1.30ms        ? ?/sec    1.00    139.4±1.67ms        ? ?/sec
bundle/bundle@threejs                                        1.00     42.9±1.01ms        ? ?/sec    1.02     43.7±0.90ms        ? ?/sec
bundle/bundle@threejs-sourcemap                              1.02     53.5±2.87ms        ? ?/sec    1.00     52.5±0.88ms        ? ?/sec
bundle/bundle@threejs10x                                     1.00    463.0±5.01ms        ? ?/sec    1.01    469.3±4.95ms        ? ?/sec
bundle/bundle@threejs10x-sourcemap                           1.00    545.5±4.17ms        ? ?/sec    1.00    547.9±5.49ms        ? ?/sec
scan/scan@rome_ts                                            1.01     95.7±1.30ms        ? ?/sec    1.00     94.6±2.20ms        ? ?/sec
scan/scan@threejs                                            1.00     33.1±2.01ms        ? ?/sec    1.00     33.2±2.05ms        ? ?/sec
scan/scan@threejs10x                                         1.00    350.6±3.86ms        ? ?/sec    1.00    350.2±4.38ms        ? ?/sec

@sapphi-red
Copy link
Member

sapphi-red commented Aug 22, 2025

  • What is the motivation of this change? Is it to allow specifying oxc_resolver::TsconfigReferences in the option? Why is it better to allow specifying that in the option, over just using the values written in tsconfig.json?
  • Wouldn't this require loading the tsconfig options for each file like the current transform plugin does? Do you plan to fix that in a separate PR?
  • Do you plan to rename the option to the top-level tsconfig option in a separate PR?

@shulaoda
Copy link
Member Author

  • What is the motivation of this change? Is it to allow specifying oxc_resolver::TsconfigReferences in the option? Why is it better to allow specifying that in the option, over just using the values written in tsconfig.json?

We parse the tsconfig through oxc-resolver, so we need to support the full resolve.tsconfig configuration option. See https://github.com/rolldown/rolldown/blob/2af8a415/crates/rolldown_resolver/src/resolver.rs#L265-L267

@shulaoda
Copy link
Member Author

  • Wouldn't this require loading the tsconfig options for each file like the current transform plugin does? Do you plan to fix that in a separate PR?

Unlike the transform plugin, Rolldown only respects the user-configured resolve.tsconfig and will load it only once by default.

@shulaoda
Copy link
Member Author

  • Do you plan to rename the option to the top-level tsconfig option in a separate PR?

We don't plan to do that for now because we load it using oxc-resolver, and it should be configured through resolve.tsconfig.

@sapphi-red
Copy link
Member

  • What is the motivation of this change? Is it to allow specifying oxc_resolver::TsconfigReferences in the option? Why is it better to allow specifying that in the option, over just using the values written in tsconfig.json?

We parse the tsconfig through oxc-resolver, so we need to support the full resolve.tsconfig configuration option. See https://github.com/rolldown/rolldown/blob/2af8a415/crates/rolldown_resolver/src/resolver.rs#L265-L267

Why do we need to? We can also change the behavior of oxc-resolver if there's a better approach. I want to know the fundamental motivation.

@sapphi-red
Copy link
Member

  • Wouldn't this require loading the tsconfig options for each file like the current transform plugin does? Do you plan to fix that in a separate PR?

Unlike the transform plugin, Rolldown only respects the user-configured resolve.tsconfig and will load it only once by default.

Yes, that's the current behavior. This PR adds support for loading tsconfig references. That requires applying a different configuration for each module. For example, paths can have different values for each file like:

  • tsconfig.json: has "references": ["./foo/tsconfig.json", "./bar/tsconfig.json"]
  • foo/tsconfig.json: "paths": { "@/": "./a" }
  • bar/tsconfig.json: "paths": { "@/": "./b" }

Files under foo would use foo/tsconfig.json and files under bar would use bar/tsconfig.json. The same should apply to the transform options as well. But unless we make the builtin transform to work like the transform plugin, the behavior will be inconsistent and would be confusing.

@shulaoda
Copy link
Member Author

We parse the tsconfig through oxc-resolver, so we need to support the full resolve.tsconfig configuration option. See https://github.com/rolldown/rolldown/blob/2af8a415/crates/rolldown_resolver/src/resolver.rs#L265-L267

Why do we need to? We can also change the behavior of oxc-resolver if there's a better approach. I want to know the fundamental motivation.

Alright, I made a mistake. I checked the resolve_tsconfig code, and it defaults to TsconfigReferences::Auto. So this setting only affects the resolver’s behavior. Previously, we defaulted the resolver’s references to TsconfigReferences::Disabled — should we change that?

@shulaoda
Copy link
Member Author

Unlike the transform plugin, Rolldown only respects the user-configured resolve.tsconfig and will load it only once by default.

Yes, that's the current behavior. This PR adds support for loading tsconfig references. That requires applying a different configuration for each module. For example, paths can have different values for each file like:

  • tsconfig.json: has "references": ["./foo/tsconfig.json", "./bar/tsconfig.json"]
  • foo/tsconfig.json: "paths": { "@/": "./a" }
  • bar/tsconfig.json: "paths": { "@/": "./b" }

Files under foo would use foo/tsconfig.json and files under bar would use bar/tsconfig.json. The same should apply to the transform options as well. But unless we make the builtin transform to work like the transform plugin, the behavior will be inconsistent and would be confusing.

Let me take a look at how esbuild handles this.

@shulaoda shulaoda marked this pull request as draft August 22, 2025 07:39
@sapphi-red
Copy link
Member

We parse the tsconfig through oxc-resolver, so we need to support the full resolve.tsconfig configuration option. See https://github.com/rolldown/rolldown/blob/2af8a415/crates/rolldown_resolver/src/resolver.rs#L265-L267

Why do we need to? We can also change the behavior of oxc-resolver if there's a better approach. I want to know the fundamental motivation.

Alright, I made a mistake. I checked the resolve_tsconfig code, and it defaults to TsconfigReferences::Auto. So this setting only affects the resolver’s behavior. Previously, we defaulted the resolver’s references to TsconfigReferences::Disabled — should we change that?

I think we can leave it as TsconfigReferences::Disabled for now. It should have a consistent behavior with the transform option (#5842 (comment)) and would require more changes.

@shulaoda shulaoda force-pushed the 08-22-feat_support_resolve.tsconfig branch 2 times, most recently from df58838 to 581cb0e Compare August 22, 2025 17:58
@shulaoda shulaoda changed the title feat: support resolve.tsconfig feat: support top-level tsconfig Aug 22, 2025
@shulaoda shulaoda marked this pull request as ready for review August 22, 2025 17:58
Comment on lines +385 to +386
* When a tsconfig path is specified, the module resolver will respect `compilerOptions.paths` from the specified `tsconfig.json`,
* and the tsconfig options will be merged with the top-level `transform` options, with the `transform` options taking precedence.
Copy link
Member Author

Choose a reason for hiding this comment

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

I will fix the current tsconfig merge problems in the next PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

See #5882

@shulaoda shulaoda force-pushed the 08-22-feat_support_resolve.tsconfig branch from 7e60515 to 53a630d Compare August 22, 2025 18:01
@shulaoda shulaoda force-pushed the 08-22-feat_support_resolve.tsconfig branch from 53a630d to d30ccc3 Compare August 22, 2025 20:05
@sapphi-red sapphi-red changed the title feat: support top-level tsconfig feat!: support top-level tsconfig Aug 23, 2025
@hyf0 hyf0 enabled auto-merge August 24, 2025 11:25
@hyf0 hyf0 added this pull request to the merge queue Aug 24, 2025
Merged via the queue into main with commit 481e761 Aug 24, 2025
24 checks passed
@hyf0 hyf0 deleted the 08-22-feat_support_resolve.tsconfig branch August 24, 2025 16:47
shulaoda added a commit that referenced this pull request Aug 25, 2025
## [1.0.0-beta.34] - 2025-08-25

### 💥 BREAKING CHANGES

- improve merging of top-level `transform` option with `tsconfig` (#5882) by @shulaoda
- support top-level `tsconfig` (#5842) by @shulaoda

### 🚀 Features

- rolldown_plugin_esm_external_require: export namespace directly for Node builtin modules (#5885) by @shulaoda
- rolldown_plugin_dynamic_import_vars: warn by default when errors occur (#5866) by @shulaoda
- support adding note for diagnostic (#5864) by @IWANABETHATGUY
- rolldown_plugin_vite_css_post: align partial css chunk logic (#5861) by @shulaoda
- setup `rolldown_binding_watcher` (#5859) by @hyf0
- rolldown_plugin_vite_css_post: align css url replace logic (#5857) by @shulaoda
- node/dev: binding for `DevEngine` (#5852) by @hyf0
- dev: introduce `DevEngine` to support build for devlopement scenario (#5808) by @hyf0
- Show a information log to tell built-in features if a plugin covered by built-in features are used (#5845) by @IWANABETHATGUY
- rolldown_plugin_vite_css_post: align partial css url replace logic (#5837) by @shulaoda
- rolldown_plugin_vite_css_post: align CSS chunk concatenation logic (#5836) by @shulaoda
- rolldown_plugin_transform: support `useDefineForClassFields=false` with `target>=es2022` (#5841) by @sapphi-red
- expose `esmExternalRequirePlugin` (#5810) by @shulaoda
- rolldown_plugin_esm_external_require: basic implementation (#5809) by @shulaoda
- rolldown: oxc v0.82.3 (#5807) by @Boshen
- expose `oxc_minifier` options (#5804) by @IWANABETHATGUY
- rolldown_plugin_require_to_import: initialize (#5797) by @shulaoda
- adjust codegen `initial_indent` for concatenateWrappedModule (#5779) by @IWANABETHATGUY
- rolldown: align default value of `option.context` (#5745) by @situ2001

### 🐛 Bug Fixes

- topLevelVar option removes class name, causing a TypeError in static block (#5888) by @IWANABETHATGUY
- a esm module required by other module can't be a inner module of concatenateModuleGroup (#5875) by @IWANABETHATGUY
- rolldown_plugin_transform: align `lang` logic correctly (#5874) by @shulaoda
- Runtime error occurs depending on the lazy import order. (#5873) by @IWANABETHATGUY
- when importee is ts or tsx adding potential false positive note for `missing_export` diagnostic (#5862) by @IWANABETHATGUY
- hmr: boundary and accept_via was reversed (#5843) by @sapphi-red
- returning result of this.resolve in resolveId hook impacts bundle size (#5851) by @IWANABETHATGUY
- rolldown_plugin_transform: set `typescript.removeClassFieldsWithoutInitializer` for `useDefineForClassFields=false` (#5840) by @sapphi-red
- hmr: `import.meta.hot.accept` in patch file should work (#5823) by @sapphi-red
- proper handle pife and profiler_names for concatenate_wrapped_modules (#5835) by @IWANABETHATGUY
- jsx preserve break component which is default export (#5751) by @shulaoda
- hmr: ensure patch file name to be unique (#5825) by @sapphi-red
- hmr: re-execute the boundary module rather than the accepted module (#5822) by @sapphi-red
- Rolldown cannot treeshake unused branch (#5829) by @IWANABETHATGUY
- `inlineConst` with constant propagation (#5826) by @IWANABETHATGUY
- don't mangle variable names when `minify: 'dce-only'` is used (#5830) by @sapphi-red
- return actual normalized minify options (#5818) by @IWANABETHATGUY
- plugin/vite-resolve: try non-prefixed index before prefixed index (#5801) by @sapphi-red
- throw a semantic error message instead of panic (#5796) by @AliceLanniste
- rolldown: run DCE on chunk when `minify: dce-only` (#5792) by @Boshen
- the import attribute has been removed. (#5794) by @IWANABETHATGUY
- don't match CRLF for `/./` (#5790) by @IWANABETHATGUY
- node: allow `output.topLevelVar` by options validator (#5789) by @sapphi-red
- node: allow `transform.jsx: 'preserve'` by options validator (#5781) by @sapphi-red
- preserve default export for `preserveModules` (#5780) by @shulaoda
- browser: sync exports (#5776) by @sxzz
- rolldown_plugin_transform: skip builtin transform for module id with null byte (#5775) by @hi-ogawa

### 🚜 Refactor

- move common transform types into rolldown_common (#5876) by @shulaoda
- rolldown_plugin_vite_css_post: extract `finalize_vite_css_urls` (#5860) by @shulaoda
- rust: make `NotifyWatcher` WASM-compatible (#5855) by @hyf0
- rust/dev: remove improper deref for `BuildDriver` (#5854) by @hyf0
- incremental: use `clone_in_with_semantic_ids` for program cloning (#5853) by @shulaoda
- rolldown_plugin_esm_external_require: tweak code (#5824) by @shulaoda
- improve `resolve_dependencies` (#5795) by @shulaoda
- simplify method calls in `PluginContext` (#5785) by @situ2001

### 📚 Documentation

- builtin-plugins: clarify behavior of `esmExternalRequirePlugin` (#5886) by @sapphi-red
- builtin-plugins: add documentation for `esmExternalRequirePlugin` (#5813) by @shulaoda
- support extracting doc for reference type (#5834) by @IWANABETHATGUY
- optimization.inlineConst (#5831) by @IWANABETHATGUY
- update description for output.minify (#5816) by @IWANABETHATGUY
- plugins: extract plugins into a separate section (#5812) by @shulaoda

### ⚡ Performance

- string_wizard: reduce allocation (#5793) by @Brooooooklyn

### 🧪 Testing

- hmr: import.meta.hot.accept cases (#5821) by @sapphi-red
- hmr: static import cases (#5820) by @sapphi-red
- hmr: no boundary full reload case (#5819) by @sapphi-red

### ⚙️ Miscellaneous Tasks

- deps: update `oxc-resolver` to v11.7.0 (#5889) by @shulaoda
- deps: lock file maintenance (#5880) by @renovate[bot]
- deps: lock file maintenance rust crates (#5881) by @renovate[bot]
- deps: update github-actions (#5877) by @renovate[bot]
- deps: lock file maintenance rust crates (#5879) by @renovate[bot]
- deps: lock file maintenance npm packages (#5878) by @renovate[bot]
- bump rolldown-ariadne (#5863) by @IWANABETHATGUY
- remove usage of `quote_expr`, `quote_stmt` (#5858) by @IWANABETHATGUY
- vite-tests: run all test suites even if some test suites failed (#5828) by @sapphi-red
- vite-tests: set `_VITE_TEST_JS_PLUGIN` instead of `_VITE_TEST_NATIVE_PLUGIN` (#5827) by @sapphi-red
- deps: use `vitepress@^2.0.0-alpha.12` instead (#5811) by @shulaoda
- deps: update dependency rolldown-plugin-dts to v0.15.7 (#5814) by @renovate[bot]
- add example with oxc transform styled components plugin (#5800) by @IWANABETHATGUY
- deprecate top-level `jsx` option in favor of `transform.jsx` (#5783) by @shulaoda
- deps: update crate-ci/typos action to v1.35.5 (#5786) by @renovate[bot]
- update default value of options.context (#5777) by @IWANABETHATGUY

### ◀️ Revert

- "fix: jsx preserve break component which is default export (#5764)" (#5856) by @shulaoda

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.

3 participants