Accept relative paths to node_modules in npm remappings#8007
Accept relative paths to node_modules in npm remappings#8007alcuadrado merged 5 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: b19c920 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Pull request overview
This pull request adds support for relative paths to node_modules in npm remappings, addressing issue #7562 which is a requirement to drop the beta label. Previously, only remappings starting with node_modules/ were treated as npm remappings. Now, the code also accepts relative paths like ../node_modules/, ./node_modules/, and ../../node_modules/ that resolve to a node_modules directory at the project root or in a parent directory.
Changes:
- Added
getNormalizeNodeModulesPath()function to normalize relativenode_modulespaths tonode_modules/format - Modified remapping processing logic to use the new normalization function before checking if a remapping is an npm or local remapping
- Added comprehensive test coverage for relative npm remappings and the normalization function
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| v-next/hardhat/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.ts | Implements the core logic for normalizing relative node_modules paths and integrating it into the remapping resolution flow |
| v-next/hardhat/test/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.ts | Adds comprehensive test coverage for relative npm remappings scenarios and unit tests for the getNormalizeNodeModulesPath() function |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…stem/resolver/remapped-npm-packages-graph.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…tem/resolver/remapped-npm-packages-graph.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
kanej
left a comment
There was a problem hiding this comment.
This looks good - by which I mean:
- the tests make sense to me
- a quick manual test in the example project showed remappings being normalized
Fixes #7562, a requirement to drop the beta label