React-Hot-Loader not resolving references correctly

16 Views Asked by At

So I am getting errors when building like these (names and stack simplified to packageA which depends on packageB, and src/SrcFile1.tsx, that depends on packageA):

Error in d:\npmcache\@packageNamespaceA\packageNameA-versionA\node_modules\@packageNamespaceA\packageNameA\dist\src\index.js
Module not found: Error: Can't resolve '@packageNamespaceB/packageNameB' in 'd:\npmcache\@packageNamespaceA\packageNameA-versionA\node_modules\@packageNamespaceA\packageNameA\dist\src'
@ d:\npmcache\@packageNamespaceA\packageNameA-versionA\node_modules\@packageNamespaceA\packageNameA\dist\src\index.js
@ ./src/SrcFile1.tsx
@ multi react-hot-loader/patch ./src/SrcFile1.tsx

The thing is that the node_modules folder under packageA, that is:

 d:\npmcache\@packageNamespaceA\packageNameA-versionA\node_modules

Actually has the copy of packageB that I want. Generally, this is how NPM modules are resolved, and I have successfully added dependencies this way by making them visible to just packageA. However, react-hot-loader seems to be different. It appears to only resolve packageB relative to the original file (./src/SrcFile1.tsx). If I add packageB as a dependency to building module's package.json, so that the node_modules folder next to .src has packageB, then it works. But I shouldn't need to do this, as ./src/SrcFile1.tsx doesn't depend on packageB, packageA does.

Does this seem like a bug in react-hot-loader, or by design?

0

There are 0 best solutions below