Skip to content

Commit dad4604

Browse files
committed
Rename The Secret Export of Server Internals (#28786)
We have a different set of dispatchers that Flight uses. This also includes the `jsx-runtime` which must also be aliased to use the right version. To ensure the right versions are used together we rename the export of the SharedInternals from 'react' and alias it in relevant bundles. DiffTrain build for [c771016](c771016)
1 parent 74e25ca commit dad4604

7 files changed

+64
-40
lines changed

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
d50323eb845c5fde0d720cae888bf35dedd05506
1+
c771016e19384e4b6e42e1c275bdf03fe51c2907

compiled/facebook-www/ReactDOMServerStreaming-dev.modern.js

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2345,8 +2345,16 @@ if (__DEV__) {
23452345
: 'something with type "' + typeof thing + '"';
23462346
}
23472347

2348-
var ReactSharedInternals =
2349-
React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
2348+
var ReactSharedInternalsServer = // $FlowFixMe: It's defined in the one we resolve to.
2349+
React.__SECRET_SERVER_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
2350+
2351+
if (!ReactSharedInternalsServer) {
2352+
throw new Error(
2353+
'The "react" package in this environment is not configured correctly. ' +
2354+
'The "react-server" condition must be enabled in any environment that ' +
2355+
"runs React Server Components."
2356+
);
2357+
}
23502358

23512359
// same object across all transitions.
23522360

@@ -10735,10 +10743,10 @@ if (__DEV__) {
1073510743
var previousDispatcher = null;
1073610744

1073710745
{
10738-
previousDispatcher = ReactSharedInternals.H; // Set the dispatcher in DEV because this might be call in the render function
10746+
previousDispatcher = ReactSharedInternalsServer.H; // Set the dispatcher in DEV because this might be call in the render function
1073910747
// for warnings.
1074010748

10741-
ReactSharedInternals.H = null;
10749+
ReactSharedInternalsServer.H = null;
1074210750
disableLogs();
1074310751
}
1074410752
/**
@@ -10931,7 +10939,7 @@ if (__DEV__) {
1093110939
reentry = false;
1093210940

1093310941
{
10934-
ReactSharedInternals.H = previousDispatcher;
10942+
ReactSharedInternalsServer.H = previousDispatcher;
1093510943
reenableLogs();
1093610944
}
1093710945

@@ -13779,22 +13787,22 @@ if (__DEV__) {
1377913787
}
1378013788

1378113789
var prevContext = getActiveContext();
13782-
var prevDispatcher = ReactSharedInternals.H;
13783-
ReactSharedInternals.H = HooksDispatcher;
13790+
var prevDispatcher = ReactSharedInternalsServer.H;
13791+
ReactSharedInternalsServer.H = HooksDispatcher;
1378413792
var prevCacheDispatcher = null;
1378513793

1378613794
{
13787-
prevCacheDispatcher = ReactSharedInternals.C;
13788-
ReactSharedInternals.C = DefaultCacheDispatcher;
13795+
prevCacheDispatcher = ReactSharedInternalsServer.C;
13796+
ReactSharedInternalsServer.C = DefaultCacheDispatcher;
1378913797
}
1379013798

1379113799
var prevRequest = currentRequest;
1379213800
currentRequest = request;
1379313801
var prevGetCurrentStackImpl = null;
1379413802

1379513803
{
13796-
prevGetCurrentStackImpl = ReactSharedInternals.getCurrentStack;
13797-
ReactSharedInternals.getCurrentStack = getCurrentStackInDEV;
13804+
prevGetCurrentStackImpl = ReactSharedInternalsServer.getCurrentStack;
13805+
ReactSharedInternalsServer.getCurrentStack = getCurrentStackInDEV;
1379813806
}
1379913807

1380013808
var prevResumableState = currentResumableState;
@@ -13820,14 +13828,14 @@ if (__DEV__) {
1382013828
fatalError(request, error);
1382113829
} finally {
1382213830
setCurrentResumableState(prevResumableState);
13823-
ReactSharedInternals.H = prevDispatcher;
13831+
ReactSharedInternalsServer.H = prevDispatcher;
1382413832

1382513833
{
13826-
ReactSharedInternals.C = prevCacheDispatcher;
13834+
ReactSharedInternalsServer.C = prevCacheDispatcher;
1382713835
}
1382813836

1382913837
{
13830-
ReactSharedInternals.getCurrentStack = prevGetCurrentStackImpl;
13838+
ReactSharedInternalsServer.getCurrentStack = prevGetCurrentStackImpl;
1383113839
}
1383213840

1383313841
if (prevDispatcher === HooksDispatcher) {

compiled/facebook-www/ReactDOMServerStreaming-prod.modern.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,13 @@ function sanitizeURL(url) {
278278
? "javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')"
279279
: url;
280280
}
281-
var ReactSharedInternals =
282-
React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
283-
sharedNotPendingObject = {
281+
var ReactSharedInternalsServer =
282+
React.__SECRET_SERVER_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
283+
if (!ReactSharedInternalsServer)
284+
throw Error(
285+
'The "react" package in this environment is not configured correctly. The "react-server" condition must be enabled in any environment that runs React Server Components.'
286+
);
287+
var sharedNotPendingObject = {
284288
pending: !1,
285289
data: null,
286290
method: null,
@@ -5261,10 +5265,10 @@ exports.renderNextChunk = function (stream) {
52615265
stream = stream.destination;
52625266
if (2 !== request.status) {
52635267
var prevContext = currentActiveSnapshot,
5264-
prevDispatcher = ReactSharedInternals.H;
5265-
ReactSharedInternals.H = HooksDispatcher;
5266-
var prevCacheDispatcher = ReactSharedInternals.C;
5267-
ReactSharedInternals.C = DefaultCacheDispatcher;
5268+
prevDispatcher = ReactSharedInternalsServer.H;
5269+
ReactSharedInternalsServer.H = HooksDispatcher;
5270+
var prevCacheDispatcher = ReactSharedInternalsServer.C;
5271+
ReactSharedInternalsServer.C = DefaultCacheDispatcher;
52685272
var prevRequest = currentRequest;
52695273
currentRequest = request;
52705274
var prevResumableState = currentResumableState;
@@ -5418,8 +5422,8 @@ exports.renderNextChunk = function (stream) {
54185422
logRecoverableError(request, error, {}), fatalError(request, error);
54195423
} finally {
54205424
(currentResumableState = prevResumableState),
5421-
(ReactSharedInternals.H = prevDispatcher),
5422-
(ReactSharedInternals.C = prevCacheDispatcher),
5425+
(ReactSharedInternalsServer.H = prevDispatcher),
5426+
(ReactSharedInternalsServer.C = prevCacheDispatcher),
54235427
prevDispatcher === HooksDispatcher && switchContext(prevContext),
54245428
(currentRequest = prevRequest);
54255429
}

compiled/facebook-www/ReactFlightDOMServer-dev.modern.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,10 +1146,18 @@ if (__DEV__) {
11461146
return "\n " + str;
11471147
}
11481148

1149-
var ReactSharedInternals$1 =
1150-
React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
1149+
var ReactSharedInternalsServer = // $FlowFixMe: It's defined in the one we resolve to.
1150+
React.__SECRET_SERVER_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
11511151

1152-
var ReactSharedInternals = ReactSharedInternals$1;
1152+
if (!ReactSharedInternalsServer) {
1153+
throw new Error(
1154+
'The "react" package in this environment is not configured correctly. ' +
1155+
'The "react-server" condition must be enabled in any environment that ' +
1156+
"runs React Server Components."
1157+
);
1158+
}
1159+
1160+
var ReactSharedInternals = ReactSharedInternalsServer;
11531161

11541162
function patchConsole(consoleInst, methodName) {
11551163
var descriptor = Object.getOwnPropertyDescriptor(consoleInst, methodName);

compiled/facebook-www/ReactFlightDOMServer-prod.modern.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,13 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
430430
"\n " + str + "\n " + objectOrArray)
431431
: "\n " + str;
432432
}
433-
var ReactSharedInternals$1 =
434-
React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
435-
ObjectPrototype = Object.prototype,
433+
var ReactSharedInternalsServer =
434+
React.__SECRET_SERVER_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
435+
if (!ReactSharedInternalsServer)
436+
throw Error(
437+
'The "react" package in this environment is not configured correctly. The "react-server" condition must be enabled in any environment that runs React Server Components.'
438+
);
439+
var ObjectPrototype = Object.prototype,
436440
stringify = JSON.stringify;
437441
function defaultErrorHandler(error) {
438442
console.error(error);
@@ -1018,8 +1022,8 @@ function retryTask(request, task) {
10181022
}
10191023
}
10201024
function performWork(request) {
1021-
var prevDispatcher = ReactSharedInternals$1.H;
1022-
ReactSharedInternals$1.H = HooksDispatcher;
1025+
var prevDispatcher = ReactSharedInternalsServer.H;
1026+
ReactSharedInternalsServer.H = HooksDispatcher;
10231027
var prevRequest = currentRequest;
10241028
currentRequest$1 = currentRequest = request;
10251029
try {
@@ -1032,7 +1036,7 @@ function performWork(request) {
10321036
} catch (error) {
10331037
logRecoverableError(request, error), fatalError(request, error);
10341038
} finally {
1035-
(ReactSharedInternals$1.H = prevDispatcher),
1039+
(ReactSharedInternalsServer.H = prevDispatcher),
10361040
(currentRequest$1 = null),
10371041
(currentRequest = prevRequest);
10381042
}
@@ -1085,11 +1089,11 @@ exports.renderToDestination = function (destination, model, options) {
10851089
);
10861090
var onError = options ? options.onError : void 0;
10871091
if (
1088-
null !== ReactSharedInternals$1.C &&
1089-
ReactSharedInternals$1.C !== DefaultCacheDispatcher
1092+
null !== ReactSharedInternalsServer.C &&
1093+
ReactSharedInternalsServer.C !== DefaultCacheDispatcher
10901094
)
10911095
throw Error("Currently React only supports one RSC renderer at a time.");
1092-
ReactSharedInternals$1.C = DefaultCacheDispatcher;
1096+
ReactSharedInternalsServer.C = DefaultCacheDispatcher;
10931097
var abortSet = new Set();
10941098
options = [];
10951099
var hints = new Set();

compiled/facebook-www/ReactServer-dev.modern.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3083,7 +3083,7 @@ if (__DEV__) {
30833083

30843084
function noop() {}
30853085

3086-
var ReactVersion = "19.0.0-www-modern-85fbc52f";
3086+
var ReactVersion = "19.0.0-www-modern-15824b86";
30873087

30883088
// Patch fetch
30893089
var Children = {
@@ -3105,7 +3105,7 @@ if (__DEV__) {
31053105
exports.Profiler = REACT_PROFILER_TYPE;
31063106
exports.StrictMode = REACT_STRICT_MODE_TYPE;
31073107
exports.Suspense = REACT_SUSPENSE_TYPE;
3108-
exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED =
3108+
exports.__SECRET_SERVER_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED =
31093109
ReactSharedInternals;
31103110
exports.cache = cache;
31113111
exports.cloneElement = cloneElement;

compiled/facebook-www/ReactServer-prod.modern.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ exports.Fragment = REACT_FRAGMENT_TYPE;
388388
exports.Profiler = REACT_PROFILER_TYPE;
389389
exports.StrictMode = REACT_STRICT_MODE_TYPE;
390390
exports.Suspense = REACT_SUSPENSE_TYPE;
391-
exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED =
391+
exports.__SECRET_SERVER_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED =
392392
ReactSharedInternals;
393393
exports.cache = function (fn) {
394394
return function () {
@@ -587,4 +587,4 @@ exports.useId = function () {
587587
exports.useMemo = function (create, deps) {
588588
return ReactSharedInternals.H.useMemo(create, deps);
589589
};
590-
exports.version = "19.0.0-www-modern-fc045344";
590+
exports.version = "19.0.0-www-modern-5bb44c5c";

0 commit comments

Comments
 (0)