Reputation: 622
I'm using ts-loader and Webpack to compile my .ts files. In My Webpack config I have the following configuration:
resolve: {
modulesDirectories: ['shared', 'node_modules']
}
This allows me to import a component that lives in the shared directory without spelling out the full relative path. Example:
import Button from 'components/Button'
Webpack will walk up the directory tree looking for a shared
directory. This way, the component can live in the ../../shared/components/Buttton.tsx
and Webpack will find it and bundle it.
This all works fine, however I am getting errors in my editors (both Sublime and VS Code). Also, if I run the tsc
command from the command line I will get compiler errors because the TS compiler does not know how to resolve those modules.
Is there a way to tell the TS compiler to recursively look for the component in the shared
directories?
I am using TS 2.1v
I noticed the new BaseUrl
and paths
configuration options but I was not able to use them successfully.
Upvotes: 0
Views: 71
Reputation: 275799
Is there a way to tell the TS compiler to recursively look for the component in the shared directories
Not recursively. But you can go with one level using paths
mapping.
Upvotes: 1