Skip to content

Turn the local hardhat plugins into npm packages - #6816

Draft
Amxx wants to merge 11 commits into
OpenZeppelin:masterfrom
Amxx:hardhat-plugins-packages
Draft

Amxx wants to merge 11 commits into
OpenZeppelin:masterfrom
Amxx:hardhat-plugins-packages

Conversation

@Amxx

@Amxx Amxx commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

The four Hardhat plugins under hardhat/ (hardhat-exposed, hardhat-oz-contracts-helpers, hardhat-solidity-docgen, hardhat-transpiler) become standalone npm packages, so they can be published and reused outside this repository.

Changes

  • Package layout: each plugin has its code under src/ (plugin.ts → src/index.ts), a package.json (dependencies, peer dependencies, exports, files) and a tsconfig.json. prepare compiles src/ to dist/ with tsc. hardhat-exposed's package.json follows the previous hardhat-exposed (v0.3.x) package.
  • Root wiring: the plugins are file: dev dependencies of the root package and are imported by name in hardhat.config.ts. npm install / npm ci builds them through their prepare script.
  • Running from source in the repo: each plugin exports a source condition pointing to src/index.ts, enabled by the root .npmrc (node-options=--conditions=source). Within the repository, npm run … / npx hardhat load the plugins' TypeScript sources, so edits don't require a rebuild. Published consumers still get dist/. checks.yml sets npm_config_node_options, since npm's node-options replaces NODE_OPTIONS (which carries --max_old_space_size).
  • Scripts: npm run plugins:prepare rebuilds all plugins, npm run plugins:test runs their tests (currently only hardhat-exposed, whose tests move to hardhat/hardhat-exposed/test/, plus unit tests for its manifest in manifest.test.js).
  • CI: the setup action rebuilds the plugins when node_modules is restored from cache, since the cache doesn't contain dist/.
  • Workflow: a new plugins workflow builds (type-checks) the plugins and runs npm run plugins:test, on changes under hardhat/, the root package.json/package-lock.json, or the setup action.
  • Type fixes surfaced by compiling with tsc (strict, noUncheckedIndexedAccess, verbatimModuleSyntax):
    • Explicit .ts extensions on relative imports (rewritten to .js on emit), import type for type-only imports.
    • hardhat-exposed: the build override takes TaskArguments and casts it.
    • hardhat-solidity-docgen: copies the .hbs themes to dist/, and loads theme helpers from either helpers.js (compiled built-in theme) or helpers.ts (user templates).
    • hardhat-oz-contracts-helpers: declares @nomicfoundation/hardhat-network-helpers as a plugin dependency (it already relied on networkHelpers).

Testing

  • npm run plugins:test: 30 passing.
  • hardhat docgen output is identical to the one produced by the previous (in-tree) plugin code.
  • hardhat transpile (after applying upgradeable.patch) output is identical to the one produced by the previous plugin code.
  • hardhat test on a suite using the helpers and exposed contracts passes.

Open questions

  • Package names and versions (hardhat-exposed@0.4.0, others 0.1.0) and repository fields.

Amxx and others added 6 commits October 1, 2026 16:00
Do not automatically run plugin tests when contract are being tested.
Each plugin under `hardhat/` now has its own package.json (dependencies,
peer dependencies, files, exports), a tsconfig.json, and its code under
`src/`. They are built to `dist/` with tsc through their `prepare` script,
linked from the root package.json as `file:` dev dependencies, and imported
by name from hardhat.config.ts.

- Fix the type errors surfaced by compiling the plugins with tsc (strict
  mode, verbatimModuleSyntax, explicit `.ts` import extensions).
- docgen: copy the handlebars themes to `dist/` and load compiled `.js`
  theme helpers.
- oz-contracts-helpers: declare the network-helpers plugin dependency.
- Add `plugins:prepare` and `plugins:test` root scripts, and rebuild the
  plugins in CI when node_modules is restored from cache.
@changeset-bot

changeset-bot Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 8abfcb5

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

@socket-security

socket-security Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​typescript@​7.0.29910089100100

View full report

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants