ts-loader: NormalModuleReplacementPlugin doesn't play nice with ts-loader
Expected Behaviour
When I implement the pattern for the NormalModuleReplacementPlugin, I expect that the ts-loader would be aware of the configuration and help swallow the compiler error so the compilation would finish.
Actual Behaviour
Because ‘./config/config-APP_TARGET’ does not actually exist, the compiler throws an error:
ERROR in ./ClientApp/boot.ts
Module build failed (from ./node_modules/ts-loader/index.js):
Error: Typescript emitted no output for D:\GitHub\NMRP-Plus-TypeScript-Repro\WebPack-NMRP-Repro\ClientApp\boot.ts.
at successLoader (D:\GitHub\NMRP-Plus-TypeScript-Repro\WebPack-NMRP-Repro\node_modules\ts-loader\dist\index.js:41:15)
at Object.loader (D:\GitHub\NMRP-Plus-TypeScript-Repro\WebPack-NMRP-Repro\node_modules\ts-loader\dist\index.js:21:12)
ERROR in D:\GitHub\NMRP-Plus-TypeScript-Repro\WebPack-NMRP-Repro\ClientApp\boot.ts
./ClientApp/boot.ts
[tsl] ERROR in D:\GitHub\NMRP-Plus-TypeScript-Repro\WebPack-NMRP-Repro\ClientApp\boot.ts(1,20)
TS2307: Cannot find module './config/config-APP_TARGET'.
The code executes locally anyway, but because webpack throws a failed error code at this point, automated build systems like Azure Pipelines fail.
Workaround:
You have to add a config-APP_TARGET.ts
file to the config folder, with a blank exported module mirroring your actual config module, so that the compiler does not error out.
It would be really nice if this workaround was not necessary.
Steps to Reproduce the Problem
See repro below.
Location of a Minimal Repository that Demonstrates the Issue.
https://github.com/CloudNimble/NMRP-Plus-TypeScript-Repro
I hope this information helps someone who runs into the same problem, and I hope it can ultimately be fixed so that the pattern in the documentation can be implemented as-is.
Thanks!
About this issue
- Original URL
- State: open
- Created 6 years ago
- Comments: 17 (6 by maintainers)
I’ve reopened it - I’m not sure if anyone is looking at it though
This is open source. There are no obligations. There’s just potential for collaboration.
We scratch our itches. This is something that’s impacting you, I completely encourage you to dig in and see if you can help! ❤️🌻