feat: allow to set split chunks for non-web targets#7087
Conversation
Summary of ChangesHello @chenjiahan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a significant enhancement to Rsbuild's chunk splitting capabilities by extending support for Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a valuable feature by allowing splitChunks to be configured for non-web targets, which was previously disabled. The implementation is solid, with clear logic in packages/core/src/plugins/splitChunks.ts to handle the new behavior while maintaining existing functionality for web targets. The renaming of getDefaultSplitChunks to getDefaultSplitChunksForWeb greatly improves code clarity. The changes are well-supported by a new end-to-end test that validates the feature for Node.js targets. Additionally, the documentation has been updated accurately to reflect these new capabilities. Overall, this is a high-quality contribution.
There was a problem hiding this comment.
Pull request overview
This PR enables split chunks configuration for non-web build targets (such as Node.js and web workers), which were previously hardcoded to disable chunk splitting. The implementation maintains backward compatibility by keeping split chunks disabled by default for non-web targets, while allowing users to explicitly enable it when needed.
Changes:
- Modified the splitChunks plugin to allow explicit split chunks configuration for server and web worker builds
- Updated documentation (English and Chinese) to clarify that default behavior depends on the
output.targetconfiguration - Added e2e test case to verify single-vendor preset works correctly with Node.js target
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/core/src/plugins/splitChunks.ts | Refactored plugin logic to support explicit splitChunks configuration for non-web targets while maintaining disabled-by-default behavior; renamed getDefaultSplitChunks to getDefaultSplitChunksForWeb for clarity |
| website/docs/en/config/split-chunks.mdx | Updated documentation to reflect conditional defaults based on output.target, added undefined to preset type |
| website/docs/zh/config/split-chunks.mdx | Updated Chinese documentation to match English version changes, improved Rspack documentation link to use Chinese version |
| e2e/cases/split-chunks/preset-single-vendor-node/index.test.ts | Added test to verify vendor chunk generation for Node.js target with single-vendor preset |
| e2e/cases/split-chunks/preset-single-vendor-node/rsbuild.config.ts | Configuration file for Node.js target test case |
| e2e/cases/split-chunks/preset-single-vendor-node/src/index.js | Test source file importing React dependencies to verify chunk splitting |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 891839123e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Summary
output.targetChecklist