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

feat: splitChunks support usedExports #7485

Merged
merged 2 commits into from
Aug 8, 2024

Conversation

JSerFeng
Copy link
Collaborator

@JSerFeng JSerFeng commented Aug 7, 2024

Summary

Docs: WIP

We have runtime optimization for used exports, for example when we have two entries named foo and bar, and a shared module shared which exports 2 values foo and bar.

foo imports foo from shared

bar imports bar from shared

with default behavior, there will be 2 shared modules in the final output, one contains only foo export for foo entry, and one contains only bar export for bar entry.

This is great. But when it comes to splitChunks, there will be problem.

if we have a cacheGroup that can select shared, then the shared module maybe extracted into a separate chunk, thus the runtime optimization is gone.

Now if you enable splitChunks.usedExports, when shared module is selected by a cacheGroup, the cacheGroup will calculate all possible combinations of how exports are used in different runtime.

shared with foo exported belongs to foo chunk, and with bar exported belongs to bar chunk, and if you didn't set cacheGroups.{cacheGroup}.name, then shared modules will still exist for both runtime.

Checklist

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

@github-actions github-actions bot added release: feature release: feature related release(mr only) team The issue/pr is created by the member of Rspack. labels Aug 7, 2024
Copy link

netlify bot commented Aug 7, 2024

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit 1c50910
🔍 Latest deploy log https://app.netlify.com/sites/rspack/deploys/66b49506a6146f0008b01f35

@JSerFeng JSerFeng force-pushed the feat/split-chunks-support-used-exports branch 4 times, most recently from 79c2fee to 98fa976 Compare August 8, 2024 03:16
@JSerFeng JSerFeng marked this pull request as ready for review August 8, 2024 06:42
@JSerFeng
Copy link
Collaborator Author

JSerFeng commented Aug 8, 2024

!bench

@rspack-bot
Copy link

rspack-bot commented Aug 8, 2024

📝 Benchmark detail: Open

Name Base (2024-08-08 2bd905d) Current Change
10000_development-mode + exec 2.32 s ± 27 ms 2.32 s ± 36 ms +0.13 %
10000_development-mode_hmr + exec 701 ms ± 7.3 ms 703 ms ± 7.5 ms +0.31 %
10000_production-mode + exec 2.85 s ± 23 ms 2.89 s ± 41 ms +1.54 %
arco-pro_development-mode + exec 1.89 s ± 75 ms 1.91 s ± 78 ms +0.95 %
arco-pro_development-mode_hmr + exec 434 ms ± 2.4 ms 434 ms ± 2.3 ms 0.00 %
arco-pro_production-mode + exec 3.52 s ± 286 ms 3.41 s ± 92 ms -3.19 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 3.54 s ± 235 ms 3.6 s ± 169 ms +1.53 %
threejs_development-mode_10x + exec 1.72 s ± 15 ms 1.71 s ± 19 ms -0.15 %
threejs_development-mode_10x_hmr + exec 826 ms ± 9.5 ms 832 ms ± 14 ms +0.74 %
threejs_production-mode_10x + exec 5.53 s ± 29 ms 5.52 s ± 33 ms -0.25 %

@JSerFeng JSerFeng requested review from ahabhgk and SyMind and removed request for ahabhgk August 8, 2024 07:37
@JSerFeng JSerFeng marked this pull request as draft August 8, 2024 08:33
@JSerFeng JSerFeng force-pushed the feat/split-chunks-support-used-exports branch from fb9b1d9 to 3526445 Compare August 8, 2024 09:22
@JSerFeng JSerFeng marked this pull request as ready for review August 8, 2024 09:22
@JSerFeng JSerFeng force-pushed the feat/split-chunks-support-used-exports branch from 3526445 to 1c50910 Compare August 8, 2024 09:51
@JSerFeng JSerFeng enabled auto-merge (squash) August 8, 2024 10:58
@JSerFeng JSerFeng merged commit 8572bc3 into main Aug 8, 2024
28 checks passed
@JSerFeng JSerFeng deleted the feat/split-chunks-support-used-exports branch August 8, 2024 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release: feature release: feature 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