Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Refactor Host Config Infra (getting rid of .inline*.js) (#18240)
* Require deep for reconcilers

* Delete inline* files

* Delete react-reconciler/persistent

This no longer makes any sense because it react-reconciler takes
supportsMutation or supportsPersistence as options. It's no longer based
on feature flags.

* Fix jest mocking

* Fix Flow strategy

We now explicitly list which paths we want to be checked by a renderer.
For every other renderer config we ignore those paths.

Nothing is "any" typed. So if some transitive dependency isn't reachable
it won't be accidentally "any" that leaks.
  • Loading branch information
sebmarkbage committed Mar 7, 2020
1 parent 238b57f commit 7a1691c
Show file tree
Hide file tree
Showing 59 changed files with 127 additions and 561 deletions.
2 changes: 1 addition & 1 deletion packages/react-art/src/ReactART.js
Expand Up @@ -12,7 +12,7 @@ import {
createContainer,
updateContainer,
injectIntoDevTools,
} from 'react-reconciler/inline.art';
} from 'react-reconciler/src/ReactFiberReconciler';
import Transform from 'art/core/transform';
import Mode from 'art/modes/current';
import FastNoSideEffects from 'art/modes/fast-noSideEffects';
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/client/ReactDOM.js
Expand Up @@ -35,7 +35,7 @@ import {
attemptUserBlockingHydration,
attemptContinuousHydration,
attemptHydrationAtCurrentPriority,
} from 'react-reconciler/inline.dom';
} from 'react-reconciler/src/ReactFiberReconciler';
import {createPortal as createPortalImpl} from 'shared/ReactPortal';
import {canUseDOM} from 'shared/ExecutionEnvironment';
import {setBatchingImplementation} from 'legacy-events/ReactGenericBatching';
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/client/ReactDOMLegacy.js
Expand Up @@ -31,7 +31,7 @@ import {
getPublicRootInstance,
findHostInstance,
findHostInstanceWithWarning,
} from 'react-reconciler/inline.dom';
} from 'react-reconciler/src/ReactFiberReconciler';
import getComponentName from 'shared/getComponentName';
import invariant from 'shared/invariant';
import ReactSharedInternals from 'shared/ReactSharedInternals';
Expand Down
7 changes: 5 additions & 2 deletions packages/react-dom/src/client/ReactDOMRoot.js
Expand Up @@ -13,7 +13,7 @@ import type {ReactNodeList} from 'shared/ReactTypes';
// TODO: This type is shared between the reconciler and ReactDOM, but will
// eventually be lifted out to the renderer.
import type {FiberRoot} from 'react-reconciler/src/ReactFiberRoot';
import {findHostInstanceWithNoPortals} from 'react-reconciler/inline.dom';
import {findHostInstanceWithNoPortals} from 'react-reconciler/src/ReactFiberReconciler';

export type RootType = {
render(children: ReactNodeList): void,
Expand Down Expand Up @@ -45,7 +45,10 @@ import {
DOCUMENT_FRAGMENT_NODE,
} from '../shared/HTMLNodeType';

import {createContainer, updateContainer} from 'react-reconciler/inline.dom';
import {
createContainer,
updateContainer,
} from 'react-reconciler/src/ReactFiberReconciler';
import invariant from 'shared/invariant';
import {BlockingRoot, ConcurrentRoot, LegacyRoot} from 'shared/ReactRootTags';

Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/events/EnterLeaveEventPlugin.js
Expand Up @@ -21,7 +21,7 @@ import {
getNodeFromInstance,
} from '../client/ReactDOMComponentTree';
import {HostComponent, HostText} from 'shared/ReactWorkTags';
import {getNearestMountedFiber} from 'react-reconciler/reflection';
import {getNearestMountedFiber} from 'react-reconciler/src/ReactFiberTreeReflection';
import {enableModernEventSystem} from 'shared/ReactFeatureFlags';

const eventTypes = {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/events/ReactDOMEventListener.js
Expand Up @@ -32,7 +32,7 @@ import {
getNearestMountedFiber,
getContainerFromFiber,
getSuspenseInstanceFromFiber,
} from 'react-reconciler/reflection';
} from 'react-reconciler/src/ReactFiberTreeReflection';
import {HostRoot, SuspenseComponent} from 'shared/ReactWorkTags';
import {
type EventSystemFlags,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/events/ReactDOMEventReplaying.js
Expand Up @@ -28,7 +28,7 @@ import {
getNearestMountedFiber,
getContainerFromFiber,
getSuspenseInstanceFromFiber,
} from 'react-reconciler/reflection';
} from 'react-reconciler/src/ReactFiberTreeReflection';
import {
attemptToDispatchEvent,
addResponderEventSystemEvent,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/server/ReactDOMFizzServerBrowser.js
Expand Up @@ -13,7 +13,7 @@ import {
createRequest,
startWork,
startFlowing,
} from 'react-server/inline.dom-browser';
} from 'react-server/src/ReactFizzStreamer';

function renderToReadableStream(children: ReactNodeList): ReadableStream {
let request;
Expand Down
6 changes: 5 additions & 1 deletion packages/react-dom/src/server/ReactDOMFizzServerNode.js
Expand Up @@ -10,7 +10,11 @@
import type {ReactNodeList} from 'shared/ReactTypes';
import type {Writable} from 'stream';

import {createRequest, startWork, startFlowing} from 'react-server/inline.dom';
import {
createRequest,
startWork,
startFlowing,
} from 'react-server/src/ReactFizzStreamer';

function createDrainHandler(destination, request) {
return () => startFlowing(request);
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/test-utils/ReactTestUtils.js
Expand Up @@ -7,7 +7,7 @@

import * as React from 'react';
import * as ReactDOM from 'react-dom';
import {findCurrentFiberUsingSlowPath} from 'react-reconciler/reflection';
import {findCurrentFiberUsingSlowPath} from 'react-reconciler/src/ReactFiberTreeReflection';
import {get as getInstance} from 'shared/ReactInstanceMap';
import {
ClassComponent,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/testing.classic.fb.js
Expand Up @@ -8,4 +8,4 @@
*/

export * from './index.classic.fb.js';
export {act} from 'react-reconciler/inline.dom';
export {act} from 'react-reconciler/src/ReactFiberReconciler';
2 changes: 1 addition & 1 deletion packages/react-dom/testing.experimental.js
Expand Up @@ -8,4 +8,4 @@
*/

export * from './index.experimental.js';
export {act} from 'react-reconciler/inline.dom';
export {act} from 'react-reconciler/src/ReactFiberReconciler';
2 changes: 1 addition & 1 deletion packages/react-dom/testing.js
Expand Up @@ -8,4 +8,4 @@
*/

export * from './index.js';
export {act} from 'react-reconciler/inline.dom';
export {act} from 'react-reconciler/src/ReactFiberReconciler';
2 changes: 1 addition & 1 deletion packages/react-dom/testing.modern.fb.js
Expand Up @@ -8,4 +8,4 @@
*/

export * from './index.modern.fb.js';
export {act} from 'react-reconciler/inline.dom';
export {act} from 'react-reconciler/src/ReactFiberReconciler';
2 changes: 1 addition & 1 deletion packages/react-dom/testing.stable.js
Expand Up @@ -8,4 +8,4 @@
*/

export * from './index.stable.js';
export {act} from 'react-reconciler/inline.dom';
export {act} from 'react-reconciler/src/ReactFiberReconciler';
Expand Up @@ -16,7 +16,7 @@ import {
processStringChunk,
processBinaryChunk,
complete,
} from 'react-flight/inline.dom';
} from 'react-flight/src/ReactFlightClient';

function startReadingFromStream(response, stream: ReadableStream): void {
let reader = stream.getReader();
Expand Down
Expand Up @@ -7,13 +7,13 @@
* @flow
*/

import type {ReactModel} from 'react-server/flight.inline-typed';
import type {ReactModel} from 'react-server/src/ReactFlightServer';

import {
createRequest,
startWork,
startFlowing,
} from 'react-server/flight.inline.dom-browser';
} from 'react-server/src/ReactFlightServer';

function renderToReadableStream(model: ReactModel): ReadableStream {
let request;
Expand Down
Expand Up @@ -7,14 +7,14 @@
* @flow
*/

import type {ReactModel} from 'react-server/flight.inline-typed';
import type {ReactModel} from 'react-server/src/ReactFlightServer';
import type {Writable} from 'stream';

import {
createRequest,
startWork,
startFlowing,
} from 'react-server/flight.inline.dom';
} from 'react-server/src/ReactFlightServer';

function createDrainHandler(destination, request) {
return () => startFlowing(request);
Expand Down
14 changes: 2 additions & 12 deletions packages/react-flight/index.js
Expand Up @@ -3,18 +3,8 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

// This entry point is intentionally not typed. It exists only for third-party
// renderers. The renderers we ship (such as React DOM) instead import a named
// "inline" entry point (for example, `react-server/inline.dom`). It uses
// the same code, but the Flow configuration redirects the host config to its
// real implementation so we can check it against exact intended host types.
//
// Only one renderer (the one you passed to `yarn flow <renderer>`) is fully
// type-checked at any given time. The Flow config maps the
// `react-server/inline.<renderer>` import (which is *not* Flow typed) to
// `react-server/inline-typed` (which *is*) for the current renderer.
// On CI, we run Flow checks for each renderer separately.

export * from './src/ReactFlightClient';
24 changes: 0 additions & 24 deletions packages/react-flight/inline-typed.js

This file was deleted.

11 changes: 0 additions & 11 deletions packages/react-flight/inline.dom-browser.js

This file was deleted.

11 changes: 0 additions & 11 deletions packages/react-flight/inline.dom.js

This file was deleted.

2 changes: 1 addition & 1 deletion packages/react-native-renderer/src/ReactFabric.js
Expand Up @@ -24,7 +24,7 @@ import {
updateContainer,
injectIntoDevTools,
getPublicRootInstance,
} from 'react-reconciler/inline.fabric';
} from 'react-reconciler/src/ReactFiberReconciler';

import {createPortal as createPortalImpl} from 'shared/ReactPortal';
import {setBatchingImplementation} from 'legacy-events/ReactGenericBatching';
Expand Down
Expand Up @@ -12,7 +12,7 @@ import type {Fiber} from 'react-reconciler/src/ReactFiber';
import {
findCurrentHostFiber,
findCurrentFiberUsingSlowPath,
} from 'react-reconciler/reflection';
} from 'react-reconciler/src/ReactFiberTreeReflection';
import getComponentName from 'shared/getComponentName';
import {HostComponent} from 'shared/ReactWorkTags';
import invariant from 'shared/invariant';
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-renderer/src/ReactNativeRenderer.js
Expand Up @@ -23,7 +23,7 @@ import {
updateContainer,
injectIntoDevTools,
getPublicRootInstance,
} from 'react-reconciler/inline.native';
} from 'react-reconciler/src/ReactFiberReconciler';
// TODO: direct imports like some-package/src/* are bad. Fix me.
import {getStackByFiberInDevAndProd} from 'react-reconciler/src/ReactCurrentFiber';
import {createPortal as createPortalImpl} from 'shared/ReactPortal';
Expand Down
2 changes: 1 addition & 1 deletion packages/react-noop-renderer/src/ReactNoopFlightClient.js
Expand Up @@ -14,7 +14,7 @@
* environment.
*/

import type {ReactModelRoot} from 'react-flight/inline-typed';
import type {ReactModelRoot} from 'react-flight';

import ReactFlightClient from 'react-flight';

Expand Down
2 changes: 1 addition & 1 deletion packages/react-noop-renderer/src/ReactNoopFlightServer.js
Expand Up @@ -14,7 +14,7 @@
* environment.
*/

import type {ReactModel} from 'react-server/flight.inline-typed';
import type {ReactModel} from 'react-server/src/ReactFlightServer';

import ReactFlightServer from 'react-server/flight';

Expand Down
4 changes: 2 additions & 2 deletions packages/react-noop-renderer/src/ReactNoopPersistent.js
Expand Up @@ -14,7 +14,7 @@
* environment.
*/

import ReactFiberPersistentReconciler from 'react-reconciler/persistent';
import ReactFiberReconciler from 'react-reconciler';
import createReactNoop from './createReactNoop';

export const {
Expand Down Expand Up @@ -47,6 +47,6 @@ export const {
dumpTree,
getRoot,
} = createReactNoop(
ReactFiberPersistentReconciler, // reconciler
ReactFiberReconciler, // reconciler
false, // useMutation
);
14 changes: 2 additions & 12 deletions packages/react-reconciler/index.js
Expand Up @@ -3,18 +3,8 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

// This entry point is intentionally not typed. It exists only for third-party
// renderers. The renderers we ship (such as React DOM) instead import a named
// "inline" entry point (for example, `react-reconciler/inline.dom`). It uses
// the same code, but the Flow configuration redirects the host config to its
// real implementation so we can check it against exact intended host types.
//
// Only one renderer (the one you passed to `yarn flow <renderer>`) is fully
// type-checked at any given time. The Flow config maps the
// `react-reconciler/inline.<renderer>` import (which is *not* Flow typed) to
// `react-reconciler/inline-typed` (which *is*) for the current renderer.
// On CI, we run Flow checks for each renderer separately.

export * from './src/ReactFiberReconciler';
24 changes: 0 additions & 24 deletions packages/react-reconciler/inline-typed.js

This file was deleted.

11 changes: 0 additions & 11 deletions packages/react-reconciler/inline.art.js

This file was deleted.

11 changes: 0 additions & 11 deletions packages/react-reconciler/inline.dom-browser.js

This file was deleted.

11 changes: 0 additions & 11 deletions packages/react-reconciler/inline.dom.js

This file was deleted.

0 comments on commit 7a1691c

Please sign in to comment.