fix(create-rsbuild): update React Compiler babel config#7393
Conversation
Summary of ChangesHello, 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 refines the integration of the React Compiler within create-rsbuild by updating its Babel configuration to match current React best practices. It ensures that the compiler correctly targets a broader range of JavaScript and TypeScript files while avoiding node_modules, and enhances the testing suite to validate these configuration changes and the compilation of custom hooks. 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. Footnotes
|
There was a problem hiding this comment.
Pull request overview
Updates the React Compiler Babel configuration used by create-rsbuild templates and related e2e coverage so React Compiler runs on all JS/TS source files (including hooks in plain .js/.ts) while avoiding node_modules.
Changes:
- Widened React Compiler Babel
includeto/\.[jt]sx?$/and addedexcludefornode_modulesin the React Compiler templates and the Babel e2e case. - Updated the React Compiler Babel e2e case to compile a custom hook defined in a plain
.jsfile and added bundle assertions. - Added
create-rsbuilde2e assertions to ensure the generated template includes the expected Babelinclude/excludesettings.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/create-rsbuild/template-react-compiler/react-ts/rsbuild.config.ts | Sync template Babel include/exclude patterns with updated React Compiler guidance. |
| packages/create-rsbuild/template-react-compiler/react-js/rsbuild.config.js | Same include/exclude update for the JS template variant. |
| e2e/cases/plugin-react/react-compiler-babel/src/useCounter.js | Adds a plain .js hook to ensure non-JSX files get compiled. |
| e2e/cases/plugin-react/react-compiler-babel/src/App.jsx | Uses the new hook so the build output should reflect hook compilation. |
| e2e/cases/plugin-react/react-compiler-babel/rsbuild.config.ts | Updates Babel include/exclude to match templates; disables minify to support bundle inspection. |
| e2e/cases/plugin-react/react-compiler-babel/index.test.ts | Adds assertions to verify the hook was compiled in the build bundle. |
| e2e/cases/create-rsbuild/tools.test.ts | Adds coverage to ensure generated config contains the new include/exclude settings. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Code Review
This pull request enhances the integration and testing of the React Compiler within Rsbuild. It refines Babel plugin configurations by broadening the include patterns and adding exclude rules for node_modules in both e2e tests and project templates. A new useCounter hook is introduced in an e2e test to provide a more complex scenario for the React Compiler, and new assertions are added to verify the presence of React Compiler artifacts in the bundled output. Additionally, minify: false is set in one test configuration, likely to aid in inspecting the compiler's output. A review comment suggests improving the robustness of a string search in an e2e test by using a regular expression to account for potential whitespace variations.
Summary
Update the
create-rsbuildReact Compiler templates with the React docs change so Babel includes.js,.jsx,.ts, and.tsxfiles and excludesnode_modules.Related Links