在我的webpack.config.js
我创建了一些别名,我试图在我的TypeScript配置中匹配这些别名。
在运行--traceResolution
时,我注意到它只是试图将这些别名导入一次又一次地解析为node_modules。
// import Component from the aliased 'module'
import Component from 'somealias/component';
Would output something like:
Loading module 'somealias/component' from node_modules folder.
File '/.../.../node_modules/somealias/component' does not exist
File '/../node_modules/somealias/component' does not exist
File '/node_modules/somealias/component' does not exist
...
但我希望它能将'somealias'别名转换为我在tsconfig文件中创建的正确路径。
我的tsconfig.json
文件看起来像这样:
{
compilerOptions: {
module: es6,
moduleResolution: "node",
target: es6,
jsx: react,
},
typeRoots: [ "./path/to/typingsfolder" ],
baseUrl: ".",
paths: {
"somealias/*": [
"path/to/resolve/to/*"
]
}
}