tsconfig-paths-webpack-plugin
tsconfig-paths-webpack-plugin copied to clipboard
Unexpected error with webpack + ts-node + TS_NODE_PROJECT
Scenario 1:
- Using
webpack.config.js
-
tsconfig.json
extends fromtsconfig.base.json
-
tsconfig.base.json
hasbaseUrl
andpaths
- Executing
webpack
works fine with plugin
Scenario 2:
- Using
webpack.config.ts
(ts-node
is installed) -
tsconfig.json
extends fromtsconfig.base.json
-
tsconfig.base.json
hasbaseUrl
andpaths
- Executing
webpack
works fine with plugin
Scenario 3:
- Using
webpack.config.ts
(ts-node
is installed) -
tsconfig.json
extends fromtsconfig.base.json
-
tsconfig.base.json
hasbaseUrl
andpaths
- Executing
TS_NODE_PROJECT=tsconfig.base.json webpack
complains that missingbaseUrl
incompilerOptions
In all scenarios if within webpack.config
I run below I get success
so scenario 3 should work fine:
const TsconfigPaths = require('tsconfig-paths')
console.log(TsconfigPaths.loadConfig().resultType)
Did you try adding process.env['TS_NODE_PROJECT'] = '';
to webpack.config.ts
?
Why you guys down vote a workaround? I am not the author of the library anyway. 🤷♂
...
🤦♂️
That. Makes. Sense.
Thanks! Going to leave this open for now to see if this should be a proper solution.
@jonaskello I've faced the same issue right now. Although workaround with setting the env variable inside script works fine, it would be much better to fix this inside the library itself, IMHO.
My main reason is that configFile
has file
in its name and situations when TS_NODE_PROJECT
is set and configFile
param is being used like base path are creating some really strange behavior.
I would suggest replacing configFile
with multiple params. One of those will behave like the current one and another one will always be treated as a path to file.