我有两个使用webpack作为模块打包器和打字稿的Angular2项目。了解Angular 2 webpack项目中的源代码符号链接
为了共享代码,我拆分了一些源代码,并为这两个项目中的每一个的这个“外部”源代码创建了一个符号链接。
完成此操作后,“符号链接代码”无法正确解析导入。
低于“hello world”项目以显示我的顾虑。
https://github.com/datracka/angular2-symlink-issue
该项目运行直线前进,但如果你删除给定src
文件夹,并创建一个符号链接到具有相同的源代码中的另一个src
文件夹,但位于/another/path/src
,那么你得到一个编译错误:
ERROR in .-shared/src/main.ts
Module build failed: TypeError: Path must be a string. Received undefined
at assertPath (path.js:7:11)
at Object.dirname (path.js:1326:5)
at ensureTypeScriptInstance (/Users/vicensfayos/Projects/angular2-whatafuck/node_modules/ts-loader/index.js:156:103)
at Object.loader (/Users/vicensfayos/Projects/angular2-whatafuck/node_modules/ts-loader/index.js:403:14)
所以我的问题是:当我将源代码“分发”到项目文件夹本身的另一个文件夹中时,我缺少符号链接?
我的猜测是关于在webpack中配置正确解析对象以覆盖node.js加载node_modules算法https://nodejs.org/api/modules.html#modules_loading_from_node_modules_folders但不是运气。
希望有人能指出我的方向。