Skip to content

Comments

feat: allow to set split chunks for non-web targets#7087

Merged
chenjiahan merged 2 commits intomainfrom
split_chunks_non_web_0130
Jan 30, 2026
Merged

feat: allow to set split chunks for non-web targets#7087
chenjiahan merged 2 commits intomainfrom
split_chunks_non_web_0130

Conversation

@chenjiahan
Copy link
Member

Summary

  • Allow to set split chunks for non-web targets
  • Updated the default value in documentation to depend on the output.target

Checklist

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

Copilot AI review requested due to automatic review settings January 30, 2026 05:59
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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 splitChunks configuration to non-web targets, specifically node and web-worker environments. Previously, chunk splitting was implicitly disabled for these targets, limiting optimization options. With this change, users can now explicitly define their chunk splitting strategies, allowing for more tailored and efficient bundle outputs across different build targets. The documentation has been updated to clearly outline the new default behaviors and configuration options.

Highlights

  • Flexible Chunk Splitting for Non-Web Targets: Rsbuild now allows explicit configuration of splitChunks for node and web-worker targets, providing more control over build output optimization beyond just web environments.
  • Updated Default splitChunks Behavior: The default splitChunks setting is now conditional: false for non-web targets and { preset: 'default', chunks: 'all' } for web targets, as clearly reflected in the updated documentation.
  • New E2E Test Coverage: A new end-to-end test case has been added to validate the single-vendor preset for node targets, ensuring the feature works as expected and preventing regressions.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

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.

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 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.target configuration
  • 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.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 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".

@chenjiahan chenjiahan merged commit 34db012 into main Jan 30, 2026
5 checks passed
@chenjiahan chenjiahan deleted the split_chunks_non_web_0130 branch January 30, 2026 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant