我正在使用单体库,因此希望Webpack从src
而不是dist
中加载我的源代码(在package.json
中指定了dist
)。
例如,给定以下结构:
/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`)
现在我在
/packages/foo/src/index.ts
中执行import Foo from '@test/core'
。问题在于Webpack读取core
包的package.json
并使用它的module
和main
字段指向dist
文件夹。相反,我希望Webpack从src
加载原始源代码,因为这个@test/core
是我的自己的代码库的一部分,而不是外部依赖项。有没有办法强制Webpack仅针对某些以
@test/
开头的模块加载我的原始TS源代码?