Repository navigation
Run React Compiler natively in framework mode #15720
nikolailehbrink
started this conversation in
Proposals
Replies: 2 comments 3 replies
|
I know this is a little different to what you propose but you can use the native rust react compiler with react router framework mode right now. https://blog.master.dev/react-now-rusted-all-the-way-out/ I actually implemented this in a learning/portfolio site: fringe4life/van-life#162 and it's pretty straight forward. Hope this helps if you want to use the native rust version for now! |
3 replies
plugins: [
// React Router owns JSX/HMR — do not add @vitejs/plugin-react's react()
reactRouter(),
reactCompiler({
compiler: { panicThreshold: "critical_errors", reportDiagnostics: true },
}),
],this is a simplified version of my vite config using the acusti version. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Framework mode has no supported way to run React Compiler, and the new native path (Oxc's Rust port) only ships inside
@vitejs/plugin-react, which framework mode replaces. Apps end up hand-writing a transform plugin or adding a Babel pass that the native compiler was meant to remove.Problem
@vitejs/plugin-react6.1 runs React Compiler natively withreact({ compiler: true }), throughoxc-transform-react. Framework mode usesreactRouter()instead of@vitejs/plugin-react, and adding both runs Fast Refresh twice (react router framework conflict with @vitejs/plugin-react #12870, How to enable React Compiler in framework mode? reactRouter() plugin has no Babel escape hatch #15180).reactRouter()takes no option for the compiler. The react.dev install guide points React Router users tovite-plugin-babelwithbabel-plugin-react-compiler, the slower path the native compiler replaces; [Docs]: React Compiler - Vite #13796 asked for docs and was closed.enforce: "pre"plugin that callsoxc-transform-reactwithjsx: "preserve"on client modules and leaves JSX and Fast Refresh toreactRouter(). It relies on plugin order and on howreactRouter()handles route modules and route chunks, neither of which is documented, so it can break on any release.Proposal
Support the compiler in
reactRouter()itself, for examplereactRouter({ reactCompiler: true | ReactCompilerOptions }), which would:oxc-transform-react(an optional peer dependency, as in@vitejs/plugin-react) on client modules before the Fast Refresh transform, including route modules and their split chunks;If that is out of scope, documenting the supported plugin order for a separate compiler pass would already help.
Versions
@react-router/dev8.5.1), React 19.3@vitejs/plugin-react6.1.2,oxc-transform-react0.156.0Related: #15180, #13796, #12870
All reactions