Skip to content

feat: record the license banner in the asset info, URL built without path - #764

Merged
alexander-akait merged 4 commits into
mainfrom
feat/license-banner-info
Oct 30, 2026
Merged

alexander-akait merged 4 commits into
mainfrom
feat/license-banner-info

Conversation

@alexander-akait

@alexander-akait alexander-akait commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Summary

When webpack inlines a minified chunk into an HTML page (output.html.inline, webpack/webpack#22992), the extractComments banner must name the license file from the page, not from the chunk. Today webpack finds the banner by matching its English wording, so a custom banner is never rebased. This PR records the banner in the asset info so a tool can rebase it exactly.

  • The URL the default banner names the license file by is built from the asset names, which are URL paths, instead of path.relative followed by a backslash fix. The output is identical; all 837 existing snapshots pass unchanged.
  • The asset info gains licenseBanner: { comment, href }, kept across cached rebuilds:
compilation.getAsset("filename/one.js").info.licenseBanner;
// default banner, license in another directory
// { comment: "/*! For license information please see ../licenses/filename/one.js.txt */",
//   href: "../licenses/filename/one.js.txt" }

// custom banner: (file) => `License information is in ${file}`
// { comment: "/*! License information is in filename/one.js.LICENSE.txt */",
//   href: "filename/one.js.LICENSE.txt" }

// banner: "See the licenses" → { comment: "/*! See the licenses */", href: undefined }
// banner: false → no `licenseBanner`

What kind of change does this PR introduce?

feat

Did you add tests for your changes?

Yes, five tests in test/extractComments-option.test.js: the default banner across directories, a cached rebuild, a custom function banner, a string banner naming no file, and banner: false.

Does this PR introduce a breaking change?

No. The banner text is unchanged; the asset info only gains a field.

If relevant, what needs to be documented once your changes are merged or what have you already documented?

Documented licenseBanner in the README's banner section.

Use of AI

Written with Claude Code: it found where the banner is built, wrote the change and tests, and ran the suite and lint. The requester chose the design and reviewed it.


Generated by Claude Code

Summary by CodeRabbit

  • New Features
    • Emitted assets now include license banner metadata: the banner comment and a relative link to the extracted license file when available. The metadata is also retained for cached results.
    • License links support assets in nested paths and exclude query-string slashes from the generated URL. Custom banners record a link when they name a license file; banners without one have no link.
  • Documentation
    • Clarified how banner comments and links are recorded, including when generated assets are written to another file.

…path

Build the URL the default banner names the license file by from the asset
names, which are URL paths, instead of path.relative. Record the comment
written and that URL as `licenseBanner` in the asset info, so a tool that
inlines the asset into another file can rebase the URL without matching
the banner's wording.
@changeset-bot

changeset-bot Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3506364

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
minimizer-webpack-plugin Minor

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

codecov Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.69%. Comparing base (f039f93) to head (3506364).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #764      +/-   ##
==========================================
+ Coverage   97.67%   97.69%   +0.02%     
==========================================
  Files           5        5              
  Lines        1718     1739      +21     
  Branches      664      671       +7     
==========================================
+ Hits         1678     1699      +21     
  Misses         39       39              
  Partials        1        1              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

npm audit reports four advisories against fast-uri up to 3.1.8, which
fails the lint job's security step.
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2f32ccc5-0d8e-49de-910f-fbc3817cd4c1
Commits

Reviewing files that changed from the base of the PR and between 317f692 and 3506364.

Files selected for processing: 2
  • src/index.js
  • test/extractComments-option.test.js
Files skipped from review as they are similar to previous changes: 2
  • test/extractComments-option.test.js
  • src/index.js

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Walkthrough

The plugin now records license banner text and its associated URL in emitted asset info. It computes default banner URLs with a new slash-separated relative URL helper. The minimizer cache retains this metadata. Tests cover default and custom banner URLs, cache hits, and disabled banners.

Priority: Normal

Merge Risk: Minimal · up to 35063

The previously reported query-slash URL issue is addressed. No actionable merge-blocking risk remains after normal checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main changes: recording the license banner in asset info and building its URL without the path module.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 2 files.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

test/extractComments-option.test.js

Oops! Something went wrong! :(

ESLint: 10.13.0

Error: Error while loading rule 'jest/no-deprecated-functions': Unable to detect Jest version - please ensure jest package is installed, or otherwise set version explicitly
Occurred while linting /test/extractComments-option.test.js
at detectJestVersion (/.eslint-tmp/node_modules/eslint-plugin-jest/lib/rules/utils/detectJestVersion.js:22:9)
at create (/.eslint-tmp/node_modules/eslint-plugin-jest/lib/rules/no-deprecated-functions.js:31:107)
at Object.create (/.eslint-tmp/node_modules/@typescript-eslint/utils/dist/eslint-utils/RuleCreator.js:39:20)
at createRuleListeners (/.eslint-tmp/node_modules/eslint/lib/linter/linter.js:502:15)
at /.eslint-tmp/node_modules/eslint/lib/linter/linter.js:628:7
at Array.forEach ()
at runRules (/.eslint-tmp/node_modules/eslint/lib/linter/linter.js:562:31)
at #flatVerifyWithoutProcessors (/.eslint-tmp/node_modules/eslint/lib/linter/linter.js:1297:4)
at Linter._verifyWithFlatConfigArrayAndWithoutProcessors (/.eslint-tmp/node_modules/eslint/lib/linter/linter.js:1382:43)
at Linter._verifyWithFlatConfigArray (/.eslint-tmp/node_modules/eslint/lib/linter/linter.js:1449:15)

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a145ef2f-a014-4fdf-893f-220549e1b3e7
Commits

Reviewing files that changed from the base of the PR and between f039f93 and b9671aa.

Files selected for processing: 4
  • .changeset/license-banner-info.md
  • README.md
  • src/index.js
  • test/extractComments-option.test.js

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Comment thread src/index.js Resolved
Comment thread src/index.js Resolved
Comment thread src/index.js Resolved
@linux-foundation-easycla

linux-foundation-easycla Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

A query can hold a `/`, which the relative URL would read as a directory.
@alexander-akait
alexander-akait force-pushed the feat/license-banner-info branch from 1dbae2b to 317f692 Compare October 29, 2026 15:51
Asset info merges field by field, so a banner without an `href` kept an
earlier banner's. A result cached before the banner was recorded is now
recomputed rather than restored without it.
@alexander-akait
alexander-akait merged commit fb6de90 into main Oct 30, 2026
31 checks passed
@alexander-akait
alexander-akait deleted the feat/license-banner-info branch October 30, 2026 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant