Currently, I am involved in a monorepo project and I need Webpack to fetch my source files from the src
directory instead of the dist
folder (as specified in the package.json
file).
Let's consider the structure below:
/packages/core/dist/index.js (compiled output)
/packages/core/src/index.ts (original TypeScript source)
/packages/core/package.json (`main` and `module` point to `dist`)
Now, within the /packages/foo/src/index.ts
file, I have an import statement like import Foo from '@test/core'
. The issue arises when Webpack reads the core
package's package.json
because it uses the module
and main
fields pointing to the dist
folder. In this case, I need Webpack to load the original sources from the src
directory as @test/core
is part of my internal codebase and not an external library.
My question is: Is there a method to instruct Webpack to exclusively load the original TypeScript sources for specific modules that start with @test/
?