Skip to content

fix: should regenerate runtime chunk hash when using get chunk filename runtime module#10167

Merged
LingyuCoder merged 2 commits intomainfrom
fix/get-chunk-filename-runtime-chunk-hash
Apr 24, 2025
Merged

fix: should regenerate runtime chunk hash when using get chunk filename runtime module#10167
LingyuCoder merged 2 commits intomainfrom
fix/get-chunk-filename-runtime-chunk-hash

Conversation

@LingyuCoder
Copy link
Contributor

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 dependentHash flag too handle this. But I think we can just reuse fullhash to handle this.

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@LingyuCoder LingyuCoder requested a review from Copilot April 24, 2025 11:01
@github-actions github-actions bot added the release: bug fix release: bug related release(mr only) label Apr 24, 2025
@LingyuCoder LingyuCoder requested a review from ahabhgk April 24, 2025 11:01
@github-actions github-actions bot added the team The issue/pr is created by the member of Rspack. label Apr 24, 2025
@netlify
Copy link

netlify bot commented Apr 24, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit 4dc2683
🔍 Latest deploy log https://app.netlify.com/sites/rspack/deploys/680a2bdc36542e0008cd58a2

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 {

ahabhgk
ahabhgk previously approved these changes Apr 24, 2025
@LingyuCoder LingyuCoder enabled auto-merge (squash) April 24, 2025 11:16
@codspeed-hq
Copy link

codspeed-hq bot commented Apr 24, 2025

CodSpeed Performance Report

Merging #10167 will not alter performance

Comparing fix/get-chunk-filename-runtime-chunk-hash (4dc2683) with main (73d6011)

🎉 Hooray! codspeed-rust just leveled up to 2.7.2!

A heads-up, this is a breaking change and it might affect your current performance baseline a bit. But here's the exciting part - it's packed with new, cool features and promises improved result stability 🥳!
Curious about what's new? Visit our releases page to delve into all the awesome details about this new version.

Summary

✅ 11 untouched benchmarks

@LingyuCoder LingyuCoder merged commit 12e8432 into main Apr 24, 2025
29 checks passed
@LingyuCoder LingyuCoder deleted the fix/get-chunk-filename-runtime-chunk-hash branch April 24, 2025 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: bug fix release: bug related release(mr only) team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants