Skip to content

Comments

chore(build): simplify rspack runtime replacement plugin#7026

Merged
chenjiahan merged 3 commits intomainfrom
simplify_plugin_0124
Jan 24, 2026
Merged

chore(build): simplify rspack runtime replacement plugin#7026
chenjiahan merged 3 commits intomainfrom
simplify_plugin_0124

Conversation

@chenjiahan
Copy link
Member

@chenjiahan chenjiahan commented Jan 24, 2026

Summary

Replaced the RspackRuntimeReplacePlugin with a replacePlugin Rsbuild plugin, simplifying plugin registration and asset processing logic.

Related

Checklist

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

Copilot AI review requested due to automatic review settings January 24, 2026 01:11
@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 streamlines the build process by refactoring a custom Rspack runtime replacement mechanism. It transitions from a class-based Rspack plugin to a more integrated Rsbuild plugin, simplifying the logic for replacing runtime globals within bundled assets. This change enhances the maintainability and clarity of the build configuration by aligning it more closely with the Rsbuild plugin architecture.

Highlights

  • Plugin Refactoring: The RspackRuntimeReplacePlugin class has been replaced with a more streamlined replacePlugin function, leveraging the Rsbuild.RsbuildPlugin interface and api.processAssets hook for asset manipulation.
  • Simplified Configuration: The plugin application in rslib.config.ts has been simplified by moving from a tools.rspack configuration to directly adding the replacePlugin to the plugins array.
  • Dependency Updates: The pnpm-lock.yaml and scripts/config/package.json files were updated to remove a direct dependency on @rsbuild/core in scripts/config and adjust version references.
  • Type Modernization: Type imports in rslib.config.ts files were updated to use Rsbuild and rspack directly, and Minify type definition was adjusted.
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.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 24, 2026

Deploying rsbuild with  Cloudflare Pages  Cloudflare Pages

Latest commit: fdc2e48
Status: ✅  Deploy successful!
Preview URL: https://19403279.rsbuild-v2.pages.dev
Branch Preview URL: https://simplify-plugin-0124.rsbuild-v2.pages.dev

View logs

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 successfully simplifies the rspack runtime replacement plugin by refactoring it into a native Rsbuild plugin. The new implementation is more concise and maintainable by using the api.processAssets helper, and the logic remains correct. The associated changes to dependencies and type imports are also consistent and well-executed. This is a solid improvement to the build configuration.

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

Replaces a custom Rspack compiler plugin used for post-bundle runtime placeholder replacement with an Rsbuild plugin, and adjusts related build config typing/dependencies.

Changes:

  • Refactors runtime placeholder replacement from RspackRuntimeReplacePlugin (Rspack compiler hook) to an Rsbuild processAssets plugin.
  • Updates shared build config typing to reference Rsbuild.* types from @rslib/core.
  • Removes @rsbuild/core from scripts/config devDependencies and updates the lockfile resolution accordingly.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
scripts/config/rslib.config.ts Switches minify type annotation to Rsbuild.Minify via @rslib/core types.
scripts/config/package.json Removes @rsbuild/core from devDependencies.
pnpm-lock.yaml Updates dependency graph/peer resolution for scripts/config, including @rsbuild/core version selection.
packages/core/rslib.config.ts Replaces the custom Rspack plugin with an Rsbuild processAssets plugin and registers it for the client build.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)

scripts/config/package.json:12

  • rsbuild-plugin-arethetypeswrong declares @rsbuild/core as an (optional) peer dependency, and removing @rsbuild/core from this package causes pnpm to auto-install a registry @rsbuild/core version (see lockfile now pulling @rsbuild/[email protected]). This can lead to multiple @rsbuild/core copies/versions in the workspace and make plugin behavior harder to reason about. Consider either keeping @rsbuild/core as a workspace:* devDependency here, or explicitly configuring pnpm to not auto-install this peer for this package (e.g., peerDependencyRules/overrides) if you intentionally want it absent.
  "devDependencies": {
    "@rslib/core": "0.19.2",
    "@types/node": "^24.10.9",
    "@typescript/native-preview": "^7.0.0-dev.20260118.1",
    "rsbuild-plugin-arethetypeswrong": "0.1.1",
    "typescript": "^5.9.3"
  }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@chenjiahan chenjiahan merged commit f386fde into main Jan 24, 2026
6 checks passed
@chenjiahan chenjiahan deleted the simplify_plugin_0124 branch January 24, 2026 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant