microsoft / microsoft/TypeScript
Recursively Resolving Modules
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TypeScript Version: 2.1.0
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 and use the first shared directory it finds (the same way it does with the node_modules directories). This way, the component can live in the ../../shared/components/Buttton.tsx and Webpack will find it and bundle it.
My files compile fine because I am using ts-loader but I am getting can not find module errors in my editor.
Is there a way to tell the TS compiler to recursively look for the component in the shared directories?
I noticed the new baseUrl and paths configuration option but to my knowledge you can not use paths to recursively look for a directory.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no source files or tests. Start by reading TypeScript's module-resolution behavior around baseUrl and paths, then compare it with Webpack's modulesDirectories lookup. Done means the compiler and editor can resolve imports such as components/Button through applicable shared directories without module-not-found errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, webpack
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100