-
Notifications
You must be signed in to change notification settings - Fork 24
build: Ship components optimized with React Compiler #992
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pull request successfully integrates the React Compiler into the build process, which is a significant step towards improving runtime performance. The changes to the build configuration and dependencies are logical. I've identified two minor issues in the custom logger implementation within babel.config.js: one regarding inconsistent log output that could hinder debugging, and another related to potential runtime errors due to unsafe property access. After addressing these points, the PR should be ready for merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR successfully integrates the React Compiler, a valuable performance optimization. The description provides a clear assessment of the impact, including the bundle size increase and the list of components not yet optimized. The build configuration changes are logical and well-implemented. A minor suggestion is provided to improve the compiler's logging behavior to differentiate between actual errors and expected compilation skips, which would make build outputs cleaner. With that adjustment, the PR is correct.
Short description
This integrates the React compiler to optimize components within the distributed packages, minimizing re-renders.
Caveats are that not all components/hooks can be optimized at this time, and those that are have not been deprecated will be addressed in future PRs:
MenuList,ContextMenuTriggerCheckboxFieldTabsTooltipKeyboardShortcutuseForkRefuseIdpolymorphicComponent, such asBox,Inline,Stack, etc.The bundle size would also be increased by about 37%, due to the compiler's generated code (but not the runtime, which is externalized):
The left shows the bundle size using the current build step on main, using Rollup's TypeScript plugin. The right is with the compiler enabled with Babel, which had some of babel's runtime helpers inlined. Once externalized, the bundle size is decreased slightly:
Taking out the React compiler, while leaving the Babel build flow in place, results in a smaller bundle compared to when building with the TypeScript plugin (but very slightly larger gzipped), confirming that the size increase can be mostly attributed to the compiler's output.
References
https://react.dev/reference/react-compiler/compiling-libraries
PR Checklist