[RFC]: Support ignoring tsconfig paths config #4269
Replies: 16 comments
-
The specific implementation is to disable |
Beta Was this translation helpful? Give feedback.
-
Great RFC! Personally speaking, consistency with the original configuration is important. Since Second is the extendability. Based on my considerations, I would like to propose something like |
Beta Was this translation helpful? Give feedback.
-
Yes, and when using Rspack, it will remove the resolve.tsConfigPaths config. |
Beta Was this translation helpful? Give feedback.
-
Like this idea! I will update my RFC and use the
Considering that next.js reads tsconfig paths by default, maybe community users are more familiar with tsconfig paths rather than source alias.
Only tsconfig paths now. 😄 |
Beta Was this translation helpful? Give feedback.
-
Gread idea ! In addition, maybe we need to provide a configuration to specify the tsconfig.json file path. The current implementation is hard-coded |
Beta Was this translation helpful? Give feedback.
-
@targeral have enhanced the TsConfigPathsPlugin in a recent PR: #3991 Now the plugin will find the closet |
Beta Was this translation helpful? Give feedback.
-
What I mean is that the following configuration can be directly modified: // webpack
new TsconfigPathsPlugin({
configFile: 'xxx' // here
}) // rspack
resolve: {
tsConfigPath: 'xxx', // here
}, For example, some projects have diffrent |
Beta Was this translation helpful? Give feedback.
-
things becomes complex now, since rspack tsconfig paths and alias are merged and tsconfig path has high priority, so it would be hard for rspack to implement the stragegy |
Beta Was this translation helpful? Give feedback.
-
If the user asks for this config, we will consider adding it. |
Beta Was this translation helpful? Give feedback.
-
We can just remove the resolve.tsConfigPaths config fro Modern.js Builder when using |
Beta Was this translation helpful? Give feedback.
-
you mean |
Beta Was this translation helpful? Give feedback.
-
Yep, my mistake |
Beta Was this translation helpful? Give feedback.
-
it seems rspack merge tsconfig.paths and alias if set tsconfigpaths which behaves not the same as prefer-tsconfig or prefer-alias |
Beta Was this translation helpful? Give feedback.
-
If the tsconfig.paths has a higher priority, then is it same as |
Beta Was this translation helpful? Give feedback.
-
The Rspack documentation should explain more about the relationship between |
Beta Was this translation helpful? Give feedback.
-
@bvanjoi @Boshen can you help check the result and help improve the documentation of resolve |
Beta Was this translation helpful? Give feedback.
-
What problem does this feature solve?
Currently, the Modern.js Builder automatically reads the
compilerOptions.paths
field intsconfig.json
as the alias config, and the priority of tsconfig paths is higher thansource.alias
config, so thesource.alias
is basically useless for TypeScript projects.source.alias
:But in some scenarios, the user does not want the default behavior, they want to use
source.alias
because it allows user to create some alias config dynamically, for example, useprocess.env
to set alias.And tsconfig paths config is static (written by JSON) and not as flexible as
source.alias
. In this case, tsconfig paths config is only used to provide the type of alias, and should not override the user configured alias config.What does the proposed API look like?
The Modern.js Builder will add a new
source.aliasStrategy
config to change the default behavior, so users can use thesource.alias
and it will not be overridden by tsconfig paths.'prefer-tsconfig' | 'prefer-alias'
'prefer-alias'
Beta Was this translation helpful? Give feedback.
All reactions