TypeScript+Webpack resolving dependencies in symlink folder

Viewed 3254

I've faced with problem that TypeScript+Webpack doesn't resolve correctly dependencies if they are in symbolic linked folder. I have file structure like this:

- main
-- index.ts
-- package.json
-- webpack.config.js

- shared-lib
-- services
--- session.ts
-- package.json

In main there is a dependency for shared-lib@file:../shared-lib, in result npm would create symbolic link in node_modules for it.

In shared-lib I have dependency for lodash-es, as well as I have it in main, but the thing that there should be only one lodash-es in project, which I want to keep in main, in result when I try to build the project I get something like:

ERROR in [at-loader] ../shared-lib/index.ts:1:24 TS2307: Cannot find module 'lodash-es/capitalize'.

Webpack was complaining about this as well but can be fixed if provide an absolute path to node_modules in resolve.modules. Now looks like the only TypeScript not aware where to look for dependencies. I've looked through TypeScript configuration documentation and cannot find anything helpful, is there any way to give a hint to TypeScript where to look for dependencies, if file located outside of the main folder? I tried to use rootDirs but seems it's not for my case.

1 Answers
Related