From 5de047058b90529711eb2b7b75031dca958bcff0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guilherme=20Ara=C3=BAjo?= Date: Thu, 17 Jul 2025 21:31:17 -0300 Subject: [PATCH 1/4] refactor: remove mustache --- package-lock.json | 10 ---------- package.json | 3 +-- src/generators/web/template.html | 6 ++---- src/generators/web/utils/processing.mjs | 19 ++++++++++++------- 4 files changed, 15 insertions(+), 23 deletions(-) diff --git a/package-lock.json b/package-lock.json index ad2568c5..36016a41 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,7 +27,6 @@ "hastscript": "^9.0.1", "lightningcss": "^1.30.1", "mdast-util-slice-markdown": "^2.0.1", - "mustache": "^4.2.0", "preact": "^10.26.9", "preact-render-to-string": "^6.5.13", "reading-time": "^1.5.0", @@ -7987,15 +7986,6 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" }, - "node_modules/mustache": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz", - "integrity": "sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==", - "license": "MIT", - "bin": { - "mustache": "bin/mustache" - } - }, "node_modules/nano-spawn": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/nano-spawn/-/nano-spawn-1.0.2.tgz", diff --git a/package.json b/package.json index 4c648a68..76da494c 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "test:update-snapshots": "node --test --experimental-test-module-mocks --test-update-snapshots", "test:watch": "node --test --experimental-test-module-mocks --watch", "prepare": "husky", - "run": "node bin/cli.mjs", + "run": "node --inspect bin/cli.mjs ", "watch": "node --watch bin/cli.mjs" }, "main": "./src/index.mjs", @@ -60,7 +60,6 @@ "hastscript": "^9.0.1", "lightningcss": "^1.30.1", "mdast-util-slice-markdown": "^2.0.1", - "mustache": "^4.2.0", "preact": "^10.26.9", "preact-render-to-string": "^6.5.13", "reading-time": "^1.5.0", diff --git a/src/generators/web/template.html b/src/generators/web/template.html index 04329751..fe97ebb0 100644 --- a/src/generators/web/template.html +++ b/src/generators/web/template.html @@ -18,8 +18,6 @@ -
{{{dehydrated}}}
- - +
{{dehydrated}}
+ - \ No newline at end of file diff --git a/src/generators/web/utils/processing.mjs b/src/generators/web/utils/processing.mjs index e2380f93..cf26ef67 100644 --- a/src/generators/web/utils/processing.mjs +++ b/src/generators/web/utils/processing.mjs @@ -1,6 +1,5 @@ import HTMLMinifier from '@minify-html/node'; import { toJs, jsx } from 'estree-util-to-js'; -import Mustache from 'mustache'; import bundleCode from './bundle.mjs'; @@ -72,12 +71,18 @@ export async function processJSXEntry( const clientCode = buildClientProgram(code); const clientBundle = await bundleCode(clientCode); - // TODO(@avivkeller): Don't depend on Mustache - const renderedHtml = Mustache.render(template, { - title: `${entry.data.heading.data.name} | Node.js v${version} Documentation`, - dehydrated, - javascript: clientBundle.js, - }); + const title = `${entry.data.heading.data.name} | Node.js v${version} Documentation`; + + const scriptTag = ``; + + // Replace template placeholders with actual content + const filledTemplate = template + .replace('{{title}}', title) + .replace('{{dehydrated}}', dehydrated ?? ''); + + const renderedHtml = `${filledTemplate} +${scriptTag} +`; // The input to `minify` must be a Buffer. const finalHTMLBuffer = HTMLMinifier.minify(Buffer.from(renderedHtml), {}); From 85535dcd7fc187cd1078e5b2532122310f875537 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guilherme=20Ara=C3=BAjo?= Date: Thu, 17 Jul 2025 21:36:38 -0300 Subject: [PATCH 2/4] chore: oops --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 76da494c..f7b3f863 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "test:update-snapshots": "node --test --experimental-test-module-mocks --test-update-snapshots", "test:watch": "node --test --experimental-test-module-mocks --watch", "prepare": "husky", - "run": "node --inspect bin/cli.mjs ", + "run": "node bin/cli.mjs ", "watch": "node --watch bin/cli.mjs" }, "main": "./src/index.mjs", From 7c2d74d962f48705b00c24ffc786b2f3d9b3099b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guilherme=20Ara=C3=BAjo?= Date: Thu, 17 Jul 2025 21:36:55 -0300 Subject: [PATCH 3/4] chore: oops --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f7b3f863..6b694bb9 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "test:update-snapshots": "node --test --experimental-test-module-mocks --test-update-snapshots", "test:watch": "node --test --experimental-test-module-mocks --watch", "prepare": "husky", - "run": "node bin/cli.mjs ", + "run": "node bin/cli.mjs", "watch": "node --watch bin/cli.mjs" }, "main": "./src/index.mjs", From 04acf4dbfaa12374002bb4f71b4e3abd7aaf7adf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guilherme=20Ara=C3=BAjo?= Date: Fri, 18 Jul 2025 10:30:23 -0300 Subject: [PATCH 4/4] fix: use replacer fn --- src/generators/web/template.html | 5 +++-- src/generators/web/utils/processing.mjs | 11 +++-------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/generators/web/template.html b/src/generators/web/template.html index fe97ebb0..12f867c3 100644 --- a/src/generators/web/template.html +++ b/src/generators/web/template.html @@ -19,5 +19,6 @@
{{dehydrated}}
- - + + + diff --git a/src/generators/web/utils/processing.mjs b/src/generators/web/utils/processing.mjs index cf26ef67..8a953828 100644 --- a/src/generators/web/utils/processing.mjs +++ b/src/generators/web/utils/processing.mjs @@ -73,16 +73,11 @@ export async function processJSXEntry( const title = `${entry.data.heading.data.name} | Node.js v${version} Documentation`; - const scriptTag = ``; - // Replace template placeholders with actual content - const filledTemplate = template + const renderedHtml = template .replace('{{title}}', title) - .replace('{{dehydrated}}', dehydrated ?? ''); - - const renderedHtml = `${filledTemplate} -${scriptTag} -`; + .replace('{{dehydrated}}', dehydrated ?? '') + .replace('{{clientBundleJs}}', () => clientBundle.js); // The input to `minify` must be a Buffer. const finalHTMLBuffer = HTMLMinifier.minify(Buffer.from(renderedHtml), {});