Skip to content
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

Fix plugin dependency checks and set npmPackage values on plugins #6046

Merged
merged 2 commits into from
Jan 12, 2025

Conversation

antico5
Copy link
Contributor

@antico5 antico5 commented Dec 11, 2024

This PR addresses #6035

The original scope of the issue was to set the npmPackage property of our hardhat3 plugins, so when an import fails we can give detailed information if a given plugin package is missing, or some of its peer dependencies.

When running a test scenario, specifically using hardhat-viem and not having the viem peer dep installed, I noticed that even after setting the npmPackage property on our plugin, the error message wasn't helping. This lead me to debug the core plugins/detect-plugin-npm-dependency-problems.ts module.

I noticed that the require.resolve function was not working, and after thorough debugging I found out that the createRequire function doesn't work properly when passing an absolute path to a directory without a trailing forward slash. Adding the trailing forward slash to the directory path would make the require instance work.

After that, I started to get the error that package.json was not being exported by our modules, and we need to require() those to find the peer dependencies of packages. Then I added an export of package.json to all of our modules.

Closes #6035

@antico5 antico5 added the v-next A Hardhat v3 development task label Dec 11, 2024
@antico5 antico5 requested a review from alcuadrado December 11, 2024 13:27
Copy link

vercel bot commented Dec 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hardhat ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 13, 2024 2:16pm

Copy link

changeset-bot bot commented Dec 11, 2024

⚠️ No Changeset found

Latest commit: 06f1e9a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@schaable schaable added status:ready This issue is ready to be worked on and removed status:triaging labels Dec 30, 2024
@kanej kanej linked an issue Jan 7, 2025 that may be closed by this pull request
Copy link
Member

@alcuadrado alcuadrado left a comment

Choose a reason for hiding this comment

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

Approved as a temporary fix. We should make this work without exporting package.json. Luckily #6125 already does it for the resolver.

@alcuadrado alcuadrado added this pull request to the merge queue Jan 12, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 12, 2025
@alcuadrado alcuadrado added this pull request to the merge queue Jan 12, 2025
Merged via the queue into v-next with commit eb2c3df Jan 12, 2025
75 checks passed
@alcuadrado alcuadrado deleted the fix-plugin-dependency-checks branch January 12, 2025 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:ready This issue is ready to be worked on v-next A Hardhat v3 development task
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Include npmPackage in all our plugins
4 participants