tsc
will infer that moduleResolution: "node"
if I have module: "commonjs"
in my tsconfig.json
, even if I also have target: "ES6"
(it won't default to node-style moduleResolution if module
is set to "es6" and target is also set to "ES6").
However, when compiling with ts-loader
via webpack, I have to explicitly add moduleResolution: "node"
to my tsconfig file to avoid "Cannot find module 'whatever'" errors in the output.
Adding that line, "moduleResolution": "node"
is trivial. Figuring out that I need to add it, to resolve errors that webpack + ts-loader was throwing at me, was frustrating. I would expect ts-loader's (default) behavior to match tsc's (default) behavior, particularly when the ts-loader log message says it's using exactly the same tsconfig file that tsc is using.