Repository navigation
feat: let a minify function format and place the extractComments banner - #752
Conversation
A `formatBanner` helper on the minify function replaces the `/*! … */` wrapper, so an HTML minimizer can write `<!-- … -->`: a `/*!` line is text in a document, and before the doctype it switches to quirks mode.
A `getBannerPosition` helper returning `"end"` appends the banner instead of prepending it, so an HTML document keeps its doctype first.
🦋 Changeset detectedLatest commit: b1b1034 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #752 +/- ##
==========================================
+ Coverage 97.64% 97.67% +0.02%
==========================================
Files 5 5
Lines 1697 1718 +21
Branches 652 664 +12
==========================================
+ Hits 1657 1678 +21
Misses 39 39
Partials 1 1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The same lockfile change as #750, so npm audit passes in Lint.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review. WalkthroughThe plugin adds optional minimizer helpers to format extracted-comment banners and select their position. It uses the first declared helper for each option, with the default banner format and start position when helpers are not declared. A banner placed at the end follows the minimized source, and the plugin preserves a shebang at the start. Helper exceptions are reported against the asset. Minimizer identity includes the stringified banner helpers when they are declared. Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to The banner documentation matches the implemented behavior. No issue identified in this review prevents merging after normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The hooks operate within trusted build configuration and existing asset-writing authority. The main concern is that stateful helpers can reuse outdated cached banners or skip a helper that would now fail. No new attacker-controlled execution boundary was established. Retained concerns
Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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: 3
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 01d009ca-9c8d-4a4e-afef-00b4194a742c
⛔ Files ignored due to path filters (2)
package-lock.jsonis excluded by!**/package-lock.jsontest/__snapshots__/minify-option.test.js.snapis excluded by!**/*.snap
📒 Files selected for processing (5)
.changeset/format-banner.mdREADME.mdsrc/index.jstest/minify-option.test.jstypes/index.d.ts
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
…ache on it An end banner now keeps the shebang it was split from, a formatBanner or getBannerPosition that throws becomes an error of that asset rather than rejecting processAssets, and a declared helper's source joins the cache and chunk-hash identity.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: ee7e621d-aa0d-475d-8730-31d83cd8e1b3
📒 Files selected for processing (2)
src/index.jstest/minify-option.test.js
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.
Summary
The
extractCommentsbanner is always written as/*! … */at the top of the asset. That works for JS and CSS, but webpack's HTML minifier is going to extract license comments too, and in an HTML document that line is visible text placed before the doctype.A
minifyfunction can now define two optional helpers, likegetTypesorgetStage:formatBanner(banner)returns the comment to write, for example<!-- ${banner} -->.getBannerPosition()returns"start"(the default) or"end". With"end"the banner is appended with nothing in between, so the doctype stays first.Without the helpers nothing changes. The output of webpack's HTML minimizer test case:
What kind of change does this PR introduce?
feat
Did you add tests for your changes?
Yes, two cases in
test/minify-option.test.js: one forformatBanner, one forgetBannerPositionreturning"end".Does this PR introduce a breaking change?
No. Both helpers are optional.
If relevant, what needs to be documented once your changes are merged or what have you already documented?
Documented in the README under
extractComments→banner. A changeset is included.Use of AI
Written with Claude Code at the author's direction: the author chose the design (an HTML-style banner, placed at the end), and Claude implemented it, wrote the tests and ran the build, tests and lint.
🤖 Generated with Claude Code
https://claude.ai/code/session_01PodT59cXaxm4YzC9WBHr6P
Generated by Claude Code
Summary by CodeRabbit