You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rspack/Rsbuild should automatically resolve relative imports across all root directories, making these equivalent:
// From src/a/foo.ts, these should both work:import{moo}from'../c/d/moo'// Resolves to generated/c/d/moo.tsimport{moo}from'./sibling'// Resolves to src/a/sibling.ts
Why This Makes Sense
Consistency: Rspack already reads tsconfig for paths - rootDirs is a natural extension
Common Use Case: Generated code patterns are increasingly common (GraphQL codegen, Protocol Buffers, etc.)
TypeScript Alignment: Reduces impedance mismatch between type checking and bundling
Developer Experience: Eliminates need for complex workarounds or custom plugins
Implementation Notes
Should follow the same patterns as existing paths support
Need to handle relative path resolution across multiple root directories
Consider file precedence when same relative path exists in multiple roots (TypeScript uses first match)
This feature would eliminate a significant pain point for projects using generated code patterns while maintaining consistency with existing TypeScript configuration support.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Support TypeScript
rootDirsConfigurationProblem Statement
Generated code often lives alongside source code in separate directory structures:
src/ a/foo.ts generated/ b/bar.d.ts c/d/moo.ts # Generated TypeScript files (not just .d.ts)The issue:
rootDirsconfigurationCurrent broken behavior:
src/a/foo.ts, this import fails during build:rootDirs: ["src", "generated"]is configuredAttempted Workarounds
1. Using
resolve.modules(Partial Solution)Limitation: Only works for absolute imports, not relative paths like
'./c/moo'.2. Custom Plugin (Working but Complex)
Works but: Requires custom plugin code for what should be standard TypeScript behavior.
3. Webpack
resolve.plugins(Not Available)This worked in Webpack but
resolve.pluginsare not supported by Rsbuild.Proposed Solution
Add native support for TypeScript's
rootDirsconfiguration, similar to howpathsis currently handled.Expected Behavior
When
tsconfig.jsoncontains:{ "compilerOptions": { "rootDirs": ["src", "generated"] } }Rspack/Rsbuild should automatically resolve relative imports across all root directories, making these equivalent:
Why This Makes Sense
tsconfigforpaths-rootDirsis a natural extensionImplementation Notes
pathssupportThis feature would eliminate a significant pain point for projects using generated code patterns while maintaining consistency with existing TypeScript configuration support.
Beta Was this translation helpful? Give feedback.
All reactions