I have an node module which I want to create an alias for.
I have the following configs:
// tsconfig.json
{
"compilerOptions": {
...
"allowJs": true,
"module": "commonjs",
"target": "es6",
"jsx": "react",
"esModuleInterop": true,
"experimentalDecorators": true,
"baseUrl": "./",
"moduleResolution": "node",
"paths": {
"@my-lib/*": [
"node_modules/my-lib/src/Components/*"
]
}
},
"exclude": ["node_modules"]
}
// webpack.config.js
resolve: {
extensions: ['.js', '.jsx', '.tsx', '.ts'],
alias: {
'@my-lib': path.resolve(
'./node_modules/my-lib/src/Components'
),
}
},
// eslintrc.json
"settings": {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"]
},
"import/resolver": {
"typescript": {},
"alias": {
"map": [
[
"@my-lib",
"./node_modules/my-lib/src/Components"
]
],
"extensions": [".js", ".jsx", ".ts", ".tsx"]
}
}
But when importing a module from my-lib vscode auto import resolves it to:
my-lib/src/Components/...
Another config I have is:
"typescript.preferences.importModuleSpecifier": "relative",
(though I've tried auto and non-relative as well)
I tried pretty much every combination of baseUrl
and paths
.
Appreciate any help!