Skip to content

docs: introduce @swc/react-compiler to make react-compiler fast #10823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

GiveMe-A-Name
Copy link
Member

Summary

We are introducing a recommendation to use @swc/react-compiler for pre-compilation to reduce the number of files processed by babel-loader, which is known to add significant compilation time.

Related links

Checklist

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

Copy link

netlify bot commented Jun 27, 2025

Deploy Preview for rspack ready!

Name Link
🔨 Latest commit 2ffb916
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/685e5384aafe740008853a74
😎 Deploy Preview https://deploy-preview-10823--rspack.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@GiveMe-A-Name GiveMe-A-Name requested review from chenjiahan and Copilot and removed request for chenjiahan June 27, 2025 08:09
@github-actions github-actions bot added the release: document release: document related release(mr only) label Jun 27, 2025
Copilot

This comment was marked as resolved.

{
// Must be run before 'builtin:swc-loader' to ensure that the file is processed by the React Compiler
// So we add it to the beginning of the rule
test: (resouce) => /\.jsx$/.test(resouce) && isReactCompilerRequiredSync(fs.readFileSync(resouce)),
Copy link
Member

Choose a reason for hiding this comment

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

I'm curious about the performance impact of readFileSync , can we do a performance comparison test to verify the performance difference between @swc/react-compiler and the previous babel-loader?

Copy link
Member Author

Choose a reason for hiding this comment

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

Got it, i will check it later

@github-actions github-actions bot added the team The issue/pr is created by the member of Rspack. label Jun 27, 2025
GiveMe-A-Name and others added 3 commits June 27, 2025 16:13
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@suguanYang
Copy link

Just out of curiosity, are we already use @swc/react-compiler to use the react-compiler compling on jsx files? or only use the isReactCompilerRequired to skip some files as we still use babel to ReactCompiler?

I was looking for use react-compiler with swc, but the links leads me here. 😀

@chenjiahan
Copy link
Member

Currently @swc/react-compiler only provides the isReactCompilerRequired method to skip some files, and React Compiler still depends on running Babel (ref).

Unfortunately, in our early tests, isReactCompilerRequired did not bring significant performance improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release: document release: document related release(mr only) team The issue/pr is created by the member of Rspack.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants