Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
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.
  • Loading branch information
sebmarkbage committed Sep 29, 2023
commit f9ddb5e640ec7d4a8d0d6f6a961da73e9ca1b836
2 changes: 1 addition & 1 deletion packages/react/src/React.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ import {
cloneElementWithValidation,
} from './ReactElementValidator';
import {createServerContext} from './ReactServerContext';
import ReactSharedInternals from './ReactSharedInternals';
import ReactSharedInternals from './ReactSharedInternalsClient';
import {startTransition} from './ReactStartTransition';
import {act} from './ReactAct';

Expand Down
4 changes: 1 addition & 3 deletions packages/react/src/ReactServerContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ import type {
} from 'shared/ReactTypes';

import {enableServerContext} from 'shared/ReactFeatureFlags';
import ReactSharedInternals from './ReactSharedInternals';

const ContextRegistry = ReactSharedInternals.ContextRegistry;
import {ContextRegistry} from './ReactServerContextRegistry';

export function createServerContext<T: ServerContextJSONValue>(
globalName: string,
Expand Down
16 changes: 16 additions & 0 deletions packages/react/src/ReactServerSharedInternals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

import ReactCurrentDispatcher from './ReactCurrentDispatcher';
import ReactCurrentCache from './ReactCurrentCache';

const ReactServerSharedInternals = {
ReactCurrentDispatcher,
ReactCurrentCache,
};

export default ReactServerSharedInternals;
25 changes: 25 additions & 0 deletions packages/react/src/ReactSharedInternalsServer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

import ReactCurrentOwner from './ReactCurrentOwner';
import ReactDebugCurrentFrame from './ReactDebugCurrentFrame';
import {enableServerContext} from 'shared/ReactFeatureFlags';
import {ContextRegistry} from './ReactServerContextRegistry';

const ReactSharedInternals = {
ReactCurrentOwner,
};

if (__DEV__) {
ReactSharedInternals.ReactDebugCurrentFrame = ReactDebugCurrentFrame;
}

if (enableServerContext) {
ReactSharedInternals.ContextRegistry = ContextRegistry;
}

export default ReactSharedInternals;
5 changes: 4 additions & 1 deletion packages/react/src/ReactSharedSubset.experimental.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
// Patch fetch
import './ReactFetch';

export {default as __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED} from './ReactSharedInternalsServer';

export {default as __SECRET_SERVER_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED} from './ReactServerSharedInternals';

export {
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED as __SECRET_SERVER_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
Children,
Fragment,
Profiler,
Expand Down
5 changes: 4 additions & 1 deletion packages/react/src/ReactSharedSubset.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
// Patch fetch
import './ReactFetch';

export {default as __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED} from './ReactSharedInternalsServer';

export {default as __SECRET_SERVER_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED} from './ReactServerSharedInternals';

export {
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED as __SECRET_SERVER_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
Children,
Fragment,
Profiler,
Expand Down
2 changes: 1 addition & 1 deletion scripts/jest/setupHostConfigs.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ inlinedHostConfigs.forEach(rendererInfo => {
// Make it possible to import this module inside
// the React package itself.
jest.mock('shared/ReactSharedInternals', () =>
jest.requireActual('react/src/ReactSharedInternals')
jest.requireActual('react/src/ReactSharedInternalsClient')
);

// Make it possible to import this module inside
Expand Down
7 changes: 5 additions & 2 deletions scripts/rollup/forks.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,11 @@ const forks = Object.freeze({
entry,
dependencies
) => {
if (entry === 'react' || entry === 'react/src/ReactSharedSubset.js') {
return './packages/react/src/ReactSharedInternals.js';
if (entry === 'react') {
return './packages/react/src/ReactSharedInternalsClient.js';
}
if (entry === 'react/src/ReactSharedSubset.js') {
return './packages/react/src/ReactSharedInternalsServer.js';
}
if (!entry.startsWith('react/') && dependencies.indexOf('react') === -1) {
// React internals are unavailable if we can't reference the package.
Expand Down