Skip to content

Commit d0e6f20

Browse files
committed
Some of the internals are shared in shared/
Like ReactDebugCurrentFrame. So we preserve those simple cases on the old name while still moving dispatcher and cache to the separate one.
1 parent bab361f commit d0e6f20

9 files changed

+57
-9
lines changed

packages/react/src/React.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ import {
6767
cloneElementWithValidation,
6868
} from './ReactElementValidator';
6969
import {createServerContext} from './ReactServerContext';
70-
import ReactSharedInternals from './ReactSharedInternals';
70+
import ReactSharedInternals from './ReactSharedInternalsClient';
7171
import {startTransition} from './ReactStartTransition';
7272
import {act} from './ReactAct';
7373

packages/react/src/ReactServerContext.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ import type {
1919
} from 'shared/ReactTypes';
2020

2121
import {enableServerContext} from 'shared/ReactFeatureFlags';
22-
import ReactSharedInternals from './ReactSharedInternals';
23-
24-
const ContextRegistry = ReactSharedInternals.ContextRegistry;
22+
import {ContextRegistry} from './ReactServerContextRegistry';
2523

2624
export function createServerContext<T: ServerContextJSONValue>(
2725
globalName: string,
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
import ReactCurrentDispatcher from './ReactCurrentDispatcher';
9+
import ReactCurrentCache from './ReactCurrentCache';
10+
11+
const ReactServerSharedInternals = {
12+
ReactCurrentDispatcher,
13+
ReactCurrentCache,
14+
};
15+
16+
export default ReactServerSharedInternals;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
import ReactCurrentOwner from './ReactCurrentOwner';
9+
import ReactDebugCurrentFrame from './ReactDebugCurrentFrame';
10+
import {enableServerContext} from 'shared/ReactFeatureFlags';
11+
import {ContextRegistry} from './ReactServerContextRegistry';
12+
13+
const ReactSharedInternals = {
14+
ReactCurrentOwner,
15+
};
16+
17+
if (__DEV__) {
18+
ReactSharedInternals.ReactDebugCurrentFrame = ReactDebugCurrentFrame;
19+
}
20+
21+
if (enableServerContext) {
22+
ReactSharedInternals.ContextRegistry = ContextRegistry;
23+
}
24+
25+
export default ReactSharedInternals;

packages/react/src/ReactSharedSubset.experimental.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@
1010
// Patch fetch
1111
import './ReactFetch';
1212

13+
export {default as __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED} from './ReactSharedInternalsServer';
14+
15+
export {default as __SECRET_SERVER_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED} from './ReactServerSharedInternals';
16+
1317
export {
14-
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED as __SECRET_SERVER_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
1518
Children,
1619
Fragment,
1720
Profiler,

packages/react/src/ReactSharedSubset.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@
1010
// Patch fetch
1111
import './ReactFetch';
1212

13+
export {default as __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED} from './ReactSharedInternalsServer';
14+
15+
export {default as __SECRET_SERVER_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED} from './ReactServerSharedInternals';
16+
1317
export {
14-
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED as __SECRET_SERVER_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
1518
Children,
1619
Fragment,
1720
Profiler,

scripts/jest/setupHostConfigs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ inlinedHostConfigs.forEach(rendererInfo => {
169169
// Make it possible to import this module inside
170170
// the React package itself.
171171
jest.mock('shared/ReactSharedInternals', () =>
172-
jest.requireActual('react/src/ReactSharedInternals')
172+
jest.requireActual('react/src/ReactSharedInternalsClient')
173173
);
174174

175175
// Make it possible to import this module inside

scripts/rollup/forks.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,11 @@ const forks = Object.freeze({
6060
entry,
6161
dependencies
6262
) => {
63-
if (entry === 'react' || entry === 'react/src/ReactSharedSubset.js') {
64-
return './packages/react/src/ReactSharedInternals.js';
63+
if (entry === 'react') {
64+
return './packages/react/src/ReactSharedInternalsClient.js';
65+
}
66+
if (entry === 'react/src/ReactSharedSubset.js') {
67+
return './packages/react/src/ReactSharedInternalsServer.js';
6568
}
6669
if (!entry.startsWith('react/') && dependencies.indexOf('react') === -1) {
6770
// React internals are unavailable if we can't reference the package.

0 commit comments

Comments
 (0)