Skip to content
Open
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
731d409
mvp
ChristopherDedominici Oct 8, 2025
4088b56
istanbul libCoverage: copy original js file in root assets folder
ChristopherDedominici Oct 13, 2025
e3d52e3
libReport
ChristopherDedominici Oct 16, 2025
4dae722
report
ChristopherDedominici Oct 16, 2025
d002919
remove dependencies from istanbul in coverage-manager
ChristopherDedominici Oct 16, 2025
95f8d9a
add 'node:' to imports
ChristopherDedominici Oct 16, 2025
f3e276f
replace import to istanbul with internal assets
ChristopherDedominici Oct 17, 2025
c77eb8d
remove unused library
ChristopherDedominici Oct 17, 2025
7771d9f
replace html escape package
ChristopherDedominici Oct 17, 2025
029bc26
replace make-dir with fs/promises
ChristopherDedominici Oct 17, 2025
9be67d5
remove dependencies from istanbul npm packages
ChristopherDedominici Oct 17, 2025
3a55628
base package
ChristopherDedominici Oct 17, 2025
cc5cb6a
move js istanbul libs in the new package
ChristopherDedominici Oct 17, 2025
1856995
add postbuild script and re-organize coverage-manager
ChristopherDedominici Oct 23, 2025
e646399
exclude js, cjs, css, png from the gitignore
ChristopherDedominici Oct 27, 2025
3047483
rename to hardhat-vendored
ChristopherDedominici Oct 27, 2025
c8ea036
exclude from gitignore
ChristopherDedominici Oct 27, 2025
39ce891
delete test file
ChristopherDedominici Oct 27, 2025
c6f1e72
remove dist folder
ChristopherDedominici Oct 27, 2025
f78a224
fix package name and imports
ChristopherDedominici Oct 27, 2025
b28430a
rename folder to avoid gitignore
ChristopherDedominici Oct 27, 2025
8c92ef9
fix copy-assets
ChristopherDedominici Oct 27, 2025
022c6ae
fix exports after changing folder name
ChristopherDedominici Oct 27, 2025
a50b3b8
show colored lines in coverage report
ChristopherDedominici Oct 27, 2025
0b89710
update tsconfig in new vendored package
ChristopherDedominici Oct 28, 2025
50f3b4c
minor fixes
ChristopherDedominici Oct 28, 2025
f3591e7
Merge branch 'main' of github.com:NomicFoundation/hardhat into html-c…
ChristopherDedominici Oct 28, 2025
d0fba8e
Merge branch 'main' of github.com:NomicFoundation/hardhat into html-c…
ChristopherDedominici Nov 3, 2025
3602408
lint:fix
ChristopherDedominici Nov 3, 2025
006f834
Create gorgeous-swans-try.md
ChristopherDedominici Nov 3, 2025
f771d34
ignore spelling in vendored package src code
ChristopherDedominici Nov 3, 2025
7724608
Merge branch 'html-coverage' of github.com:NomicFoundation/hardhat in…
ChristopherDedominici Nov 3, 2025
9dde2ee
remove dependency from @nomicfoundation/hardhat-node-test-reporter
ChristopherDedominici Nov 3, 2025
7542cdc
add reference to test reporter
ChristopherDedominici Nov 3, 2025
8ed50de
Merge branch 'html-coverage' of github.com:NomicFoundation/hardhat in…
ChristopherDedominici Nov 3, 2025
f264363
add hardhat-node-test-reporter in package.json
ChristopherDedominici Nov 3, 2025
b26e193
Merge branch 'main' of github.com:NomicFoundation/hardhat into html-c…
ChristopherDedominici Nov 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/gorgeous-swans-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@nomicfoundation/hardhat": minor
"@nomicfoundation/hardhat-vendored": patch
---

Added HTML coverage reporting and a new internal `hardhat-vendored` package ([7528](https://github.com/NomicFoundation/hardhat/pull/7528)).
1 change: 1 addition & 0 deletions cspell.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ ignorePaths:
- .github/config/regression-tests.yml
- archive/**
- pnpm-lock.yaml
- v-next/hardhat-vendored/src
39 changes: 39 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions v-next/hardhat-vendored/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Node modules
/node_modules

# Compilation output
/dist

# pnpm deploy output
/bundle

# test coverage output
coverage

# all the tmp folders in the fixture projects
/test/fixture-projects/tmp/
6 changes: 6 additions & 0 deletions v-next/hardhat-vendored/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/node_modules
/dist
/coverage
CHANGELOG.md
/test/fixture-projects/**/artifacts
/test/fixture-projects/**/cache
9 changes: 9 additions & 0 deletions v-next/hardhat-vendored/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MIT License

Copyright (c) 2025 Nomic Foundation

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
5 changes: 5 additions & 0 deletions v-next/hardhat-vendored/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# hardhat-vendored

> ⚠️ This package is an internal Hardhat component and it's not meant to be used directly.

This package contains vendored code used by Hardhat 3 and its plugins.
3 changes: 3 additions & 0 deletions v-next/hardhat-vendored/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { createConfig } from "../config/eslint.config.js";

export default createConfig(import.meta.filename, { onlyHardhatError: false });
57 changes: 57 additions & 0 deletions v-next/hardhat-vendored/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"name": "@nomicfoundation/hardhat-vendored",
"version": "3.0.0",
"description": "Internal dependencies used by Hardhat that have been vendored to prevent bloating the main package",
"homepage": "https://github.com/nomicfoundation/hardhat/tree/v-next/v-next/hardhat-vendored",
"repository": {
"type": "git",
"url": "https://github.com/NomicFoundation/hardhat",
"directory": "v-next/hardhat-vendored"
},
"author": "Nomic Foundation",
"license": "MIT",
"type": "module",
"exports": {
"./coverage": "./dist/src/coverage-module/index.js",
"./coverage/types": "./dist/src/coverage-module/types.js"
},
"keywords": [
"hardhat"
],
"scripts": {
"lint": "pnpm prettier --check && pnpm eslint",
"lint:fix": "pnpm prettier --write && pnpm eslint --fix",
"eslint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
"prettier": "prettier \"**/*.{ts,js,md,json}\"",
"test": "node --import tsx/esm --test --test-reporter=@nomicfoundation/hardhat-node-test-reporter \"test/*.ts\" \"test/!(fixture-projects|helpers)/**/*.ts\"",
"test:only": "node --import tsx/esm --test --test-only --test-reporter=@nomicfoundation/hardhat-node-test-reporter \"test/*.ts\" \"test/!(fixture-projects|helpers)/**/*.ts\"",
"test:coverage": "c8 --reporter html --reporter text --all --exclude test --exclude \"src/**/{types,type-extensions}.ts\" --src src node --import tsx/esm --test --test-reporter=@nomicfoundation/hardhat-node-test-reporter \"test/*.ts\" \"test/!(fixture-projects|helpers)/**/*.ts\"",
"pretest": "pnpm build",
"pretest:only": "pnpm build",
"build": "tsc --build .",
"postbuild": "node dist/src/copy-assets.js",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This step is required to copy the assets folder, which contains the CSS and JS files used to generate the report, into the dist folder after compilation

"prepublishOnly": "pnpm build",
"clean": "rimraf dist"
},
"files": [
"dist/src/",
"src/",
"CHANGELOG.md",
"LICENSE",
"README.md"
],
"devDependencies": {
"@nomicfoundation/hardhat-node-test-reporter": "workspace:^3.0.0",
"@types/bn.js": "^5.1.5",
"@types/debug": "^4.1.7",
"@types/node": "^20.14.9",
"c8": "^9.1.0",
"eslint": "9.25.1",
"expect-type": "^1.2.1",
"prettier": "3.2.5",
"rimraf": "^5.0.5",
"tsx": "^4.19.3",
"typescript": "~5.8.0"
},
"dependencies": {}
}
33 changes: 33 additions & 0 deletions v-next/hardhat-vendored/src/copy-assets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { cp } from "node:fs/promises";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function is invoked by the postbuild in the package.json file.

Used to copy the assets folder, which contains the CSS and JS files used to generate the report, into the dist folder after compilation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm open to better ideas to solve this issue

import path from "node:path";

async function copyFolder(from: string, to: string): Promise<void> {
const src = path.resolve(from);
const dest = path.resolve(to);

await cp(src, dest, { recursive: true, force: true });
console.log(`Copied folder from ${src} -> ${dest}`);
}

// eslint-disable-next-line no-restricted-syntax -- allow in this post build script
await copyFolder(
path.resolve(
process.cwd(),
"src",
"coverage-module",
"istanbul-reports",
"lib",
"html",
"assets",
),
path.resolve(
process.cwd(),
"dist",
"src",
"coverage-module",
"istanbul-reports",
"lib",
"html",
"assets",
),
);
24 changes: 24 additions & 0 deletions v-next/hardhat-vendored/src/coverage-module/html-escaper/index.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const { replace } = "";

// escape
const es = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g;
const ca = /[&<>'"]/g;

const esca = {
"&": "&amp;",
"<": "&lt;",
">": "&gt;",
"'": "&#39;",
'"': "&quot;",
};
const pe = (m) => esca[m];

/**
* Safely escape HTML entities such as `&`, `<`, `>`, `"`, and `'`.
* @param {string} es the input to safely escape
* @returns {string} the escaped input, and it **throws** an error if
* the input type is unexpected, except for boolean and numbers,
* converted as string.
*/
const escape = (es) => replace.call(es, ca, pe);
exports.escape = escape;
8 changes: 8 additions & 0 deletions v-next/hardhat-vendored/src/coverage-module/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import libCoverage from "./lib-coverage/index.cjs";
export { libCoverage };

import libReport from "./lib-report/index.cjs";
export { libReport };

import reports from "./istanbul-reports/index.cjs";
export { reports };
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"use strict";
/*
Copyright 2012-2015, Yahoo Inc.
Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
*/
const path = require("node:path");

module.exports = {
create(name, cfg) {
cfg = cfg || {};
let Cons;
try {
Cons = require(path.join(__dirname, "lib", name, "index.cjs"));
} catch (e) {
if (e.code !== "MODULE_NOT_FOUND") {
throw e;
}

Cons = require(name);
}

return new Cons(cfg);
},
};
Loading