GeezerVison is showing github.com — fix(output): warn when a base64 hash digest is used in an asset name by alexander-akait · Pull Request #23508 · webpack/webpack
Conversation
alexander-akait
commented
Nov 21, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary
A base64 hash can hold /. In an asset name it adds a directory, so the file lands deeper than its template says, and paths the runtime computes from it (such as publicPath: "auto") point to the wrong place, failing with ChunkLoadError. Whether a build breaks depends on the hash value, so it can start after an unrelated edit. Refs #23497, #5136.
output: {
publicPath: "auto",
filename: "static/js/[name].[contenthash:8].js",
hashDigest: "base64"
}
- Before: a build whose hash happens to hold
/ emits static/js/main.Fl/KJZm6.js with no message, and its lazy chunks fail to load.
- After: every build with
hashDigest: "base64" that emits a file with a hash in its name warns, whatever the hash value:
output.hashDigest "base64" can put "/" in a hash, and the asset "main.Fl/KJZm6.js" has a hash in its name. Such a file lands one directory deeper than its template says, and paths the runtime computes from it, such as an automatic public path, break. Use output.hashDigest "base64url".
The check runs after asset processing and reads the hashes each asset's info records, so it depends on the config and on which files carry a hash, never on a hash value. It does not check the filename templates: defaults such as assetModuleFilename already hold [hash], and that would warn builds that emit no hashed file. The plugin is applied only when output.hashDigest is "base64".
Note: a digest set on one placeholder ([contenthash:base64:8]) is not covered.
What kind of change does this PR introduce?
fix
Did you add tests for your changes?
Yes, test/configCases/output/hash-digest-base64-filename: a hashed chunk name with hashDigest: "base64" expects the warning. It fails without the plugin. The existing base64 cases (output/hash-function, css/external-import-anonymous-layer) emit no hashed file and stay without a warning.
Does this PR introduce a breaking change?
No. Builds with hashDigest: "base64" and hashed file names gain one warning; output is unchanged.
If relevant, what needs to be documented once your changes are merged or what have you already documented?
n/a, the output.hashDigest docs already recommend base64url.
Use of AI
Claude Code wrote the change and the test and ran the test suites; I reviewed it.
Generated by Claude Code
Generated by Claude Code
Summary by CodeRabbit
- Bug Fixes
- Webpack now warns when a base64 hash digest may introduce
/ into an asset filename, which can cause problems with .js files. The warning recommends using base64url instead.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Reports for 42dc40b, computed by this pull request's own code. Each section updates when its workflow finishes.
Preview package
This PR is packaged and the instant preview of its latest commit is available.
Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@23508
yarn add -D webpack@https://pkg.pr.new/webpack@23508
pnpm add -D webpack@https://pkg.pr.new/webpack@23508
From Preview package run #13842.
Generated code size
Comparing base (eec8289) to head (42dc40b). Merging this pull request adds 2 new asset(s).
| What moved |
Tests |
Assets |
Gzip |
Raw |
Test edit |
| Changed, test untouched |
0 |
0 |
— |
— |
— |
| Changed, test edited |
0 |
0 |
— |
— |
— |
| New |
1 |
2 |
⚪ added +849 B |
⚪ added +1.37 KiB |
— |
| Deleted |
0 |
0 |
— |
— |
— |
| Unchanged |
— |
10891 |
— |
— |
— |
Read Changed, test untouched first: the test is byte-identical on both sides, so webpack generated the difference. Changed, test edited moved partly because the test did — Test edit is how many bytes the test gained, and a bundle that grew by less is not a regression. New and Deleted are whole files, not deltas — a new asset was created, not grown, so it reads gray (⚪ added) — and adding tests cannot bury a real change. Gzip decides, because that is what users download; raw is the tiebreak, and brotli and zstd are per asset below.
Sample apps
No sample app changed size.
26 unchanged app(s)
| App |
Gzip |
Gzip change |
Raw |
Raw change |
library amd |
1.38 KiB |
— |
2.68 KiB |
— |
library amd-require |
1.38 KiB |
— |
2.67 KiB |
— |
library assign |
1.38 KiB |
— |
2.66 KiB |
— |
library assign-properties |
1.42 KiB |
— |
2.80 KiB |
— |
library commonjs |
1.38 KiB |
— |
2.66 KiB |
— |
library commonjs-module |
1.38 KiB |
— |
2.67 KiB |
— |
library commonjs-static |
1.55 KiB |
— |
3.54 KiB |
— |
library commonjs2 |
1.38 KiB |
— |
2.67 KiB |
— |
library global |
1.38 KiB |
— |
2.66 KiB |
— |
library jsonp |
1.37 KiB |
— |
2.66 KiB |
— |
library module |
1.21 KiB |
— |
2.35 KiB |
— |
library self |
1.38 KiB |
— |
2.66 KiB |
— |
library system |
1.41 KiB |
— |
2.73 KiB |
— |
library this |
1.37 KiB |
— |
2.66 KiB |
— |
library umd |
1.44 KiB |
— |
2.85 KiB |
— |
library umd2 |
1.44 KiB |
— |
2.85 KiB |
— |
library var |
1.38 KiB |
— |
2.67 KiB |
— |
library window |
1.38 KiB |
— |
2.66 KiB |
— |
node-ssr |
96.36 KiB |
— |
371.26 KiB |
— |
node-ssr-esm |
96.60 KiB |
— |
371.83 KiB |
— |
react-100 |
32.14 KiB |
— |
150.41 KiB |
— |
react-1k |
73.31 KiB |
— |
907.23 KiB |
— |
react-1k-esm |
72.51 KiB |
— |
906.05 KiB |
— |
react-5k |
191.45 KiB |
— |
4.08 MiB |
— |
webworker |
36.60 KiB |
— |
94.98 KiB |
— |
webworker-esm |
35.67 KiB |
— |
93.65 KiB |
— |
No asset that both runs emit changed size — everything below is new or deleted.
2 asset(s) this pull request adds
|
Asset |
Raw |
Gzip (9) |
Brotli (11) |
Zstd (19) |
| ⚪ added |
output/hash-digest-base64-filename bundle0.js |
1.28 KiB |
742 B |
666 B |
742 B |
| ⚪ added |
output/hash-digest-base64-filename 339.[hash].js |
96 B |
107 B |
84 B |
94 B |
No runtime that both runs build changed which runtime modules it carries.
1 runtime(s) this pull request adds or no longer builds
|
Runtime |
Modules |
| ➕ |
output/hash-digest-base64-filename main |
6 |
Built test/configCases with the defaults a user gets, and the apps in test/sizeCoreReports (apps/): 2509 test(s), 10893 asset(s), 112 emitted nothing.
From Generated code size run #8477.
Types Coverage
Typed lines: 99.66% (206281 of 206993)
| Kind |
Base |
Head |
Change |
any |
41 |
41 |
— |
unknown |
18 |
18 |
— |
object |
18 |
18 |
— |
Function |
0 |
0 |
— |
| untyped |
0 |
0 |
— |
any counts EXPECTED_ANY, a written any and JSDoc's * and ? for any type. unknown counts a written unknown; ThrownValue, the unknown a throw or a rejected promise hands on, is left out. object counts EXPECTED_OBJECT and Object, Function counts EXPECTED_FUNCTION. Untyped counts the any TypeScript infers where no type is written: a type argument a call leaves to inference that comes out any, whether a lib signature defaults it, as in const map = new Map() and Array(5), or a generic call infers it from an any argument; and const list = []. An identifier that only holds an any written in the project's files is not counted again, as the any row counts it where it is written; an any a lib signature returns, such as JSON.parse's, is counted in neither row.
This pull request adds or removes no escape hatch, any or untyped identifier.
33 file(s) in lib/, hot/, declarations/ and bin/ still have an escape hatch, `any` or untyped identifiers
| File |
Typed lines |
any |
unknown |
object |
Function |
untyped |
declarations/WebpackOptions.ts |
100.00% |
7 |
|
|
|
|
lib/Compilation.js |
99.97% |
5 |
2 |
|
|
|
lib/javascript/syntax-printer.js |
100.00% |
|
|
5 |
|
|
lib/module/NormalModule.js |
100.00% |
4 |
1 |
|
|
|
lib/loaders/LoaderOptionsPlugin.js |
100.00% |
4 |
|
|
|
|
lib/serialization/ObjectMiddleware.js |
100.00% |
|
|
4 |
|
|
lib/util/SortableSet.js |
100.00% |
|
4 |
|
|
|
lib/hmr/HotModuleReplacement.runtime.js |
100.00% |
|
2 |
1 |
|
|
lib/module/NormalModuleFactory.js |
100.00% |
|
3 |
|
|
|
lib/stats/StatsFactory.js |
100.00% |
2 |
|
1 |
|
|
lib/Compiler.js |
100.00% |
2 |
|
|
|
|
lib/config/defineConfig.js |
100.00% |
2 |
|
|
|
|
lib/hmr/JavascriptHotModuleReplacement.runtime.js |
100.00% |
|
|
2 |
|
|
lib/index.js |
100.00% |
2 |
|
|
|
|
lib/loaders/LoaderRunner.js |
100.00% |
2 |
|
|
|
|
lib/module/Module.js |
100.00% |
2 |
|
|
|
|
lib/module/Parser.js |
100.00% |
2 |
|
|
|
|
lib/node/nodeConsole.js |
100.00% |
|
2 |
|
|
|
lib/util/cleverMerge.js |
100.00% |
|
|
2 |
|
|
lib/config/cli.js |
100.00% |
1 |
|
|
|
|
lib/dll/DllReferencePlugin.js |
100.00% |
1 |
|
|
|
|
lib/graph/ModuleGraph.js |
100.00% |
1 |
|
|
|
|
lib/hmr/HotModuleReplacementPlugin.js |
100.00% |
|
1 |
|
|
|
lib/javascript/JavascriptParser.js |
100.00% |
|
|
1 |
|
|
lib/javascript/syntax-parser.js |
100.00% |
1 |
|
|
|
|
lib/logging/Logger.js |
100.00% |
1 |
|
|
|
|
lib/logging/createConsoleLogger.js |
100.00% |
|
1 |
|
|
|
lib/output/ManifestPlugin.js |
100.00% |
1 |
|
|
|
|
lib/serialization/types.js |
100.00% |
|
|
1 |
|
|
lib/stats/DefaultStatsFactoryPlugin.js |
100.00% |
|
1 |
|
|
|
lib/stats/StatsPrinter.js |
100.00% |
1 |
|
|
|
|
lib/util/makeSerializable.js |
100.00% |
|
|
1 |
|
|
lib/util/terminalColors.js |
100.00% |
|
1 |
|
|
|
From Types Coverage run #4515.
Module loading
How many files a fresh Node.js process loads (require or import) to do each thing below; a change from the pull request's base is marked 🔴 when it grew and 🟢 when it shrank. Every file is startup time, so fewer is better. webpack files are this package's own (lib/, hot/); node_modules files are its dependencies'.
| What the process does |
webpack files |
node_modules files |
require("webpack") |
2 |
0 |
import "webpack" |
2 |
0 |
| JavaScript syntax |
12 |
0 |
| CSS syntax |
12 |
0 |
| HTML syntax |
11 |
0 |
| XML syntax |
11 |
0 |
| JavaScript minifier |
13 |
0 |
| CSS minifier |
14 |
0 |
| HTML minifier |
19 |
0 |
| XML minifier |
14 |
0 |
| JSON minifier |
1 |
0 |
| development build |
422 |
103 |
| production build |
430 |
133 |
| watch with HMR, one rebuild |
446 |
110 |
From Module loading run #1759.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|

No actionable comments were generated in the recent review.
Walkthrough
-
The configuration now applies a warning plugin when output.hashDigest is base64. The plugin warns when an asset name contains a recorded hash and recommends base64url. A configuration test covers a hashed chunk filename.
Changes: Base64 hash filename warning
| Layer / File(s) |
Summary |
Warning detection and validation lib/diagnostics/WarnHashDigestInFilenamePlugin.js, lib/config/WebpackOptionsApply.js, test/configCases/output/hash-digest-base64-filename/*, .changeset/297-hash-digest-base64-filename.md |
When output.hashDigest is base64, the configuration applies a plugin that checks asset names for recorded hashes. On the first match, the plugin adds a warning recommending base64url. The configuration test checks a content-hashed chunk filename, and the changeset declares a patch release. |
Possibly related PRs
- webpack/webpack#23497: Adds a warning for the related base64 hash behavior that can add a directory level to an emitted JavaScript chunk filename.
Suggested labels: area: config
Suggested reviewers: xiaoxiaojx, bjohansebas
Change: Bug fix
Merge Risk: Minimal · up to 42dc4
-
This adds a warning for builds that use a base64 hash digest with hashed asset names, and suggests base64url instead. Output is unchanged, so the risk of merging is minimal.
Pre-merge checks: 3 · 1
-
Failed checks: 1 inconclusive
| Check name |
Status |
Explanation |
Resolution |
| Title check |
 |
The title uses the conventional-commit form with type fix and scope output, which matches the required format. It describes the main change: a warning for a base64 hash digest in an asset name. The ti… |
Confirm the source branch prefix matches the type 'fix'. The title itself meets the format and scope requirements. |
Passed checks: 3 passed
-
| Check name |
Status |
Explanation |
| Description Check |
 |
Check skipped - CodeRabbit’s high-level summary is enabled. |
| Linked Issues check |
 |
Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check |
 |
Check skipped because no linked issues were found for this pull request. |
Full details: Title check
-
Explanation
The title uses the conventional-commit form with type fix and scope output, which matches the required format. It describes the main change: a warning for a base64 hash digest in an asset name. The title does not state the branch prefix, so the branch-match requirement could not be checked from the provided context.
Resolution
Confirm the source branch prefix matches the type 'fix'. The title itself meets the format and scope requirements.
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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
-
Recent review info
-
Run configuration
-
Commits
-
Reviewing files that changed from the base of the PR and between eec8289 and 42dc40b.
Files selected for processing: 7
-
.changeset/297-hash-digest-base64-filename.md
lib/config/WebpackOptionsApply.js
lib/diagnostics/WarnHashDigestInFilenamePlugin.js
test/configCases/output/hash-digest-base64-filename/index.js
test/configCases/output/hash-digest-base64-filename/lazy.js
test/configCases/output/hash-digest-base64-filename/warnings.js
test/configCases/output/hash-digest-base64-filename/webpack.config.js
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Merging this PR will not alter performance
1 warning, 1 note
⚠️ 117 benchmarks are dominated by system calls
System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.
Learn more about system calls
See affected benchmarks
ℹ️ 39 benchmarks have no flamegraph
The flamegraph wasn't generated: most of the time was spent in runtime internals, which would leave nothing useful to analyze.
See affected benchmarks
✅ 351 untouched benchmarks
Comparing fix/base64-hash-digest-filenames (42dc40b) with main (eec8289)
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
area: config
Options, defaults, validation (lib/config, schemas/)
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|