Skip to content

Accept relative paths to node_modules in npm remappings#8007

Merged
alcuadrado merged 5 commits intomainfrom
relative-npm-remappings
Mar 2, 2026
Merged

Accept relative paths to node_modules in npm remappings#8007
alcuadrado merged 5 commits intomainfrom
relative-npm-remappings

Conversation

@alcuadrado
Copy link
Copy Markdown
Member

@alcuadrado alcuadrado commented Feb 25, 2026

Fixes #7562, a requirement to drop the beta label

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 25, 2026

🦋 Changeset detected

Latest commit: b19c920

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
hardhat Patch

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 relative node_modules paths to node_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.

alcuadrado and others added 2 commits February 25, 2026 15:26
…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>
@alcuadrado alcuadrado added no docs needed This PR doesn't require links to documentation no peer bump needed labels Feb 25, 2026
Comment thread .changeset/polite-beds-doubt.md Outdated
Copy link
Copy Markdown
Member

@kanej kanej left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@alcuadrado alcuadrado added this pull request to the merge queue Mar 2, 2026
Merged via the queue into main with commit 67a6676 Mar 2, 2026
619 of 627 checks passed
@alcuadrado alcuadrado deleted the relative-npm-remappings branch March 2, 2026 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no docs needed This PR doesn't require links to documentation no peer bump needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support relative paths to node_modules in the reamppings.txt files

3 participants