feat(resolve): allow custom tsconfig file via resolve.tsconfigPaths.configFile#22533
Open
rubnogueira wants to merge 2 commits into
Open
feat(resolve): allow custom tsconfig file via resolve.tsconfigPaths.configFile#22533rubnogueira wants to merge 2 commits into
rubnogueira wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Widens
resolve.tsconfigPathsfrombooleantoboolean | TsconfigPathsOptionsso consumers can pin a specific tsconfig (e.g.tsconfig.prod.json) instead of relying on rolldown'sauto-discovery.
Motivation
resolve.tsconfigPaths: truealready works, but only auto-discovers the nearesttsconfig.json. There's no way to point it at a different file. Today users have to either:vite-tsconfig-pathsplugin (and itsprojectsoption), orresolve.aliasby hand invite.config.ts.The intended migration story from #22112 was to drop the external plugin once Vite 8 shipped native support, but
booleanis too narrow for the cases that motivatedvite-tsconfig-paths.projectsin the first place.Changes
packages/vite/src/node/plugins/resolve.ts:TsconfigPathsOptions { configFile: string }interface.ResolveOptions.tsconfigPathstyped asboolean | TsconfigPathsOptions.viteResolvePlugin, resolving a relativeconfigFileagainst the project root (oxc-resolver requires an absolute path).docs/config/shared-options.md— documents the new shape with the prod/dev switch example.playground/resolve-tsconfig-paths-config-file/— new e2e playground proving the customconfigFilewins over an adjacent (wrong-mapping)tsconfig.json.Depends on
viteResolvePluginaccepts the object form. Without it, passing{ configFile }throwsFailed to convert napi value into rust type 'bool'at runtime.The Rust side already had
TsconfigDiscovery::Manualplumbed throughoxc_resolver; only the vite-resolve plugin's binding hardcodedbool(
crates/rolldown_plugin_vite_resolve/src/resolver.rs:174upstream), so theManualarm was unreachable from JS. The rolldown PR exposes it; this PR forwards it.Related
esbuild.tsconfigRaw(vitest 4.1 moved to rolldown) left users with no way to swap tsconfigs for prod vs dev runs.Test plan
pnpm typecheck)packages/vite/src/node/__tests__/resolve.spec.tscases passplayground/resolve-tsconfig-paths/__tests__/resolve.spec.ts— existingtsconfigPaths: truebehavior unchangedplayground/resolve-tsconfig-paths-config-file/__tests__/resolve.spec.ts— new playground passes in both dev and build modestsconfigPaths: falsestill disables resolutionrolldownto a version that includes the binding widening