Description
Expected Behavior
When using Webpack's raw-loader
with TypeScript project references— For any given module X.ts
, I'd expect import paths relative to X.ts
to refer to the same resources whether X
is imported from within its own project, or from a module in a different project.
Specifically, if X.ts successfully finds a resource Y, both contained in project Z when Z is compiled separately, then I wouldn't expect Y to suddenly be considered missing when Z is imported or referenced by another project.
Clone https://github.com/trbabb/rawloader-repro.git, and after npm install
, run npx webpack
. I'd expect src/Foo.ts
to find ./shad/foo.frg
and import it normally.
Actual Behavior
npx webpack
in the above repo yields:
ERROR in /project/path/src/Foo.ts
./src/Foo.ts
[tsl] ERROR in /project/path/src/Foo.ts(1,19)
TS2307: Cannot find module './shad/foo.frg' or its corresponding type declarations.
This is not the case if src/Foo.ts
is compiled from within its own project. This can be seen if you:
> mv webpack.config.js webpack.config.js-broken
> mv webpack.config.js-working webpack.config.js
> npx webpack
This compiles normally, and the contents of foo.frg
can be found inside the bundle as expected.
Somehow, the existence of project reference breaks the relative path in src/Foo.ts
.
Code / How to reproduce
git clone https://github.com/trbabb/rawloader-repro.git
npm install
npx run webpack
The raw-loader team informs me that this is likely a ts-loader issue. I'm not well versed in how different loaders interact with each other— please let me know if there's relevant information to pass back to the raw-loader team, or if there's anything I need to configure differently to get this to work.
Thanks!