fix: should regenerate runtime chunk hash when using get chunk filename runtime module#10167
Conversation
…me runtime module
✅ Deploy Preview for rspack canceled.
|
There was a problem hiding this comment.
Pull Request Overview
This pull request fixes the runtime chunk hash regeneration for the GetChunkFilenameRuntimeModule by ensuring that dependent chunk hashes are correctly handled. Key changes include:
- Updating test configurations and cases to verify that runtime chunk filenames include the proper hash values.
- Adding a full_hash method in the runtime module to always return true, simplifying the dependency on fullhash.
- Modifying the module chunk format logic to early-return when the chunk does not have an entry module.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/rspack-test-tools/tests/watchCases/hashes/runtimeChunkGetChunkFilename/test.config.js | Added test cases to verify that generated runtime chunk filenames are included in the output content. |
| packages/rspack-test-tools/tests/watchCases/hashes/runtimeChunkGetChunkFilename/rspack.config.js | Updated configuration to use module chunk format and ensure proper filename patterns. |
| packages/rspack-test-tools/tests/watchCases/hashes/runtimeChunkGetChunkFilename/1/index.js | Added a simple test to output a log for runtime chunk validation. |
| packages/rspack-test-tools/tests/watchCases/hashes/runtimeChunkGetChunkFilename/0/warnings.js | Provided warning message tests related to dependent hash calculation. |
| packages/rspack-test-tools/tests/watchCases/hashes/runtimeChunkGetChunkFilename/0/index2.js | Added a test file to validate behavior when importing dependent hash module. |
| packages/rspack-test-tools/tests/watchCases/hashes/runtimeChunkGetChunkFilename/0/index.js | Included a simple test with a console log to support runtime chunk testing. |
| packages/rspack-test-tools/tests/watchCases/hashes/runtimeChunkGetChunkFilename/0/dependent-hash.js | Integrated a placeholder to mimic webpack behavior using webpack_get_script_filename. |
| crates/rspack_plugin_runtime/src/runtime_module/get_chunk_filename.rs | Introduced a full_hash method to always return true, deviating from webpack’s dependentHash usage. |
| crates/rspack_plugin_runtime/src/module_chunk_format.rs | Refactored the chunk format check to early-return if the chunk lacks an entry module. |
Comments suppressed due to low confidence (1)
crates/rspack_plugin_runtime/src/runtime_module/get_chunk_filename.rs:390
- [nitpick] Consider clarifying the naming of the 'full_hash' method to more explicitly indicate that it always returns true, which differentiates it from webpack's 'dependentHash' behavior.
fn full_hash(&self) -> bool {
CodSpeed Performance ReportMerging #10167 will not alter performanceComparing 🎉 Hooray!
|
…me runtime module
Summary
another case of #9986
The GetChunkFilenameRuntimeModule may include some chunks that change after rebuilding. So this runtime module should depend on their hashes. Changing of their hashes may lead to the change of runtime chunk. And then the generated code of entry which uses
chunkFormat: "module"should also change.In webpack, it uses a
dependentHashflag too handle this. But I think we can just reusefullhashto handle this.Checklist