I have two Angular2 projects that utilize webpack as a module bundler and typescript.
In an effort to share code between the two projects, I decided to split some of the source code and create a symlink to this 'external' source code from each project.
However, upon doing this, the "symlinked code" is unable to resolve the imports properly.
Here is a simple "hello world" project showcasing my concerns:
https://github.com/datracka/angular2-symlink-issue
Initially, the project runs smoothly. However, if you remove the original src
folder and create a symlink to another source code located at /another/path/src
, you will encounter a compiler error:
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-abc/node_modules/ts-loader/index.js:156:103)
at Object.loader (/Users/vicensfayos/Projects/angular2-abc/node_modules/ts-loader/index.js:403:14)
Therefore, my question is: what am I missing when it comes to using symlinks to distribute the source code outside of the project folder itself?
I suspect that proper configuration for resolving objects in webpack () to override the node.js loading algorithm for node modules (https://nodejs.org/api/modules.html#modules_loading_from_node_modules_folders) may be the key, but I have had no success thus far.
Any guidance in this matter would be greatly appreciated.