Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@squaremo
Copy link
Member

Prior to npm module resolution, the specifier for a module and the
file path had a direct relationship, and it was a reasonable
approximation to make base/specifier the new base for recursive
imports.

However, npm modules can be resolved to paths that don't correspond
closely with the specifier; so, explicitly return the filesystem path
from Import and use that to resolve recursive imports.

(Another way to do this would be to take the top path from the candidates list, and assume the contract that it must be the successful path (if bytes is not empty).)

@squaremo
Copy link
Member Author

I'm going to squash this when I merge.

One thing I have noticed, that I ought to test and fix, is that the "candidates" list can be inconsistent -- with repeated entries in particular. I was not too careful about getting it exactly right when I implemented the module resolution.

@dlespiau
Copy link
Member

Ah yes, I noticed that too and thought we could have pass deduplicating entries.

@squaremo
Copy link
Member Author

we could have pass deduplicating entries.

My feeling is that a correct resolution procedure would not consider each path more than once. I suppose different importers might do so (but you'd kind of hope they wouldn't overlap?)

Prior to npm module resolution, the specifier for a module and the
file path had a direct relationship, and it was a reasonable
approximation to make base/specifier the new base for recursive
imports.

However, npm modules can be resolved to paths that don't correspond
closely with the specifier; so, explicitly return the filesystem path
from `Import` and use that to resolve recursive imports.
@squaremo squaremo force-pushed the node-modules-relative branch from 6866f6e to 8074582 Compare January 23, 2019 07:48
To make import failures a little more transparent, give each import
candidate an annotation saying which rule was being applied. In the
case of the NPM importer, these can get quite complicated ..
.. specifically, eslint rules pertaining to module imports, since
that's what's under test.
@squaremo squaremo force-pushed the node-modules-relative branch from d2867a6 to 421b713 Compare January 23, 2019 17:37
@squaremo squaremo merged commit 04bb7ac into master Jan 23, 2019
@squaremo squaremo deleted the node-modules-relative branch January 23, 2019 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants