Skip to content

Comments

feat(plugin-svgr): compatible with Rsbuild v1#7061

Merged
chenjiahan merged 1 commit intomainfrom
svgr_compat_v1_0126
Jan 27, 2026
Merged

feat(plugin-svgr): compatible with Rsbuild v1#7061
chenjiahan merged 1 commit intomainfrom
svgr_compat_v1_0126

Conversation

@chenjiahan
Copy link
Member

Summary

Updated pluginSvgr implementation to detect Rsbuild v1 and adjust how JS transform rules are applied for SVG files, ensuring compatibility with both Rsbuild v1 and v2.

Related Links

Checklist

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

Copilot AI review requested due to automatic review settings January 27, 2026 03:18
@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@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 compatibility for pluginSvgr with Rsbuild v1, allowing the plugin to function correctly across both Rsbuild v1 and v2 environments. It achieves this by implementing version detection logic to dynamically adapt how JavaScript transformation rules are applied to SVG files, addressing structural differences in the module rule chaining between the two Rsbuild versions. This ensures a consistent and reliable SVG processing experience regardless of the Rsbuild version in use.

Highlights

  • Rsbuild v1 Compatibility: The pluginSvgr now includes logic to detect Rsbuild v1 and adjust its behavior for SVG file processing, ensuring backward compatibility.
  • Dynamic JS Rule Application: The plugin intelligently applies JavaScript transformation rules to SVGR based on the detected Rsbuild version, handling differences in how chain.module.rules are structured.
  • Expanded Test Coverage: New test cases have been added to specifically verify the pluginSvgr's functionality and configuration when running under Rsbuild v1.
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

Deploying rsbuild with  Cloudflare Pages  Cloudflare Pages

Latest commit: f7bd573
Status: ✅  Deploy successful!
Preview URL: https://92309c02.rsbuild-v2.pages.dev
Branch Preview URL: https://svgr-compat-v1-0126.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

The pull request successfully introduces compatibility for Rsbuild v1 within the pluginSvgr. The implementation correctly identifies the Rsbuild version and applies the appropriate JS transform rules for SVG files. The addition of @rsbuild/core-v1 as a dev dependency and the new test cases for Rsbuild v1 compatibility demonstrate a thorough approach to ensuring backward compatibility. All changes are well-aligned with the PR's objective and appear to be correctly implemented and tested.

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

Updates @rsbuild/plugin-svgr to work with both Rsbuild v1 and v2 by selecting the appropriate JS rule shape when inheriting the project’s JS transform loader(s) for SVG → React component handling.

Changes:

  • Detect Rsbuild v1 via api.context.version and apply JS transform loader(s) from the correct chain rule shape.
  • Add Rsbuild v1 test coverage by running the same SVGR rule snapshots against @rsbuild/[email protected] via an alias package.
  • Update snapshots and lockfile to reflect the new compatibility test matrix.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pnpm-lock.yaml Adds locked dependency entry for @rsbuild/core-v1 (alias to Rsbuild v1) used by tests.
packages/plugin-svgr/package.json Adds @rsbuild/core-v1 devDependency to run compatibility tests against Rsbuild v1.
packages/plugin-svgr/src/index.ts Switches JS rule selection logic to support both v1 (no JS oneOf) and v2 (JS main oneOf).
packages/plugin-svgr/tests/index.test.ts Runs the existing SVGR snapshot cases against both Rsbuild v2 and Rsbuild v1.
packages/plugin-svgr/tests/snapshots/index.test.ts.snap Adds/updates snapshots for the new Rsbuild v1 test cases.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

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

@chenjiahan chenjiahan merged commit 0cc868d into main Jan 27, 2026
13 checks passed
@chenjiahan chenjiahan deleted the svgr_compat_v1_0126 branch January 27, 2026 03: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