Implement #hash import resolution for package.json imports#148
Open
larsmoa wants to merge 2 commits intodependents:mainfrom
Open
Implement #hash import resolution for package.json imports#148larsmoa wants to merge 2 commits intodependents:mainfrom
larsmoa wants to merge 2 commits intodependents:mainfrom
Conversation
a99ccf4 to
af9b687
Compare
Member
|
I could use more eyes on this PR... |
|
Hoping to see this PR land soon, so we can leverage it in Madge! Btw, in our case, the @larsmoa would it be supported? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for resolving
#hashimports defined in theimportsfield ofpackage.json.Motivation
This change will enable e.g. madge to properly resolve
#hash-style imports. See pahen/madge#406.Currently, imports like:
...fail to resolve when the
package.jsoncontains:{ "imports": { "#aggregate": "./src/util/aggregate.js", "#lib/*": "./src/lib/*.js" } }This causes madge to skip these dependencies entirely, making dependency graphs incomplete for projects using Node.js subpath imports.
Solution
This PR adds hash import resolution by leveraging
enhanced-resolve(already a dependency) which fully supports the Node.js subpath imports specification including:#utils→./src/utils.js)#lib/*→./src/lib/*.js)import,require,node,defaultconditions)References