Skip to content

[rcr, Flight] Add throwing RSC entrypoint for compiler-runtime#75

Open
everettbu wants to merge 3 commits into
mainfrom
sebbie/rcr-rsc-throw
Open

[rcr, Flight] Add throwing RSC entrypoint for compiler-runtime#75
everettbu wants to merge 3 commits into
mainfrom
sebbie/rcr-rsc-throw

Conversation

@everettbu

@everettbu everettbu commented Dec 12, 2025

Copy link
Copy Markdown

Mirror of facebook/react#32056
Original author: eps1lon


Summary

Alternate to react/react#29057
Closes react/react#31702

Adds a throwing stub to react-compiler-runtime and react/compiler-runtime if the react-server import condition is set that throw:

The React Compiler is currently not supported in a React Server environment.
Ensure that modules imported with a `react-server` condition are not compiled with the React Compiler.
Libraries should provide a dedicated `react-server` entrypoint that wasn't compiled with the React Compiler.

For react-compiler-runtime I had to add exports so this is technically a breaking change. Though I think we consider this only to be used as a Compiler target so any react-compiler-runtime/dist/* or react-compiler-runtime/src/* imports are already out of SemVer guarantees I guess?

How did you test this change?

Tested react/compiler-runtime with CSB artifacts merged with a local yarn build react-compiler-runtime.react-server,react/compiler-runtime

react-compiler-runtime I just manually checked that dist/ is as expected:

$ ls dist
index.d.ts                index.js.map              index.react-server.js.map
index.js                  index.react-server.js

@everettbu everettbu added CLA Signed React Core Team Opened by a member of the React Core Team labels Dec 12, 2025
@greptile-apps

greptile-apps Bot commented Dec 12, 2025

Copy link
Copy Markdown

Greptile Overview

Greptile Summary

Added throwing RSC (React Server Components) entrypoints for react-compiler-runtime and react/compiler-runtime that prevent React Compiler usage in react-server environments.

  • Added new throwing stubs that display clear error message when React Compiler is used in react-server context
  • Configured package exports to map react-server condition to throwing entrypoints
  • Updated build scripts to generate both client and server bundles
  • Added error code 545 for minification in production builds
  • Follows existing React pattern for react-server entrypoints (similar to jsx-runtime)

All changes are well-structured and consistent with React's architecture. The error messages are clear and actionable.

Confidence Score: 5/5

  • This PR is safe to merge with no issues found
  • All changes follow established patterns in the React codebase, properly implement the throwing stub pattern used elsewhere, include appropriate error codes for production minification, and maintain consistency with similar react-server entrypoints like jsx-runtime
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
compiler/packages/react-compiler-runtime/package.json 5/5 Added exports field with react-server condition mapping to throwing stub
packages/react/package.json 5/5 Updated compiler-runtime exports to use dedicated react-server entrypoint instead of default
compiler/packages/react-compiler-runtime/scripts/build.js 5/5 Updated build to handle multiple entry points (index.ts and index.react-server.ts)
scripts/rollup/bundles.js 5/5 Added bundle configuration for react-compiler-runtime.react-server with error code minification enabled

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

9 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Compiler Bug]: server components built externally by the compiler error when rendered in app

2 participants