i have 2 angular2 projects using webpack module bundler , typescript.
aiming share code between, split of source code , created symlink 'external' source code each of 2 projects.
after doing "symlinked code" can not resolve imports properly.
below "hello world" project shows concerns.
https://github.com/datracka/angular2-symlink-issue
this project runs straight forward if remove given src
folder , create symlink src
folder same source code located @ /another/path/src
compiler error:
error in .-shared/src/main.ts module build failed: typeerror: path must string. received undefined @ assertpath (path.js:7:11) @ object.dirname (path.js:1326:5) @ ensuretypescriptinstance (/users/vicensfayos/projects/angular2-whatafuck/node_modules/ts-loader/index.js:156:103) @ object.loader (/users/vicensfayos/projects/angular2-whatafuck/node_modules/ts-loader/index.js:403:14)
so question is: missing symlinks when "distribute" source code in folder out of project folder itself?
my guess configure resolving object in webpack https://webpack.github.io/docs/resolving.html override node.js loading node_modules algorithm https://nodejs.org/api/modules.html#modules_loading_from_node_modules_folders not luck.
hopefully can point me in direction.
i found answer.
my guess right. how nodejs resolve dependencies. https://nodejs.org/api/modules.html#modules_loading_from_node_modules_folders
the symlinked code trying find dependencies moving way failing until finds node_module
. nothing there. node_module
in parent project.
therefore solution create symlink symlinked code node_modules
folder of parent project resolve dependencies.
Comments
Post a Comment