You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Support inline hash digest/length in path placeholders and CSS localIdentName (#21259)
* Support inline digest/length in CSS module localIdentName hash placeholders
Normalize css-loader / loader-utils style `[hash:<digest>:<length>]`
placeholders in the native CSS generator: fold the digest and length into the
local ident hash options and map `[hash]`/`[fullhash]` to the local ident hash
(css-loader semantics) so suffixed placeholders like `[fullhash:6]` and
`[hash:base64:6]` work.
* Support inline digest in hash path placeholders
Extend TemplatedPathPlugin.interpolate to accept `[hash:<digest>:<length>]`
(e.g. `[contenthash:base64:8]`) for filename/path templates, re-encoding the
stored hash into the requested digest. The source hash is already truncated to
output.hashDigestLength, so the result derives from those bytes.
* Revert CSS localIdentName-specific hash handling
Drop the css-loader-specific localIdentName hash remapping; inline digest and
length are handled generically in TemplatedPathPlugin.interpolate.
* Support inline hash digest and length in CSS localIdentName
Make the localIdent hash-detection regexes suffix-tolerant so [fullhash:N] and
[contenthash:...] trigger hash computation, and pass the output digest into
interpolate so an inline digest on [hash]/[contenthash] re-encodes correctly.
* Centralize placeholder-kind detection in TemplatedPathPlugin
Export getPresentKinds as the single source of truth for which [kind]
placeholders a template references, and route CssGenerator, RuntimePlugin and
SourceMapDevToolPlugin through it instead of their own hand-rolled regexes so
they can't drift from interpolate's grammar.
* Throw on an unknown inline hash digest in path templates
Re-encoding silently kept the source encoding for a typo'd digest; validate the
requested digest and throw a clear error instead, matching how interpolate
already rejects unimplemented path variables.
* Re-encode [fullhash]/[chunkhash] inline digests from the full hash
Inline-digest path re-encoded the hashDigestLength-truncated hash, capping
entropy below the requested length. Pass the untruncated compilation/chunk hash
(which already exists) so [fullhash:<digest>] and [chunkhash:<digest>] carry full
entropy and match an encode-then-slice result.
* Reject inline digest on [contenthash] when realContentHash is enabled
RealContentHashPlugin recomputes content hashes in output.hashDigest and would
silently overwrite an inline-digest [contenthash] with a hex hash. Throw a clear
error for that combination instead of emitting the wrong encoding.
* Support inline digest on [fullhash] in CSS localIdentName
The local ident hash uses localIdentHashDigest, not output.hashDigest, so an
inline [fullhash:<digest>] re-encoded from the wrong source. Pass the untruncated
local ident hash and its own digest (fullHashDigest) so interpolate re-encodes it
correctly with full entropy.
* Extract digestNonNumericOnly content-hash helper
The contentHash producers all did nonNumericOnlyHash(hash.digest(d), n); wrap
that composition in one helper and route JavascriptModulesPlugin,
CssModulesPlugin, HtmlModulesPlugin and getLocalIdent through it. AssetGenerator
keeps the inline form since it also returns the untruncated digest.
* Resolve CSS localIdentName [hash] to the local ident hash, not the module hash
Fixes issue point 2: the module-context block in interpolate repurposed [hash]
to the module hash, diverging from css-loader. Add a data.hashAsFullHash flag
that getLocalIdent sets so [hash] stays the local ident hash (like [fullhash]);
[modulehash] still yields the module hash. Closes#21141 (point 2).
* Fix test types and update CSS cache snapshots
* Support base64url hash digest on Node < 14.18
0 commit comments