question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Recursively Resolving Modules

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:2
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
jquensecommented, Jan 7, 2019

this is a huge blocker to adopting typescript on larger projects. I’ve been trying to come up with a flow to typescript migration for a lot of our projects and without this option it’s just infeasible.

We need an option that allows customizing which modules are node_modules

2reactions
wclrcommented, Sep 21, 2016

It would be very useful if TS supported more advanced ala webpack resolution strategies. https://webpack.github.io/docs/configuration.html#resolve-alias

but no need be as much sophisticated it believe

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack - How to resolve module recursively - Stack Overflow
This is how I do it. Gonna have to manually add more directory in the array when there is new one. resolve: {...
Read more >
What is a Recursive Module?
analysis of the notion of a recursive module in the con- ... de nition of recursive modules. ... how rds's are used to...
Read more >
What is a Recursive Module?*
There is no question that hierarchical design is an important tool for structuring large systems. It has of- ule systems impose an acyclic...
Read more >
5.11 Recursive module loading - The Internals of Deno - GitBook
Overview · Create a recursive module loader (one of the args is the module loader) · Prepare modules. Fetch. Insert in graph ·...
Read more >
Mutually recursive modules - HaskellWiki
In difficult cases it is impossible to solve the recursion through adding *.hs-boot files, and in these cases the protocol-buffers package ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found