From 8cfcf82764ef4cb8078ad18e00d4f2dc36840176 Mon Sep 17 00:00:00 2001 From: Claudio Wunder Date: Sun, 15 Feb 2026 01:25:32 +0100 Subject: [PATCH 1/4] meta: switch to minify-htm; fixed test glob on package.json; removed console.log --- .github/dependabot.yml | 2 +- npm-shrinkwrap.json | 271 ++++++------------ package.json | 12 +- src/generators/legacy-html-all/index.mjs | 4 +- src/generators/legacy-html/index.mjs | 4 +- src/generators/web/utils/processing.mjs | 4 +- .../configuration/__tests__/index.test.mjs | 2 - src/utils/queries/__tests__/index.test.mjs | 1 - 8 files changed, 93 insertions(+), 207 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 86f9a3f0..cffe51e8 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -62,7 +62,7 @@ updates: - 'recma-*' compiling: patterns: - - '@swc/html' + - '@minify-html/node' - '@rollup/*' - 'rolldown' - 'lightningcss' diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 4dc455ec..b22e4ca5 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -8,12 +8,12 @@ "dependencies": { "@actions/core": "^3.0.0", "@heroicons/react": "^2.2.0", + "@minify-html/node": "^0.18.1", "@node-core/rehype-shiki": "^1.4.0", "@node-core/ui-components": "^1.6.0", "@orama/orama": "^3.1.18", "@orama/ui": "^1.5.4", "@rollup/plugin-virtual": "^3.0.2", - "@swc/html": "^1.15.11", "acorn": "^8.15.0", "commander": "^14.0.2", "dedent": "^1.7.1", @@ -637,6 +637,85 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@minify-html/node": { + "version": "0.18.1", + "resolved": "https://registry.npmjs.org/@minify-html/node/-/node-0.18.1.tgz", + "integrity": "sha512-pNOv6z9zUDrjTU1+VcPOnDzGeaaqd6m9kbyHU+sg9O35450uzfke8ahx8gKlFdp/kQFrRn2rFIGAoANUZ62nSw==", + "license": "MIT", + "bin": { + "minify-html": "cli.js" + }, + "engines": { + "node": ">= 8.6.0" + }, + "optionalDependencies": { + "@minify-html/node-darwin-arm64": "0.18.1", + "@minify-html/node-darwin-x64": "0.18.1", + "@minify-html/node-linux-arm64": "0.18.1", + "@minify-html/node-linux-x64": "0.18.1", + "@minify-html/node-win32-x64": "0.18.1" + } + }, + "node_modules/@minify-html/node-darwin-arm64": { + "version": "0.18.1", + "resolved": "https://registry.npmjs.org/@minify-html/node-darwin-arm64/-/node-darwin-arm64-0.18.1.tgz", + "integrity": "sha512-sc/VJHRcHtEk0IQP2hRA/TWkAQntaYH3RCw8n750NbfzliQqkyrDqNAGiKBOli7UlhFtG/H2aWqGjtOjIM/dZA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@minify-html/node-darwin-x64": { + "version": "0.18.1", + "resolved": "https://registry.npmjs.org/@minify-html/node-darwin-x64/-/node-darwin-x64-0.18.1.tgz", + "integrity": "sha512-0bff2ng4Vgp3+kdC8zgjd5dMN04zkM4nGuYEVP4dLR7J5NCD/Ka4XD4CKNSDZ9goLYQ8BjtKD6AeDTfJ8KBjrA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@minify-html/node-linux-arm64": { + "version": "0.18.1", + "resolved": "https://registry.npmjs.org/@minify-html/node-linux-arm64/-/node-linux-arm64-0.18.1.tgz", + "integrity": "sha512-CVGu5XVmmDrGFuA9/b/695rJBFvfTZFwKJJYA1ZXAsBZrqlKVO4bfXPq9DVNmhQ76ky3LFtVZ/+UsU7xpyK5Qw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@minify-html/node-linux-x64": { + "version": "0.18.1", + "resolved": "https://registry.npmjs.org/@minify-html/node-linux-x64/-/node-linux-x64-0.18.1.tgz", + "integrity": "sha512-qmIv4kRyhZTKO3nXDXHlFrhnmwIKTM57ZRomlYRYdZTWiFW3CbJ4Ggg57qIgx7D/t4dgyS7/O8OTetrWvmEg9w==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@minify-html/node-win32-x64": { + "version": "0.18.1", + "resolved": "https://registry.npmjs.org/@minify-html/node-win32-x64/-/node-win32-x64-0.18.1.tgz", + "integrity": "sha512-SNRE/NvcKXvh4UwXTRrujNSWaCj/3E+FFN+FLOBaN4FY+dZG83h6nWxGHJ5+LAoJxVTU7Al1e8toi4JjHpzv2w==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ] + }, "node_modules/@napi-rs/nice": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@napi-rs/nice/-/nice-1.1.1.tgz", @@ -2429,196 +2508,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/@swc/counter": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/@swc/counter/-/counter-0.1.3.tgz", - "integrity": "sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==", - "license": "Apache-2.0" - }, - "node_modules/@swc/html": { - "version": "1.15.11", - "resolved": "https://registry.npmjs.org/@swc/html/-/html-1.15.11.tgz", - "integrity": "sha512-JOO48SCxyR3KbH9iiLMSWRDm7+Xl6lgvOBe5di54W8PsumdeP0Imatq8cunkRAUR7br8xAjlpB16bX6iJeyeMw==", - "license": "Apache-2.0", - "dependencies": { - "@swc/counter": "^0.1.3" - }, - "engines": { - "node": ">=14" - }, - "optionalDependencies": { - "@swc/html-darwin-arm64": "1.15.11", - "@swc/html-darwin-x64": "1.15.11", - "@swc/html-linux-arm-gnueabihf": "1.15.11", - "@swc/html-linux-arm64-gnu": "1.15.11", - "@swc/html-linux-arm64-musl": "1.15.11", - "@swc/html-linux-x64-gnu": "1.15.11", - "@swc/html-linux-x64-musl": "1.15.11", - "@swc/html-win32-arm64-msvc": "1.15.11", - "@swc/html-win32-ia32-msvc": "1.15.11", - "@swc/html-win32-x64-msvc": "1.15.11" - } - }, - "node_modules/@swc/html-darwin-arm64": { - "version": "1.15.11", - "resolved": "https://registry.npmjs.org/@swc/html-darwin-arm64/-/html-darwin-arm64-1.15.11.tgz", - "integrity": "sha512-FTa0ypbMbUXiwXIIT76HMFQYewEdTsPKOQGDqI6/kUTzU+lCIqIJequdoh6gqQvMq2BtBu/15dkTYYIlp4JoJw==", - "cpu": [ - "arm64" - ], - "license": "Apache-2.0 AND MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=10" - } - }, - "node_modules/@swc/html-darwin-x64": { - "version": "1.15.11", - "resolved": "https://registry.npmjs.org/@swc/html-darwin-x64/-/html-darwin-x64-1.15.11.tgz", - "integrity": "sha512-U+WFUFqbqS2WsLVCt40MuBGJ7mxDJi/T8RocBvQkoRwU3juOmeM2V/Od/QLBZxTFZTLQ3RCHJTkLXSDnxUWUuw==", - "cpu": [ - "x64" - ], - "license": "Apache-2.0 AND MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=10" - } - }, - "node_modules/@swc/html-linux-arm-gnueabihf": { - "version": "1.15.11", - "resolved": "https://registry.npmjs.org/@swc/html-linux-arm-gnueabihf/-/html-linux-arm-gnueabihf-1.15.11.tgz", - "integrity": "sha512-Cid64465sEkAiTh8KLFCbQbsIbgDzPeGdA5ZYB8w5AXmYAGPJ0xbeRHEFq3iq469Dj2rxYvExrLCXNhn8rHbww==", - "cpu": [ - "arm" - ], - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=10" - } - }, - "node_modules/@swc/html-linux-arm64-gnu": { - "version": "1.15.11", - "resolved": "https://registry.npmjs.org/@swc/html-linux-arm64-gnu/-/html-linux-arm64-gnu-1.15.11.tgz", - "integrity": "sha512-sxKdt0QJIR2x/6pAmDPK0tjfGVwsSZsfeY1BM8ODTm7h18ApE7KVNN+ZtsDbl4n5ejfXG7fOWNmMPUvj8qSMSA==", - "cpu": [ - "arm64" - ], - "license": "Apache-2.0 AND MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=10" - } - }, - "node_modules/@swc/html-linux-arm64-musl": { - "version": "1.15.11", - "resolved": "https://registry.npmjs.org/@swc/html-linux-arm64-musl/-/html-linux-arm64-musl-1.15.11.tgz", - "integrity": "sha512-aNACh2/HPy52VbKPqHieVRDeKzkO66DQdlhiVUi+fggdn8khvllni6Xr52INeAMjYFASrTTth/3vKXMv215t3A==", - "cpu": [ - "arm64" - ], - "license": "Apache-2.0 AND MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=10" - } - }, - "node_modules/@swc/html-linux-x64-gnu": { - "version": "1.15.11", - "resolved": "https://registry.npmjs.org/@swc/html-linux-x64-gnu/-/html-linux-x64-gnu-1.15.11.tgz", - "integrity": "sha512-8YOar0XeRLBzA+UMMW5smGpsQamoZLtaQ5RKGfap21FxOUUXqkPhkDTRr+kBVCYb47yz3NokjTPaDGTWOYNyww==", - "cpu": [ - "x64" - ], - "license": "Apache-2.0 AND MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=10" - } - }, - "node_modules/@swc/html-linux-x64-musl": { - "version": "1.15.11", - "resolved": "https://registry.npmjs.org/@swc/html-linux-x64-musl/-/html-linux-x64-musl-1.15.11.tgz", - "integrity": "sha512-em2Ur0uGFA/nw2JbMclXu9mLuUC7q/1J06i8FZTRHqZzNGt9Q0UMdgH9T8HkGLT5e7dZ6ROJoq1H4st6B8N3uw==", - "cpu": [ - "x64" - ], - "license": "Apache-2.0 AND MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=10" - } - }, - "node_modules/@swc/html-win32-arm64-msvc": { - "version": "1.15.11", - "resolved": "https://registry.npmjs.org/@swc/html-win32-arm64-msvc/-/html-win32-arm64-msvc-1.15.11.tgz", - "integrity": "sha512-Xf9Vd4UsYTs4ejBwS+j9zShkyp3KQ+qfn/ZKVMKDygWjuOjU6FFXWYm93/PdTmS5qD0c58FhmoqTv+uFEZ4nxQ==", - "cpu": [ - "arm64" - ], - "license": "Apache-2.0 AND MIT", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=10" - } - }, - "node_modules/@swc/html-win32-ia32-msvc": { - "version": "1.15.11", - "resolved": "https://registry.npmjs.org/@swc/html-win32-ia32-msvc/-/html-win32-ia32-msvc-1.15.11.tgz", - "integrity": "sha512-+YNzKR81UqH+xOZPU8XEIy5L6E63UUGSSEu1Wv3D85GVMQkZ8X9LZkZ5hq4vvqmCTV1zeHIPfzNrrVElqK198g==", - "cpu": [ - "ia32" - ], - "license": "Apache-2.0 AND MIT", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=10" - } - }, - "node_modules/@swc/html-win32-x64-msvc": { - "version": "1.15.11", - "resolved": "https://registry.npmjs.org/@swc/html-win32-x64-msvc/-/html-win32-x64-msvc-1.15.11.tgz", - "integrity": "sha512-Y3Xj62eA+pjadhgiVNFUBgIN9Wa1gYrB3N1l6NmSLeApVE2qkBww3WrVXhRDfqUXiWz7eRHPDakZSRQREyMv5A==", - "cpu": [ - "x64" - ], - "license": "Apache-2.0 AND MIT", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=10" - } - }, "node_modules/@tailwindcss/node": { "version": "4.1.18", "resolved": "https://registry.npmjs.org/@tailwindcss/node/-/node-4.1.18.tgz", diff --git a/package.json b/package.json index d81ffbc2..b53ef963 100644 --- a/package.json +++ b/package.json @@ -10,11 +10,11 @@ "format": "prettier .", "format:write": "prettier --write .", "format:check": "prettier --check .", - "test": "node --test --experimental-test-module-mocks", - "test:coverage": "c8 npm test", - "test:ci": "c8 --reporter=lcov node --test --experimental-test-module-mocks --test-reporter=@reporters/github --test-reporter-destination=stdout --test-reporter=junit --test-reporter-destination=junit.xml --test-reporter=spec --test-reporter-destination=stdout", - "test:update-snapshots": "node --test --experimental-test-module-mocks --test-update-snapshots", - "test:watch": "node --test --experimental-test-module-mocks --watch", + "test": "node --test --experimental-test-module-mocks 'src/**/*.test.mjs'", + "test:coverage": "c8 node --test --experimental-test-module-mocks 'src/**/*.test.mjs'", + "test:ci": "c8 --reporter=lcov node --test --experimental-test-module-mocks 'src/**/*.test.mjs' --test-reporter=@reporters/github --test-reporter-destination=stdout --test-reporter=junit --test-reporter-destination=junit.xml --test-reporter=spec --test-reporter-destination=stdout", + "test:update-snapshots": "node --test --experimental-test-module-mocks --test-update-snapshots 'src/**/*.test.mjs'", + "test:watch": "node --test --experimental-test-module-mocks --watch 'src/**/*.test.mjs'", "prepare": "husky || exit 0", "run": "node bin/cli.mjs", "watch": "node --watch bin/cli.mjs" @@ -42,12 +42,12 @@ "dependencies": { "@actions/core": "^3.0.0", "@heroicons/react": "^2.2.0", + "@minify-html/node": "^0.18.1", "@node-core/rehype-shiki": "^1.4.0", "@node-core/ui-components": "^1.6.0", "@orama/orama": "^3.1.18", "@orama/ui": "^1.5.4", "@rollup/plugin-virtual": "^3.0.2", - "@swc/html": "^1.15.11", "acorn": "^8.15.0", "commander": "^14.0.2", "dedent": "^1.7.1", diff --git a/src/generators/legacy-html-all/index.mjs b/src/generators/legacy-html-all/index.mjs index 051eead9..e50fa33d 100644 --- a/src/generators/legacy-html-all/index.mjs +++ b/src/generators/legacy-html-all/index.mjs @@ -3,7 +3,7 @@ import { readFile, writeFile } from 'node:fs/promises'; import { join } from 'node:path'; -import { minify } from '@swc/html'; +import minifyHtml from '@minify-html/node'; import getConfig from '../../utils/configuration/index.mjs'; import { getRemarkRehype } from '../../utils/remark.mjs'; @@ -86,7 +86,7 @@ export default { }); if (config.minify) { - ({ code: result } = await minify(result)); + result = Buffer.from(minifyHtml.minify(Buffer.from(result), {})); } if (config.output) { diff --git a/src/generators/legacy-html/index.mjs b/src/generators/legacy-html/index.mjs index 8a33bccd..a0e4ea4f 100644 --- a/src/generators/legacy-html/index.mjs +++ b/src/generators/legacy-html/index.mjs @@ -3,7 +3,7 @@ import { readFile, writeFile, mkdir } from 'node:fs/promises'; import { basename, join } from 'node:path'; -import { minify } from '@swc/html'; +import minifyHtml from '@minify-html/node'; import buildContent from './utils/buildContent.mjs'; import { replaceTemplateValues } from './utils/replaceTemplateValues.mjs'; @@ -159,7 +159,7 @@ export default { let result = replaceTemplateValues(apiTemplate, template, config); if (config.minify) { - ({ code: result } = await minify(result)); + result = Buffer.from(minifyHtml.minify(Buffer.from(result), {})); } await writeFile(join(config.output, `${template.api}.html`), result); diff --git a/src/generators/web/utils/processing.mjs b/src/generators/web/utils/processing.mjs index 5508edc5..422596b7 100644 --- a/src/generators/web/utils/processing.mjs +++ b/src/generators/web/utils/processing.mjs @@ -1,6 +1,6 @@ import { randomUUID } from 'node:crypto'; -import { minifySync } from '@swc/html'; +import minifyHtml from '@minify-html/node'; import { jsx, toJs } from 'estree-util-to-js'; import { transform } from 'lightningcss'; @@ -123,7 +123,7 @@ export async function processJSXEntries( .replace('{{ogTitle}}', title); // Minify HTML (input must be a Buffer) - const { code: html } = minifySync(renderedHtml); + const html = Buffer.from(minifyHtml.minify(Buffer.from(renderedHtml), {})); return { html, api }; }); diff --git a/src/utils/configuration/__tests__/index.test.mjs b/src/utils/configuration/__tests__/index.test.mjs index f6f3c43c..293a468f 100644 --- a/src/utils/configuration/__tests__/index.test.mjs +++ b/src/utils/configuration/__tests__/index.test.mjs @@ -137,8 +137,6 @@ describe('config.mjs', () => { threads: 2, }); - console.log(config); - assert.strictEqual(config.global.input, 'custom-src/'); assert.strictEqual(config.global.output, 'custom-dist/'); assert.strictEqual(config.threads, 2); diff --git a/src/utils/queries/__tests__/index.test.mjs b/src/utils/queries/__tests__/index.test.mjs index 5a435487..a0e580a3 100644 --- a/src/utils/queries/__tests__/index.test.mjs +++ b/src/utils/queries/__tests__/index.test.mjs @@ -89,7 +89,6 @@ describe('createQueries', () => { }, ]; - console.log(node, definitions); queries.updateLinkReference(node, definitions); strictEqual(node.type, 'link'); From 6e3a4c4b6901daca962bd67555187c86f78c1070 Mon Sep 17 00:00:00 2001 From: Claudio Wunder Date: Sun, 15 Feb 2026 17:28:39 +0100 Subject: [PATCH 2/4] chore: use terser --- .github/dependabot.yml | 2 +- npm-shrinkwrap.json | 262 ++++++++++++++++------- package.json | 2 +- src/generators/legacy-html-all/index.mjs | 5 +- src/generators/legacy-html/index.mjs | 5 +- src/generators/web/utils/processing.mjs | 42 ++-- src/utils/html-minifier.mjs | 21 ++ 7 files changed, 231 insertions(+), 108 deletions(-) create mode 100644 src/utils/html-minifier.mjs diff --git a/.github/dependabot.yml b/.github/dependabot.yml index cffe51e8..27f99161 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -62,7 +62,7 @@ updates: - 'recma-*' compiling: patterns: - - '@minify-html/node' + - 'html-minifier-terser' - '@rollup/*' - 'rolldown' - 'lightningcss' diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index b22e4ca5..09bbb7cd 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -8,7 +8,6 @@ "dependencies": { "@actions/core": "^3.0.0", "@heroicons/react": "^2.2.0", - "@minify-html/node": "^0.18.1", "@node-core/rehype-shiki": "^1.4.0", "@node-core/ui-components": "^1.6.0", "@orama/orama": "^3.1.18", @@ -23,6 +22,7 @@ "globals": "^17.2.0", "hast-util-to-string": "^3.0.1", "hastscript": "^9.0.1", + "html-minifier-terser": "^7.2.0", "lightningcss": "^1.31.1", "mdast-util-slice-markdown": "^2.0.1", "piscina": "^5.1.4", @@ -621,6 +621,16 @@ "node": ">=6.0.0" } }, + "node_modules/@jridgewell/source-map": { + "version": "0.3.11", + "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.11.tgz", + "integrity": "sha512-ZMp1V8ZFcPG5dIWnQLr3NSI1MiCU7UETdS/A0G8V/XWHvJv3ZsFqutJn1Y5RPmAPX6F3BiE397OqveU/9NCuIA==", + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.25" + } + }, "node_modules/@jridgewell/sourcemap-codec": { "version": "1.5.5", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", @@ -637,85 +647,6 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, - "node_modules/@minify-html/node": { - "version": "0.18.1", - "resolved": "https://registry.npmjs.org/@minify-html/node/-/node-0.18.1.tgz", - "integrity": "sha512-pNOv6z9zUDrjTU1+VcPOnDzGeaaqd6m9kbyHU+sg9O35450uzfke8ahx8gKlFdp/kQFrRn2rFIGAoANUZ62nSw==", - "license": "MIT", - "bin": { - "minify-html": "cli.js" - }, - "engines": { - "node": ">= 8.6.0" - }, - "optionalDependencies": { - "@minify-html/node-darwin-arm64": "0.18.1", - "@minify-html/node-darwin-x64": "0.18.1", - "@minify-html/node-linux-arm64": "0.18.1", - "@minify-html/node-linux-x64": "0.18.1", - "@minify-html/node-win32-x64": "0.18.1" - } - }, - "node_modules/@minify-html/node-darwin-arm64": { - "version": "0.18.1", - "resolved": "https://registry.npmjs.org/@minify-html/node-darwin-arm64/-/node-darwin-arm64-0.18.1.tgz", - "integrity": "sha512-sc/VJHRcHtEk0IQP2hRA/TWkAQntaYH3RCw8n750NbfzliQqkyrDqNAGiKBOli7UlhFtG/H2aWqGjtOjIM/dZA==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "darwin" - ] - }, - "node_modules/@minify-html/node-darwin-x64": { - "version": "0.18.1", - "resolved": "https://registry.npmjs.org/@minify-html/node-darwin-x64/-/node-darwin-x64-0.18.1.tgz", - "integrity": "sha512-0bff2ng4Vgp3+kdC8zgjd5dMN04zkM4nGuYEVP4dLR7J5NCD/Ka4XD4CKNSDZ9goLYQ8BjtKD6AeDTfJ8KBjrA==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "darwin" - ] - }, - "node_modules/@minify-html/node-linux-arm64": { - "version": "0.18.1", - "resolved": "https://registry.npmjs.org/@minify-html/node-linux-arm64/-/node-linux-arm64-0.18.1.tgz", - "integrity": "sha512-CVGu5XVmmDrGFuA9/b/695rJBFvfTZFwKJJYA1ZXAsBZrqlKVO4bfXPq9DVNmhQ76ky3LFtVZ/+UsU7xpyK5Qw==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@minify-html/node-linux-x64": { - "version": "0.18.1", - "resolved": "https://registry.npmjs.org/@minify-html/node-linux-x64/-/node-linux-x64-0.18.1.tgz", - "integrity": "sha512-qmIv4kRyhZTKO3nXDXHlFrhnmwIKTM57ZRomlYRYdZTWiFW3CbJ4Ggg57qIgx7D/t4dgyS7/O8OTetrWvmEg9w==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@minify-html/node-win32-x64": { - "version": "0.18.1", - "resolved": "https://registry.npmjs.org/@minify-html/node-win32-x64/-/node-win32-x64-0.18.1.tgz", - "integrity": "sha512-SNRE/NvcKXvh4UwXTRrujNSWaCj/3E+FFN+FLOBaN4FY+dZG83h6nWxGHJ5+LAoJxVTU7Al1e8toi4JjHpzv2w==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "win32" - ] - }, "node_modules/@napi-rs/nice": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@napi-rs/nice/-/nice-1.1.1.tgz", @@ -3881,6 +3812,12 @@ "node": ">=8" } }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "license": "MIT" + }, "node_modules/c8": { "version": "10.1.3", "resolved": "https://registry.npmjs.org/c8/-/c8-10.1.3.tgz", @@ -3925,6 +3862,16 @@ "node": ">=6" } }, + "node_modules/camel-case": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/camel-case/-/camel-case-4.1.2.tgz", + "integrity": "sha512-gxGWBrTT1JuMx6R+o5PTXMmUnhnVzLQ9SNutD4YqKtI6ap897t3tKECYla6gCWEkplXnlNybEkZg9GEGxKFCgw==", + "license": "MIT", + "dependencies": { + "pascal-case": "^3.1.2", + "tslib": "^2.0.3" + } + }, "node_modules/ccount": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/ccount/-/ccount-2.0.1.tgz", @@ -3998,6 +3945,18 @@ "integrity": "sha512-saHYOzhIQs6wy2sVxTM6bUDsQO4F50V9RQ22qBpEdCW+I+/Wmke2HOl6lS6dTpdxVhb88/I6+Hs+438c3lfUow==", "license": "MIT" }, + "node_modules/clean-css": { + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-5.3.3.tgz", + "integrity": "sha512-D5J+kHaVb/wKSFcyyV75uCn8fiY4sV38XJoe4CUyGQ+mOU/fMVYUdH1hJC+CJQ5uY3EnW27SbJYS4X8BiLrAFg==", + "license": "MIT", + "dependencies": { + "source-map": "~0.6.0" + }, + "engines": { + "node": ">= 10.0" + } + }, "node_modules/cli-cursor": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-5.0.0.tgz", @@ -4349,6 +4308,16 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/dot-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/dot-case/-/dot-case-3.0.4.tgz", + "integrity": "sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==", + "license": "MIT", + "dependencies": { + "no-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, "node_modules/eastasianwidth": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", @@ -5326,6 +5295,48 @@ "dev": true, "license": "MIT" }, + "node_modules/html-minifier-terser": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/html-minifier-terser/-/html-minifier-terser-7.2.0.tgz", + "integrity": "sha512-tXgn3QfqPIpGl9o+K5tpcj3/MN4SfLtsx2GWwBC3SSd0tXQGyF3gsSqad8loJgKZGM3ZxbYDd5yhiBIdWpmvLA==", + "license": "MIT", + "dependencies": { + "camel-case": "^4.1.2", + "clean-css": "~5.3.2", + "commander": "^10.0.0", + "entities": "^4.4.0", + "param-case": "^3.0.4", + "relateurl": "^0.2.7", + "terser": "^5.15.1" + }, + "bin": { + "html-minifier-terser": "cli.js" + }, + "engines": { + "node": "^14.13.1 || >=16.0.0" + } + }, + "node_modules/html-minifier-terser/node_modules/commander": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-10.0.1.tgz", + "integrity": "sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==", + "license": "MIT", + "engines": { + "node": ">=14" + } + }, + "node_modules/html-minifier-terser/node_modules/entities": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, "node_modules/html-url-attributes": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/html-url-attributes/-/html-url-attributes-3.0.1.tgz", @@ -6121,6 +6132,15 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/lower-case": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz", + "integrity": "sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==", + "license": "MIT", + "dependencies": { + "tslib": "^2.0.3" + } + }, "node_modules/magic-string": { "version": "0.30.21", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", @@ -7114,6 +7134,16 @@ "dev": true, "license": "MIT" }, + "node_modules/no-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.4.tgz", + "integrity": "sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==", + "license": "MIT", + "dependencies": { + "lower-case": "^2.0.2", + "tslib": "^2.0.3" + } + }, "node_modules/nth-check": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz", @@ -7223,6 +7253,16 @@ "dev": true, "license": "BlueOak-1.0.0" }, + "node_modules/param-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/param-case/-/param-case-3.0.4.tgz", + "integrity": "sha512-RXlj7zCYokReqWpOPH9oYivUzLYZ5vAPIfEmCTNViosC78F8F0H9y7T7gG2M39ymgutxF5gcFEsyZQSph9Bp3A==", + "license": "MIT", + "dependencies": { + "dot-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, "node_modules/parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -7290,6 +7330,16 @@ "url": "https://github.com/inikulin/parse5?sponsor=1" } }, + "node_modules/pascal-case": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/pascal-case/-/pascal-case-3.1.2.tgz", + "integrity": "sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==", + "license": "MIT", + "dependencies": { + "no-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -7745,6 +7795,15 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/relateurl": { + "version": "0.2.7", + "resolved": "https://registry.npmjs.org/relateurl/-/relateurl-0.2.7.tgz", + "integrity": "sha512-G08Dxvm4iDN3MLM0EsP62EDV9IuhXPR6blNz6Utcp7zyV3tr4HVNINt6MpaRWbxoOHT3Q7YN2P+jaHX8vUbgog==", + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, "node_modules/remark-gfm": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/remark-gfm/-/remark-gfm-4.0.1.tgz", @@ -8029,6 +8088,15 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/source-map-js": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", @@ -8038,6 +8106,16 @@ "node": ">=0.10.0" } }, + "node_modules/source-map-support": { + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "license": "MIT", + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, "node_modules/space-separated-tokens": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-2.0.2.tgz", @@ -8326,6 +8404,30 @@ "url": "https://opencollective.com/webpack" } }, + "node_modules/terser": { + "version": "5.46.0", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.46.0.tgz", + "integrity": "sha512-jTwoImyr/QbOWFFso3YoU3ik0jBBDJ6JTOQiy/J2YxVJdZCc+5u7skhNwiOR3FQIygFqVUPHl7qbbxtjW2K3Qg==", + "license": "BSD-2-Clause", + "dependencies": { + "@jridgewell/source-map": "^0.3.3", + "acorn": "^8.15.0", + "commander": "^2.20.0", + "source-map-support": "~0.5.20" + }, + "bin": { + "terser": "bin/terser" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/terser/node_modules/commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "license": "MIT" + }, "node_modules/test-exclude": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-7.0.1.tgz", diff --git a/package.json b/package.json index b53ef963..fcba1304 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,6 @@ "dependencies": { "@actions/core": "^3.0.0", "@heroicons/react": "^2.2.0", - "@minify-html/node": "^0.18.1", "@node-core/rehype-shiki": "^1.4.0", "@node-core/ui-components": "^1.6.0", "@orama/orama": "^3.1.18", @@ -57,6 +56,7 @@ "globals": "^17.2.0", "hast-util-to-string": "^3.0.1", "hastscript": "^9.0.1", + "html-minifier-terser": "^7.2.0", "lightningcss": "^1.31.1", "mdast-util-slice-markdown": "^2.0.1", "piscina": "^5.1.4", diff --git a/src/generators/legacy-html-all/index.mjs b/src/generators/legacy-html-all/index.mjs index e50fa33d..96e2808e 100644 --- a/src/generators/legacy-html-all/index.mjs +++ b/src/generators/legacy-html-all/index.mjs @@ -3,9 +3,8 @@ import { readFile, writeFile } from 'node:fs/promises'; import { join } from 'node:path'; -import minifyHtml from '@minify-html/node'; - import getConfig from '../../utils/configuration/index.mjs'; +import { minifyHTML } from '../../utils/html-minifier.mjs'; import { getRemarkRehype } from '../../utils/remark.mjs'; import legacyHtml from '../legacy-html/index.mjs'; import { replaceTemplateValues } from '../legacy-html/utils/replaceTemplateValues.mjs'; @@ -86,7 +85,7 @@ export default { }); if (config.minify) { - result = Buffer.from(minifyHtml.minify(Buffer.from(result), {})); + result = Buffer.from(await minifyHTML(result)); } if (config.output) { diff --git a/src/generators/legacy-html/index.mjs b/src/generators/legacy-html/index.mjs index a0e4ea4f..d647fe08 100644 --- a/src/generators/legacy-html/index.mjs +++ b/src/generators/legacy-html/index.mjs @@ -3,14 +3,13 @@ import { readFile, writeFile, mkdir } from 'node:fs/promises'; import { basename, join } from 'node:path'; -import minifyHtml from '@minify-html/node'; - import buildContent from './utils/buildContent.mjs'; import { replaceTemplateValues } from './utils/replaceTemplateValues.mjs'; import { safeCopy } from './utils/safeCopy.mjs'; import tableOfContents from './utils/tableOfContents.mjs'; import getConfig from '../../utils/configuration/index.mjs'; import { groupNodesByModule } from '../../utils/generators.mjs'; +import { minifyHTML } from '../../utils/html-minifier.mjs'; import { getRemarkRehypeWithShiki } from '../../utils/remark.mjs'; /** @@ -159,7 +158,7 @@ export default { let result = replaceTemplateValues(apiTemplate, template, config); if (config.minify) { - result = Buffer.from(minifyHtml.minify(Buffer.from(result), {})); + result = Buffer.from(await minifyHTML(result)); } await writeFile(join(config.output, `${template.api}.html`), result); diff --git a/src/generators/web/utils/processing.mjs b/src/generators/web/utils/processing.mjs index 422596b7..e1c4d46a 100644 --- a/src/generators/web/utils/processing.mjs +++ b/src/generators/web/utils/processing.mjs @@ -1,12 +1,12 @@ import { randomUUID } from 'node:crypto'; -import minifyHtml from '@minify-html/node'; import { jsx, toJs } from 'estree-util-to-js'; import { transform } from 'lightningcss'; -import { SPECULATION_RULES } from '../constants.mjs'; import bundleCode from './bundle.mjs'; import { createChunkedRequire } from './chunks.mjs'; +import { minifyHTML } from '../../../utils/html-minifier.mjs'; +import { SPECULATION_RULES } from '../constants.mjs'; /** * Converts JSX AST entries to server and client JavaScript code. @@ -109,24 +109,26 @@ export async function processJSXEntries( const titleSuffix = `Node.js v${version.version} Documentation`; // Step 3: Create final HTML (could be parallelized in workers) - const results = entries.map(({ data: { api, heading } }) => { - const fileName = `${api}.js`; - const title = `${heading.data.name} | ${titleSuffix}`; - - // Replace template placeholders with actual content - const renderedHtml = template - .replace('{{title}}', title) - .replace('{{dehydrated}}', serverBundle.pages.get(fileName) ?? '') - .replace('{{importMap}}', clientBundle.importMap ?? '') - .replace('{{entrypoint}}', `./${fileName}?${randomUUID()}`) - .replace('{{speculationRules}}', SPECULATION_RULES) - .replace('{{ogTitle}}', title); - - // Minify HTML (input must be a Buffer) - const html = Buffer.from(minifyHtml.minify(Buffer.from(renderedHtml), {})); - - return { html, api }; - }); + const results = await Promise.all( + entries.map(async ({ data: { api, heading } }) => { + const fileName = `${api}.js`; + const title = `${heading.data.name} | ${titleSuffix}`; + + // Replace template placeholders with actual content + const renderedHtml = template + .replace('{{title}}', title) + .replace('{{dehydrated}}', serverBundle.pages.get(fileName) ?? '') + .replace('{{importMap}}', clientBundle.importMap ?? '') + .replace('{{entrypoint}}', `./${fileName}?${randomUUID()}`) + .replace('{{speculationRules}}', SPECULATION_RULES) + .replace('{{ogTitle}}', title); + + const minifiedHtml = await minifyHTML(renderedHtml); + const html = Buffer.from(minifiedHtml); + + return { html, api }; + }) + ); const { code: minifiedCSS } = transform({ code: Buffer.from(`${serverBundle.css}\n${clientBundle.css}`), diff --git a/src/utils/html-minifier.mjs b/src/utils/html-minifier.mjs new file mode 100644 index 00000000..750823a9 --- /dev/null +++ b/src/utils/html-minifier.mjs @@ -0,0 +1,21 @@ +import { minify } from 'html-minifier-terser'; + +const DEFAULT_HTML_MINIFIER_OPTIONS = { + collapseWhitespace: true, + conservativeCollapse: true, + minifyCSS: true, + removeComments: true, + removeRedundantAttributes: true, + removeScriptTypeAttributes: true, + removeStyleLinkTypeAttributes: true, + useShortDoctype: true, +}; + +/** + * Minifies HTML with project defaults and optional overrides. + * + * @param {string} html + * @param {import('html-minifier-terser').Options} [overrides] + */ +export const minifyHTML = (html, overrides = {}) => + minify(html, { ...DEFAULT_HTML_MINIFIER_OPTIONS, ...overrides }); From 30c10d13cfc2a65aaa2ade021e12436fb030cb2f Mon Sep 17 00:00:00 2001 From: Claudio Wunder Date: Sun, 15 Feb 2026 17:32:57 +0100 Subject: [PATCH 3/4] chore: use @minify-html/wasm --- .github/dependabot.yml | 2 +- npm-shrinkwrap.json | 189 ++---------------------------------- package.json | 2 +- src/utils/html-minifier.mjs | 27 +++--- 4 files changed, 24 insertions(+), 196 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 27f99161..fed4ef6d 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -62,7 +62,7 @@ updates: - 'recma-*' compiling: patterns: - - 'html-minifier-terser' + - '@minify-html/wasm' - '@rollup/*' - 'rolldown' - 'lightningcss' diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 09bbb7cd..13e7e66a 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -8,6 +8,7 @@ "dependencies": { "@actions/core": "^3.0.0", "@heroicons/react": "^2.2.0", + "@minify-html/wasm": "^0.18.1", "@node-core/rehype-shiki": "^1.4.0", "@node-core/ui-components": "^1.6.0", "@orama/orama": "^3.1.18", @@ -22,7 +23,6 @@ "globals": "^17.2.0", "hast-util-to-string": "^3.0.1", "hastscript": "^9.0.1", - "html-minifier-terser": "^7.2.0", "lightningcss": "^1.31.1", "mdast-util-slice-markdown": "^2.0.1", "piscina": "^5.1.4", @@ -621,16 +621,6 @@ "node": ">=6.0.0" } }, - "node_modules/@jridgewell/source-map": { - "version": "0.3.11", - "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.11.tgz", - "integrity": "sha512-ZMp1V8ZFcPG5dIWnQLr3NSI1MiCU7UETdS/A0G8V/XWHvJv3ZsFqutJn1Y5RPmAPX6F3BiE397OqveU/9NCuIA==", - "license": "MIT", - "dependencies": { - "@jridgewell/gen-mapping": "^0.3.5", - "@jridgewell/trace-mapping": "^0.3.25" - } - }, "node_modules/@jridgewell/sourcemap-codec": { "version": "1.5.5", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", @@ -647,6 +637,12 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@minify-html/wasm": { + "version": "0.18.1", + "resolved": "https://registry.npmjs.org/@minify-html/wasm/-/wasm-0.18.1.tgz", + "integrity": "sha512-GBkBOJxe7duO+z2b00SP83EewOI+Qm4MsnajXHw4yT7/J+TuG3jLEatBHKnT59Zq4CgXBRpdkv/2hlCGnyqAzg==", + "license": "MIT" + }, "node_modules/@napi-rs/nice": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@napi-rs/nice/-/nice-1.1.1.tgz", @@ -3812,12 +3808,6 @@ "node": ">=8" } }, - "node_modules/buffer-from": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", - "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", - "license": "MIT" - }, "node_modules/c8": { "version": "10.1.3", "resolved": "https://registry.npmjs.org/c8/-/c8-10.1.3.tgz", @@ -3862,16 +3852,6 @@ "node": ">=6" } }, - "node_modules/camel-case": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/camel-case/-/camel-case-4.1.2.tgz", - "integrity": "sha512-gxGWBrTT1JuMx6R+o5PTXMmUnhnVzLQ9SNutD4YqKtI6ap897t3tKECYla6gCWEkplXnlNybEkZg9GEGxKFCgw==", - "license": "MIT", - "dependencies": { - "pascal-case": "^3.1.2", - "tslib": "^2.0.3" - } - }, "node_modules/ccount": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/ccount/-/ccount-2.0.1.tgz", @@ -3945,18 +3925,6 @@ "integrity": "sha512-saHYOzhIQs6wy2sVxTM6bUDsQO4F50V9RQ22qBpEdCW+I+/Wmke2HOl6lS6dTpdxVhb88/I6+Hs+438c3lfUow==", "license": "MIT" }, - "node_modules/clean-css": { - "version": "5.3.3", - "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-5.3.3.tgz", - "integrity": "sha512-D5J+kHaVb/wKSFcyyV75uCn8fiY4sV38XJoe4CUyGQ+mOU/fMVYUdH1hJC+CJQ5uY3EnW27SbJYS4X8BiLrAFg==", - "license": "MIT", - "dependencies": { - "source-map": "~0.6.0" - }, - "engines": { - "node": ">= 10.0" - } - }, "node_modules/cli-cursor": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-5.0.0.tgz", @@ -4308,16 +4276,6 @@ "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/dot-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/dot-case/-/dot-case-3.0.4.tgz", - "integrity": "sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==", - "license": "MIT", - "dependencies": { - "no-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, "node_modules/eastasianwidth": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", @@ -5295,48 +5253,6 @@ "dev": true, "license": "MIT" }, - "node_modules/html-minifier-terser": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/html-minifier-terser/-/html-minifier-terser-7.2.0.tgz", - "integrity": "sha512-tXgn3QfqPIpGl9o+K5tpcj3/MN4SfLtsx2GWwBC3SSd0tXQGyF3gsSqad8loJgKZGM3ZxbYDd5yhiBIdWpmvLA==", - "license": "MIT", - "dependencies": { - "camel-case": "^4.1.2", - "clean-css": "~5.3.2", - "commander": "^10.0.0", - "entities": "^4.4.0", - "param-case": "^3.0.4", - "relateurl": "^0.2.7", - "terser": "^5.15.1" - }, - "bin": { - "html-minifier-terser": "cli.js" - }, - "engines": { - "node": "^14.13.1 || >=16.0.0" - } - }, - "node_modules/html-minifier-terser/node_modules/commander": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-10.0.1.tgz", - "integrity": "sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==", - "license": "MIT", - "engines": { - "node": ">=14" - } - }, - "node_modules/html-minifier-terser/node_modules/entities": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", - "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", - "license": "BSD-2-Clause", - "engines": { - "node": ">=0.12" - }, - "funding": { - "url": "https://github.com/fb55/entities?sponsor=1" - } - }, "node_modules/html-url-attributes": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/html-url-attributes/-/html-url-attributes-3.0.1.tgz", @@ -6132,15 +6048,6 @@ "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/lower-case": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz", - "integrity": "sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==", - "license": "MIT", - "dependencies": { - "tslib": "^2.0.3" - } - }, "node_modules/magic-string": { "version": "0.30.21", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", @@ -7134,16 +7041,6 @@ "dev": true, "license": "MIT" }, - "node_modules/no-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.4.tgz", - "integrity": "sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==", - "license": "MIT", - "dependencies": { - "lower-case": "^2.0.2", - "tslib": "^2.0.3" - } - }, "node_modules/nth-check": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz", @@ -7253,16 +7150,6 @@ "dev": true, "license": "BlueOak-1.0.0" }, - "node_modules/param-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/param-case/-/param-case-3.0.4.tgz", - "integrity": "sha512-RXlj7zCYokReqWpOPH9oYivUzLYZ5vAPIfEmCTNViosC78F8F0H9y7T7gG2M39ymgutxF5gcFEsyZQSph9Bp3A==", - "license": "MIT", - "dependencies": { - "dot-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, "node_modules/parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -7330,16 +7217,6 @@ "url": "https://github.com/inikulin/parse5?sponsor=1" } }, - "node_modules/pascal-case": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/pascal-case/-/pascal-case-3.1.2.tgz", - "integrity": "sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==", - "license": "MIT", - "dependencies": { - "no-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -7795,15 +7672,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/relateurl": { - "version": "0.2.7", - "resolved": "https://registry.npmjs.org/relateurl/-/relateurl-0.2.7.tgz", - "integrity": "sha512-G08Dxvm4iDN3MLM0EsP62EDV9IuhXPR6blNz6Utcp7zyV3tr4HVNINt6MpaRWbxoOHT3Q7YN2P+jaHX8vUbgog==", - "license": "MIT", - "engines": { - "node": ">= 0.10" - } - }, "node_modules/remark-gfm": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/remark-gfm/-/remark-gfm-4.0.1.tgz", @@ -8088,15 +7956,6 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "license": "BSD-3-Clause", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/source-map-js": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", @@ -8106,16 +7965,6 @@ "node": ">=0.10.0" } }, - "node_modules/source-map-support": { - "version": "0.5.21", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", - "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", - "license": "MIT", - "dependencies": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - } - }, "node_modules/space-separated-tokens": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-2.0.2.tgz", @@ -8404,30 +8253,6 @@ "url": "https://opencollective.com/webpack" } }, - "node_modules/terser": { - "version": "5.46.0", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.46.0.tgz", - "integrity": "sha512-jTwoImyr/QbOWFFso3YoU3ik0jBBDJ6JTOQiy/J2YxVJdZCc+5u7skhNwiOR3FQIygFqVUPHl7qbbxtjW2K3Qg==", - "license": "BSD-2-Clause", - "dependencies": { - "@jridgewell/source-map": "^0.3.3", - "acorn": "^8.15.0", - "commander": "^2.20.0", - "source-map-support": "~0.5.20" - }, - "bin": { - "terser": "bin/terser" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/terser/node_modules/commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "license": "MIT" - }, "node_modules/test-exclude": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-7.0.1.tgz", diff --git a/package.json b/package.json index fcba1304..f6ece7fa 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "dependencies": { "@actions/core": "^3.0.0", "@heroicons/react": "^2.2.0", + "@minify-html/wasm": "^0.18.1", "@node-core/rehype-shiki": "^1.4.0", "@node-core/ui-components": "^1.6.0", "@orama/orama": "^3.1.18", @@ -56,7 +57,6 @@ "globals": "^17.2.0", "hast-util-to-string": "^3.0.1", "hastscript": "^9.0.1", - "html-minifier-terser": "^7.2.0", "lightningcss": "^1.31.1", "mdast-util-slice-markdown": "^2.0.1", "piscina": "^5.1.4", diff --git a/src/utils/html-minifier.mjs b/src/utils/html-minifier.mjs index 750823a9..e3921288 100644 --- a/src/utils/html-minifier.mjs +++ b/src/utils/html-minifier.mjs @@ -1,21 +1,24 @@ -import { minify } from 'html-minifier-terser'; +import { minify } from '@minify-html/wasm'; const DEFAULT_HTML_MINIFIER_OPTIONS = { - collapseWhitespace: true, - conservativeCollapse: true, - minifyCSS: true, - removeComments: true, - removeRedundantAttributes: true, - removeScriptTypeAttributes: true, - removeStyleLinkTypeAttributes: true, - useShortDoctype: true, + minify_css: true, + minify_js: true, }; +const textEncoder = new TextEncoder(); +const textDecoder = new TextDecoder(); + /** * Minifies HTML with project defaults and optional overrides. * * @param {string} html - * @param {import('html-minifier-terser').Options} [overrides] + * @param {Record} [overrides] */ -export const minifyHTML = (html, overrides = {}) => - minify(html, { ...DEFAULT_HTML_MINIFIER_OPTIONS, ...overrides }); +export const minifyHTML = async (html, overrides = {}) => { + const minified = minify(textEncoder.encode(html), { + ...DEFAULT_HTML_MINIFIER_OPTIONS, + ...overrides, + }); + + return textDecoder.decode(minified); +}; From cb6f4cdeb0fdfeca97f53e6a3c803834953ce914 Mon Sep 17 00:00:00 2001 From: Claudio Wunder Date: Sun, 15 Feb 2026 17:35:17 +0100 Subject: [PATCH 4/4] chore: address copilot warn --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index f6ece7fa..8d732d46 100644 --- a/package.json +++ b/package.json @@ -10,11 +10,11 @@ "format": "prettier .", "format:write": "prettier --write .", "format:check": "prettier --check .", - "test": "node --test --experimental-test-module-mocks 'src/**/*.test.mjs'", - "test:coverage": "c8 node --test --experimental-test-module-mocks 'src/**/*.test.mjs'", - "test:ci": "c8 --reporter=lcov node --test --experimental-test-module-mocks 'src/**/*.test.mjs' --test-reporter=@reporters/github --test-reporter-destination=stdout --test-reporter=junit --test-reporter-destination=junit.xml --test-reporter=spec --test-reporter-destination=stdout", - "test:update-snapshots": "node --test --experimental-test-module-mocks --test-update-snapshots 'src/**/*.test.mjs'", - "test:watch": "node --test --experimental-test-module-mocks --watch 'src/**/*.test.mjs'", + "test": "node --test --experimental-test-module-mocks \"src/**/*.test.mjs\"", + "test:coverage": "c8 node --test --experimental-test-module-mocks \"src/**/*.test.mjs\"", + "test:ci": "c8 --reporter=lcov node --test --experimental-test-module-mocks \"src/**/*.test.mjs\" --test-reporter=@reporters/github --test-reporter-destination=stdout --test-reporter=junit --test-reporter-destination=junit.xml --test-reporter=spec --test-reporter-destination=stdout", + "test:update-snapshots": "node --test --experimental-test-module-mocks --test-update-snapshots \"src/**/*.test.mjs\"", + "test:watch": "node --test --experimental-test-module-mocks --watch \"src/**/*.test.mjs\"", "prepare": "husky || exit 0", "run": "node bin/cli.mjs", "watch": "node --watch bin/cli.mjs"