tsconfig-paths-webpack-plugin
tsconfig-paths-webpack-plugin copied to clipboard
Support for references
It seems like this plugin doesn't support paths defined in references, so I'm suggesting adding this feature to the plugin.
Sounds good! Fancy submitting a PR?
I tried to find some time to do it but unfortunately no luck so far :(
ts-loader has support for references:
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin')
module.exports = {
entry: './src/index.ts',
mode: 'development',
output: {
filename: 'bundle.js',
},
resolve: {
extensions: ['.ts', '.tsx', '.js'],
plugins: [new TsconfigPathsPlugin()],
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
options: { projectReferences: true },
},
],
},
}
When webpack resolves modules, it should use the paths from these TS projects but only for the modules which belong to the project they're defined for.
To illustrate this, here's an example:
Project shared
has these paths:
"paths": {
"helpers/*": ["./my-helpers/*"]
}
Project app
references project shared
and has these paths:
"paths": {
"components/*": ["./my-components/*"]
}
The components/*
path defined by the app
project should not be used for modules inside of the referenced project shared
.
Here is a reduced test case to demonstrate the problem: https://github.com/OliverJAsh/tsconfig-paths-project-references-bug
The paths inside the referenced project shared/tsconfig.json
are not picked up at all.