-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
add allowNumericOnlyHash option for asset/resource #17903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
add allowNumericOnlyHash option for asset/resource #17903
Conversation
For maintainers only:
|
Can you accept CLA? Also can you describe the problem deeply, because #13628 (comment) we had a bug in |
i will try confirm CLA later. as described in #13628 title, when module.rule.generator.emit is false, if output filename contains contenthash, it may result in different filename when emit is true. webpack/lib/asset/AssetGenerator.js Line 402 in ea3d248
then in generate webpack/lib/asset/AssetGenerator.js Line 225 in ea3d248
because it's type is JS_TYPES, it's run into default branch webpack/lib/asset/AssetGenerator.js Line 240 in ea3d248
and then calculate content hash using nonNumericOnlyHash webpack/lib/asset/AssetGenerator.js Line 303 in ea3d248
and nonNumericOnlyHash will return hash with prefixed webpack/lib/util/nonNumericOnlyHash.js Lines 18 to 21 in ea3d248
it happen because the
it's more relevant with nonNumericOnlyHash introduced in #15289 |
@makaria So you need the same filename when emit is true and false? Just want to undestand this deeply |
yes, to be more accurately, the content hash need to be exactly the same as full hash sliced. the assets is uploaded by backend with hashed filename, frontend calculate file content hash and replace file url with uploaded url |
@makaria can you fix CI? |
sorry, but i've no idea about how to fix Error: Deprecations while compiling, can you help me fix it? |
fixes #13628 (comment)
What kind of change does this PR introduce?
feature
Did you add tests for your changes?
yes
Does this PR introduce a breaking change?
no
What needs to be documented once your changes are merged?
the generator options for asset/resource have a new
allowNumericOnlyHash
option. Defaults to false. Setting it to true will opt-out from prefixed numeric hash with charactera
(bypass nonNumericOnlyHash whenemit
is false).Related problem
using
generator.emit: false
result in incorrect content hash of specific gifUsing a gif which hash using the hashing algorithm SHA-1 is:
63269829566710439434dae6582fa16f9345afbf
.In React jsx
In
webpack.config.js