Conversation
WalkthroughThe pull request replaces the HTML minifier dependency from Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
package.json (1)
58-63: New minifier dependency looks good; remove stale html-minifier-next types
@minify-html/node@0.18.1is correctly integrated—verified usage atsrc/minify/minifyContents.tswith the documented Node API (minifyHtml.minify(Buffer.from(...), { ... })).
@types/html-minifier-nextis stale and can be safely removed fromdevDependencies. No references to the oldhtml-minifier-nextpackage remain anywhere in the codebase.
🧹 Nitpick comments (2)
src/minify/minifyContents.ts (2)
1-9: Helper wraps @minify-html/node correctly; a couple of optional cleanupsThe switch to
@minify-html/nodelooks correct: using the default import, passing aBufferplus snake_case options, and then converting the result back to a string all match the library’s documented pattern. (github.com)Two small, non-blocking tweaks you might consider:
minifyHtml.minifyis synchronous, so you don’t strictly needasync/awaitinminifyContentsHtml; a plain sync helper keeps the types a bit simpler.- Importing
Bufferexplicitly (import { Buffer } from "node:buffer";) avoids relying on the global and makes the dependency on Node’s Buffer API clearer.For example:
-import minifyHtml from "@minify-html/node"; - -const minifyContentsHtml = async (contents: string): Promise<string> => { - const minified = await minifyHtml.minify(Buffer.from(contents), { +import { Buffer } from "node:buffer"; +import minifyHtml from "@minify-html/node"; + +const minifyContentsHtml = (contents: string): string => { + const minified = minifyHtml.minify(Buffer.from(contents), { minify_css: true, minify_js: true, }); - - return minified.toString(); -}; + return minified.toString(); +};
18-22: Confirm new minifier’s defaults (whitespace, comments, templates) match expectations
@minify-html/nodehas different defaults and a more aggressive minification strategy thanhtml-minifier-next(especially around whitespace and comment handling), and you’re currently only tweakingminify_cssandminify_jswhile leaving other options at their defaults. (github.com)I’d recommend running a build (e.g. your example project) and diffing the generated HTML against the previous version to catch any regressions in whitespace‑sensitive or templated files; if needed, you can adjust options such as
keep_comments,keep_spaces_between_attributes, or the variouspreserve_*_template_syntaxflags to better mirror prior behaviour. (github.com)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (2)
package.json(1 hunks)src/minify/minifyContents.ts(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Codacy Static Code Analysis
This pull request updates the HTML minification logic to use a new library and adapts the code to match the new API. The main change is switching from
html-minifier-nextto@minify-html/node, which requires updates to both the dependency list and the minification function implementation.Dependency update:
html-minifier-nextdependency with@minify-html/nodeinpackage.json.Minification logic refactor:
src/minify/minifyContents.tsto use@minify-html/node's API, including converting the input to aBufferand adjusting option names to match the new library.minifyHtmltominifyContentsHtmland updated its usage in the mainminifyContentsfunction.Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.