Problem
When TS_NODE_PROJECT environment variable is defined, the config path will be detected incorrectly and the plugin will not work.
The configFile configuration parameter will be ignored even if provided.
Example:
| Command |
Resulting Using config file at ... output |
Correct? |
webpack |
...client/management/tsconfig.json |
✅ |
TS_NODE_PROJECT=tsconfig.json webpack |
...client/management/tsconfig.json/tsconfig.json |
❌ |
TS_NODE_PROJECT=tsconfig.tools.json webpack |
...client/management/tsconfig.json/tsconfig.tools.json |
❌ |
Use case
I have two TS config files - main and tooling.
Main:
"compilerOptions": {
...
"module": "esnext",
"moduleResolution": "bundler",
"paths": {
"@root/*": ["./src/app/*"]
}
},
Tooling:
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node"
},
However, invoking webpack via TS_NODE_PROJECT=tsconfig.tools.json webpack breaks tsconfig-paths-webpack-plugin.
Workaround
- Create a wrapper script that registers tooling TS project and invokes webpack CLI programmatically.
- Provide explicit main config file to the
tsconfig-paths-webpack-plugin via configFile property.
Problem
When
TS_NODE_PROJECTenvironment variable is defined, the config path will be detected incorrectly and the plugin will not work.The
configFileconfiguration parameter will be ignored even if provided.Example:
Using config file at ...outputwebpack...client/management/tsconfig.jsonTS_NODE_PROJECT=tsconfig.json webpack...client/management/tsconfig.json/tsconfig.jsonTS_NODE_PROJECT=tsconfig.tools.json webpack...client/management/tsconfig.json/tsconfig.tools.jsonUse case
I have two TS config files - main and tooling.
Main:
Tooling:
However, invoking webpack via
TS_NODE_PROJECT=tsconfig.tools.json webpackbreakstsconfig-paths-webpack-plugin.Workaround
tsconfig-paths-webpack-pluginviaconfigFileproperty.