Skip to content

Commit

Permalink
Move react-dom implementation files to react-dom-bindings
Browse files Browse the repository at this point in the history
This lets us share it with react-server-dom-webpack while still having a
dependency on react-dom. It also makes somewhat sense from a bundling
perspective since react-dom is an external to itself.
  • Loading branch information
sebmarkbage committed Sep 28, 2022
1 parent cb5084d commit 7821c55
Show file tree
Hide file tree
Showing 101 changed files with 67 additions and 99 deletions.
23 changes: 23 additions & 0 deletions packages/react-dom-bindings/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "react-dom-bindings",
"description": "React implementation details for react-dom.",
"version": "18.2.0",
"private": true,
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/facebook/react.git",
"directory": "packages/react-dom-bindings"
},
"keywords": [
"react"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/facebook/react/issues"
},
"homepage": "https://reactjs.org/",
"peerDependencies": {
"react": "^18.2.0"
}
}
2 changes: 1 addition & 1 deletion packages/react-dom/index.classic.fb.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @flow
*/

import {isEnabled} from './src/events/ReactDOMEventListener';
import {isEnabled} from 'react-dom-bindings/src/events/ReactDOMEventListener';

import Internals from './src/ReactDOMSharedInternals';

Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/src/ReactDOMSharedInternals.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import {batchedUpdates} from 'react-reconciler/src/ReactFiberReconciler';
import {
enqueueStateRestore,
restoreStateIfNeeded,
} from './events/ReactDOMControlledComponent';
} from 'react-dom-bindings/src/events/ReactDOMControlledComponent';
import {
getInstanceFromNode,
getNodeFromInstance,
getFiberCurrentPropsFromNode,
} from './client/ReactDOMComponentTree';
} from 'react-dom-bindings/src/client/ReactDOMComponentTree';

const Internals = {
usingClientEntryPoint: false,
Expand Down
14 changes: 7 additions & 7 deletions packages/react-dom/src/client/ReactDOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import type {ReactNodeList} from 'shared/ReactTypes';
import type {Container} from './ReactDOMHostConfig';
import type {Container} from 'react-dom-bindings/src/client/ReactDOMHostConfig';
import type {
RootType,
HydrateRootOptions,
Expand All @@ -27,7 +27,7 @@ import {
hydrateRoot as hydrateRootImpl,
isValidContainer,
} from './ReactDOMRoot';
import {createEventHandle} from './ReactDOMEventHandle';
import {createEventHandle} from 'react-dom-bindings/src/client/ReactDOMEventHandle';

import {
batchedUpdates,
Expand All @@ -50,18 +50,18 @@ import {canUseDOM} from 'shared/ExecutionEnvironment';
import ReactVersion from 'shared/ReactVersion';
import {enableNewReconciler} from 'shared/ReactFeatureFlags';

import {getClosestInstanceFromNode} from './ReactDOMComponentTree';
import {restoreControlledState} from './ReactDOMComponent';
import {getClosestInstanceFromNode} from 'react-dom-bindings/src/client/ReactDOMComponentTree';
import {restoreControlledState} from 'react-dom-bindings/src/client/ReactDOMComponent';
import {
setAttemptSynchronousHydration,
setAttemptDiscreteHydration,
setAttemptContinuousHydration,
setAttemptHydrationAtCurrentPriority,
setGetCurrentUpdatePriority,
setAttemptHydrationAtPriority,
} from '../events/ReactDOMEventReplaying';
import {setBatchingImplementation} from '../events/ReactDOMUpdateBatching';
import {setRestoreImplementation} from '../events/ReactDOMControlledComponent';
} from 'react-dom-bindings/src/events/ReactDOMEventReplaying';
import {setBatchingImplementation} from 'react-dom-bindings/src/events/ReactDOMUpdateBatching';
import {setRestoreImplementation} from 'react-dom-bindings/src/events/ReactDOMControlledComponent';
import Internals from '../ReactDOMSharedInternals';

setAttemptSynchronousHydration(attemptSynchronousHydration);
Expand Down
8 changes: 4 additions & 4 deletions packages/react-dom/src/client/ReactDOMLegacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @flow
*/

import type {Container} from './ReactDOMHostConfig';
import type {Container} from 'react-dom-bindings/src/client/ReactDOMHostConfig';
import type {FiberRoot} from 'react-reconciler/src/ReactInternalTypes';
import type {ReactNodeList} from 'shared/ReactTypes';

Expand All @@ -16,14 +16,14 @@ import {
isContainerMarkedAsRoot,
markContainerAsRoot,
unmarkContainerAsRoot,
} from './ReactDOMComponentTree';
import {listenToAllSupportedEvents} from '../events/DOMPluginEventSystem';
} from 'react-dom-bindings/src/client/ReactDOMComponentTree';
import {listenToAllSupportedEvents} from 'react-dom-bindings/src/events/DOMPluginEventSystem';
import {isValidContainerLegacy} from './ReactDOMRoot';
import {
DOCUMENT_NODE,
ELEMENT_NODE,
COMMENT_NODE,
} from '../shared/HTMLNodeType';
} from 'react-dom-bindings/src/shared/HTMLNodeType';

import {
createContainer,
Expand Down
8 changes: 4 additions & 4 deletions packages/react-dom/src/client/ReactDOMRoot.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type {
TransitionTracingCallbacks,
} from 'react-reconciler/src/ReactInternalTypes';

import {queueExplicitHydrationTarget} from '../events/ReactDOMEventReplaying';
import {queueExplicitHydrationTarget} from 'react-dom-bindings/src/events/ReactDOMEventReplaying';
import {REACT_ELEMENT_TYPE} from 'shared/ReactSymbols';
import {enableFloat} from 'shared/ReactFeatureFlags';

Expand Down Expand Up @@ -51,14 +51,14 @@ import {
isContainerMarkedAsRoot,
markContainerAsRoot,
unmarkContainerAsRoot,
} from './ReactDOMComponentTree';
import {listenToAllSupportedEvents} from '../events/DOMPluginEventSystem';
} from 'react-dom-bindings/src/client/ReactDOMComponentTree';
import {listenToAllSupportedEvents} from 'react-dom-bindings/src/events/DOMPluginEventSystem';
import {
ELEMENT_NODE,
COMMENT_NODE,
DOCUMENT_NODE,
DOCUMENT_FRAGMENT_NODE,
} from '../shared/HTMLNodeType';
} from 'react-dom-bindings/src/shared/HTMLNodeType';

import {
createContainer,
Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/src/server/ReactDOMFizzServerBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import type {ReactNodeList} from 'shared/ReactTypes';
import type {BootstrapScriptDescriptor} from './ReactDOMServerFormatConfig';
import type {BootstrapScriptDescriptor} from 'react-dom-bindings/src/server/ReactDOMServerFormatConfig';

import ReactVersion from 'shared/ReactVersion';

Expand All @@ -22,7 +22,7 @@ import {
import {
createResponseState,
createRootFormatContext,
} from './ReactDOMServerFormatConfig';
} from 'react-dom-bindings/src/server/ReactDOMServerFormatConfig';

type Options = {
identifierPrefix?: string,
Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/src/server/ReactDOMFizzServerNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import type {ReactNodeList} from 'shared/ReactTypes';
import type {Writable} from 'stream';
import type {BootstrapScriptDescriptor} from './ReactDOMServerFormatConfig';
import type {BootstrapScriptDescriptor} from 'react-dom-bindings/src/server/ReactDOMServerFormatConfig';
import type {Destination} from 'react-server/src/ReactServerStreamConfigNode';

import ReactVersion from 'shared/ReactVersion';
Expand All @@ -24,7 +24,7 @@ import {
import {
createResponseState,
createRootFormatContext,
} from './ReactDOMServerFormatConfig';
} from 'react-dom-bindings/src/server/ReactDOMServerFormatConfig';

function createDrainHandler(destination: Destination, request) {
return () => startFlowing(request, destination);
Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/src/server/ReactDOMFizzStaticBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import type {ReactNodeList} from 'shared/ReactTypes';
import type {BootstrapScriptDescriptor} from './ReactDOMServerFormatConfig';
import type {BootstrapScriptDescriptor} from 'react-dom-bindings/src/server/ReactDOMServerFormatConfig';

import ReactVersion from 'shared/ReactVersion';

Expand All @@ -22,7 +22,7 @@ import {
import {
createResponseState,
createRootFormatContext,
} from './ReactDOMServerFormatConfig';
} from 'react-dom-bindings/src/server/ReactDOMServerFormatConfig';

type Options = {
identifierPrefix?: string,
Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/src/server/ReactDOMFizzStaticNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import type {ReactNodeList} from 'shared/ReactTypes';
import type {BootstrapScriptDescriptor} from './ReactDOMServerFormatConfig';
import type {BootstrapScriptDescriptor} from 'react-dom-bindings/src/server/ReactDOMServerFormatConfig';

import {Writable, Readable} from 'stream';

Expand All @@ -24,7 +24,7 @@ import {
import {
createResponseState,
createRootFormatContext,
} from './ReactDOMServerFormatConfig';
} from 'react-dom-bindings/src/server/ReactDOMServerFormatConfig';

type Options = {
identifierPrefix?: string,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/server/ReactDOMLegacyServerImpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
import {
createResponseState,
createRootFormatContext,
} from './ReactDOMServerLegacyFormatConfig';
} from 'react-dom-bindings/src/server/ReactDOMServerLegacyFormatConfig';

type ServerOptions = {
identifierPrefix?: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
import {
createResponseState,
createRootFormatContext,
} from './ReactDOMServerLegacyFormatConfig';
} from 'react-dom-bindings/src/server/ReactDOMServerLegacyFormatConfig';

import {Readable} from 'stream';

Expand Down
59 changes: 0 additions & 59 deletions packages/react-dom/src/server/ReactThreadIDAllocator.js

This file was deleted.

4 changes: 2 additions & 2 deletions packages/react-dom/src/test-utils/ReactTestUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import {
HostComponent,
HostText,
} from 'react-reconciler/src/ReactWorkTags';
import {SyntheticEvent} from '../events/SyntheticEvent';
import {ELEMENT_NODE} from '../shared/HTMLNodeType';
import {SyntheticEvent} from 'react-dom-bindings/src/events/SyntheticEvent';
import {ELEMENT_NODE} from 'react-dom-bindings/src/shared/HTMLNodeType';
import {
rethrowCaughtError,
invokeGuardedCallbackAndCatchFirstError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
* @flow
*/

export * from 'react-dom/src/client/ReactDOMHostConfig';
export * from 'react-dom-bindings/src/client/ReactDOMHostConfig';
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
* @flow
*/

export * from 'react-dom/src/client/ReactDOMHostConfig';
export * from 'react-dom-bindings/src/client/ReactDOMHostConfig';
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
* @flow
*/

export * from 'react-dom/src/client/ReactDOMHostConfig';
export * from 'react-dom-bindings/src/client/ReactDOMHostConfig';
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
* @flow
*/

export * from 'react-dom/src/client/ReactDOMHostConfig';
export * from 'react-dom-bindings/src/client/ReactDOMHostConfig';
1 change: 1 addition & 0 deletions packages/react-server-dom-webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
},
"peerDependencies": {
"react": "^17.0.0",
"react-dom": "^17.0.0",
"webpack": "^5.59.0"
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
* @flow
*/

export * from 'react-dom/src/server/ReactDOMServerFormatConfig';
export * from 'react-dom-bindings/src/server/ReactDOMServerFormatConfig';
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
* @flow
*/

export * from 'react-dom/src/server/ReactDOMServerLegacyFormatConfig';
export * from 'react-dom-bindings/src/server/ReactDOMServerFormatConfig';
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
* @flow
*/

export * from 'react-dom/src/server/ReactDOMServerFormatConfig';
export * from 'react-dom-bindings/src/server/ReactDOMServerFormatConfig';
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
* @flow
*/

export * from 'react-dom/src/server/ReactDOMServerFormatConfig';
export * from 'react-dom-bindings/src/server/ReactDOMServerFormatConfig';
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
* @flow
*/

export * from 'react-dom/src/server/ReactDOMLegacyServerStreamConfig';
export * from 'react-dom-bindings/src/server/ReactDOMLegacyServerStreamConfig';
5 changes: 4 additions & 1 deletion scripts/shared/inlinedHostConfigs.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports = [
],
paths: [
'react-dom',
'react-dom-bindings',
'react-dom/client',
'react-dom/server',
'react-dom/server.node',
Expand Down Expand Up @@ -53,6 +54,7 @@ module.exports = [
],
paths: [
'react-dom',
'react-dom-bindings',
'react-dom/client',
'react-dom/server.browser',
'react-dom/static.browser',
Expand Down Expand Up @@ -80,6 +82,7 @@ module.exports = [
],
paths: [
'react-dom',
'react-dom-bindings',
'react-server-dom-webpack',
'react-dom/src/server/ReactDOMLegacyServerImpl.js', // not an entrypoint, but only usable in *Brower and *Node files
'react-dom/src/server/ReactDOMLegacyServerBrowser.js', // react-dom/server.browser
Expand Down Expand Up @@ -127,7 +130,7 @@ module.exports = [
'react-server-dom-relay/server',
'react-server-dom-relay/src/ReactDOMServerFB.js',
],
paths: ['react-dom', 'react-server-dom-relay'],
paths: ['react-dom', 'react-dom-bindings', 'react-server-dom-relay'],
isFlowTyped: true,
isServerSupported: true,
},
Expand Down

0 comments on commit 7821c55

Please sign in to comment.