refactor: simplify Rspack plugin and config types#7000
Conversation
✅ Deploy Preview for rsbuild-v2 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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 focuses on refactoring and simplifying type definitions related to Rspack plugins and configuration. By aligning with Rspack's native types, the changes aim to improve type consistency, reduce maintenance overhead for custom types, and enhance clarity across the codebase. 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 is a solid refactoring that simplifies Rspack-related types by replacing custom wrappers like BundlerPluginInstance with upstream types from @rspack/core. This significantly improves code clarity and maintainability. The changes are consistently applied throughout the codebase, including type definitions, implementation files, and documentation. I have one minor suggestion to further improve the idiomaticity of a type definition. Overall, this is a great improvement.
There was a problem hiding this comment.
Pull request overview
This PR refactors the Rsbuild codebase to use upstream Rspack types directly instead of custom type wrappers, simplifying the type system and improving maintainability.
Changes:
- Removed custom
BundlerPluginInstancetype and replaced all usages withRspack.RspackPluginInstance - Simplified
SplitChunksandRspackRuletype definitions to use upstream Rspack types directly - Updated documentation to show full function signatures for better clarity
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/core/src/types/rspack.ts | Removed custom BundlerPluginInstance interface and simplified RspackRule to use direct array indexing |
| packages/core/src/types/config.ts | Updated plugin utility types to use Rspack.RspackPluginInstance and simplified SplitChunks type |
| packages/core/src/plugins/splitChunks.ts | Updated type annotations to use Rspack.OptimizationSplitChunksOptions |
| packages/core/src/plugins/rsdoctor.ts | Updated RsdoctorRspackPlugin type to use Rspack.RspackPluginInstance |
| packages/core/src/pluginManager.ts | Updated plugin validation to use Rspack.RspackPluginInstance |
| packages/core/src/index.ts | Removed BundlerPluginInstance from exports |
| scripts/test-helper/src/index.ts | Updated return types to use Rspack.RspackPluginInstance and Rspack.RuleSetRules |
| website/docs/en/config/tools/rspack.mdx | Updated documentation to show full function signatures with Rspack.RspackPluginInstance |
| website/docs/zh/config/tools/rspack.mdx | Updated documentation to show full function signatures with Rspack.RspackPluginInstance |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ### prependPlugins | ||
|
|
||
| - **Type:** `(plugins: BundlerPluginInstance | BundlerPluginInstance[]) => void` | ||
| - **Type:** ` |
There was a problem hiding this comment.
Remove the trailing backtick after "Type:". This should be "- Type:" without the backtick, consistent with the formatting of other type declarations in the file.
| - **Type:** ` | |
| - **Type:** |
Summary
BundlerPluginInstancetype throughout the codebase and replaced all usages withRspack.RspackPluginInstanceSplitChunksandRspackRuletypes to use the upstream Rspack types directlyChecklist