Skip to content

Commit

Permalink
Move react-dom implementation files to react-dom-bindings (#25345)
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 authored Sep 28, 2022
1 parent 3de9264 commit 97d75c9
Show file tree
Hide file tree
Showing 106 changed files with 72 additions and 104 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
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

'use strict';

jest.mock('../events/isEventSupported');
jest.mock('react-dom-bindings/src/events/isEventSupported');

describe('InvalidEventListeners', () => {
let React;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('ReactDOMSelection', () => {
beforeEach(() => {
React = require('react');
ReactDOM = require('react-dom');
ReactDOMSelection = require('../client/ReactDOMSelection');
ReactDOMSelection = require('react-dom-bindings/src/client/ReactDOMSelection');

({getModernOffsetsFromPoints} = ReactDOMSelection);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/__tests__/ReactMount-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

'use strict';

const {COMMENT_NODE} = require('../shared/HTMLNodeType');
const {COMMENT_NODE} = require('react-dom-bindings/src/shared/HTMLNodeType');

let React;
let ReactDOM;
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
'use strict';

// TODO: can we express this test with only public API?
const getNodeForCharacterOffset = require('../getNodeForCharacterOffset')
const getNodeForCharacterOffset = require('react-dom-bindings/src/client/getNodeForCharacterOffset')
.default;

// Create node from HTML string
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 @@ -1382,7 +1382,7 @@ describe('ResponderEventPlugin', () => {
const getLowestCommonAncestor = require('react-native-renderer/src/legacy-events/ResponderEventPlugin')
.getLowestCommonAncestor;
// This works by accident and will likely break in the future.
const ReactDOMComponentTree = require('react-dom/src/client/ReactDOMComponentTree');
const ReactDOMComponentTree = require('react-dom-bindings/src/client/ReactDOMComponentTree');

class ChildComponent extends React.Component {
render() {
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/ReactDOMServerLegacyFormatConfig';
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';
Loading

0 comments on commit 97d75c9

Please sign in to comment.