Skip to content
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

fix: copy filename_template ito split chunks #8900

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

henryqdineen
Copy link

@henryqdineen henryqdineen commented Dec 30, 2024

Summary

This is a reimplementation of a PR I opened against webpack (webpack/webpack#19104). We found that the splitChunks.cacheGroups.{cacheGroup}.filename config option was not being respected for any split initial chunks created based on the maxSize-based deterministic grouping.

I added a stats test case which configures vendors cache group (with filename options) for anything in node_modules but with a small maxSize so it creates many little chunks. This is the diff for the test from before and after the fix in case it helps:

- Entrypoint main 5.88 KiB = 990.js 352 bytes 961.js 352 bytes 727.vendors.js 352 bytes main.js 4.85 KiB
+ Entrypoint main 5.88 KiB = 990.vendors.js 352 bytes 961.vendors.js 352 bytes 727.vendors.js 352 bytes main.js 4.85 KiB
  chunk (runtime: main) 727.vendors.js (id hint: vendors) 20 bytes [initial] [rendered] split chunk (cache group: vendors)
    ./node_modules/c.js 20 bytes [built] [code generated]
  chunk (runtime: main) main.js (main) 80 bytes (javascript) 2.86 KiB (runtime) [entry] [rendered]
    ./index.js 80 bytes [built] [code generated]
- chunk (runtime: main) 961.js (id hint: vendors) 20 bytes [initial] [rendered]
+ chunk (runtime: main) 961.vendors.js (id hint: vendors) 20 bytes [initial] [rendered]
    ./node_modules/b.js 20 bytes [built] [code generated]
- chunk (runtime: main) 990.js (id hint: vendors) 20 bytes [initial] [rendered]
+ chunk (runtime: main) 990.vendors.js (id hint: vendors) 20 bytes [initial] [rendered]
    ./node_modules/a.js 20 bytes [built] [code generated]

Alternatives considered

It seems like we could move this logic in to the split method on the Chunk struct but I'm not sure if that is preferred.

Checklist

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

@CLAassistant
Copy link

CLAassistant commented Dec 30, 2024

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added the release: bug fix release: bug related release(mr only) label Dec 30, 2024
Copy link

netlify bot commented Dec 30, 2024

Deploy Preview for rspack ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 1ad61af
🔍 Latest deploy log https://app.netlify.com/sites/rspack/deploys/6777770e85440e0008e01fe8
😎 Deploy Preview https://deploy-preview-8900--rspack.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@chenjiahan chenjiahan requested a review from JSerFeng December 31, 2024 07:30
@JSerFeng
Copy link
Contributor

JSerFeng commented Jan 2, 2025

Personally I think it's fine to move this to split method

@henryqdineen henryqdineen force-pushed the hqd-split-chunks-cache-group-filename branch from abedd75 to 1ad61af Compare January 3, 2025 05:35
@henryqdineen
Copy link
Author

Thanks for the feeback @JSerFeng. I implemented your suggestion in 1ad61af

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)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants