Skip to content

Relative require paths seem to be cached and not resolved based on importing file location #5223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jessevdk opened this issue Oct 12, 2015 · 2 comments
Labels
Question An issue which isn't directly actionable in code

Comments

@jessevdk
Copy link

It looks like when I have two files importing the same relative url, that the module this relative url resolves to is somehow cached and reused. I'm running into the following problem:

mod.ts
a/a.ts: require("../mod");
b/c/b.ts: require("../mod");

The second require should fail (there is no b/mod.ts), but actually succeeds if I list a/a.ts first in the tsconfig. The generated js however just contains the relative import paths (I'm using the AMD module loader output) and so actually doesn't work.

@vladima
Copy link
Contributor

vladima commented Oct 12, 2015

yes, this is a known bug. Reason of failure is classic" module resolution algorithm that was used in TypeScript since the beginning of time. It uses folder walk (to mimic Node like resolution) which is incorrect in this situation. We have a proposal to implement module resolution strategy that will use base url - this should address this issue

@mhegazy mhegazy added the Question An issue which isn't directly actionable in code label Oct 12, 2015
@jessevdk
Copy link
Author

I see, I guess we can close this then. I'm considering this quite a severe issue for us, it's kind of hard to track down import path errors like this (we now resort to a tool to post-check relative import paths).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

3 participants