Skip to content
Permalink
Browse files

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 7a1691cdff209249b49a4472ba87b542980a5f71
Showing with 127 additions and 561 deletions.
  1. +1 −1 packages/react-art/src/ReactART.js
  2. +1 −1 packages/react-dom/src/client/ReactDOM.js
  3. +1 −1 packages/react-dom/src/client/ReactDOMLegacy.js
  4. +5 −2 packages/react-dom/src/client/ReactDOMRoot.js
  5. +1 −1 packages/react-dom/src/events/EnterLeaveEventPlugin.js
  6. +1 −1 packages/react-dom/src/events/ReactDOMEventListener.js
  7. +1 −1 packages/react-dom/src/events/ReactDOMEventReplaying.js
  8. +1 −1 packages/react-dom/src/server/ReactDOMFizzServerBrowser.js
  9. +5 −1 packages/react-dom/src/server/ReactDOMFizzServerNode.js
  10. +1 −1 packages/react-dom/src/test-utils/ReactTestUtils.js
  11. +1 −1 packages/react-dom/testing.classic.fb.js
  12. +1 −1 packages/react-dom/testing.experimental.js
  13. +1 −1 packages/react-dom/testing.js
  14. +1 −1 packages/react-dom/testing.modern.fb.js
  15. +1 −1 packages/react-dom/testing.stable.js
  16. +1 −1 packages/react-flight-dom-webpack/src/ReactFlightDOMClient.js
  17. +2 −2 packages/react-flight-dom-webpack/src/ReactFlightDOMServerBrowser.js
  18. +2 −2 packages/react-flight-dom-webpack/src/ReactFlightDOMServerNode.js
  19. +2 −12 packages/react-flight/index.js
  20. +0 −24 packages/react-flight/inline-typed.js
  21. +0 −11 packages/react-flight/inline.dom-browser.js
  22. +0 −11 packages/react-flight/inline.dom.js
  23. +1 −1 packages/react-native-renderer/src/ReactFabric.js
  24. +1 −1 packages/react-native-renderer/src/ReactNativeFiberInspector.js
  25. +1 −1 packages/react-native-renderer/src/ReactNativeRenderer.js
  26. +1 −1 packages/react-noop-renderer/src/ReactNoopFlightClient.js
  27. +1 −1 packages/react-noop-renderer/src/ReactNoopFlightServer.js
  28. +2 −2 packages/react-noop-renderer/src/ReactNoopPersistent.js
  29. +2 −12 packages/react-reconciler/index.js
  30. +0 −24 packages/react-reconciler/inline-typed.js
  31. +0 −11 packages/react-reconciler/inline.art.js
  32. +0 −11 packages/react-reconciler/inline.dom-browser.js
  33. +0 −11 packages/react-reconciler/inline.dom.js
  34. +0 −11 packages/react-reconciler/inline.fabric.js
  35. +0 −11 packages/react-reconciler/inline.fire.js
  36. +0 −11 packages/react-reconciler/inline.native.js
  37. +0 −11 packages/react-reconciler/inline.test.js
  38. +0 −7 packages/react-reconciler/npm/persistent.js
  39. +0 −1 packages/react-reconciler/package.json
  40. +0 −12 packages/react-reconciler/persistent.js
  41. +1 −1 packages/react-reconciler/src/ReactFiberClassComponent.js
  42. +1 −1 packages/react-reconciler/src/ReactFiberContext.js
  43. +1 −1 packages/react-reconciler/src/ReactFiberReconciler.js
  44. +0 −24 packages/react-server/flight.inline-typed.js
  45. +0 −11 packages/react-server/flight.inline.dom-browser.js
  46. +0 −11 packages/react-server/flight.inline.dom.js
  47. +2 −12 packages/react-server/flight.js
  48. +2 −12 packages/react-server/index.js
  49. +0 −24 packages/react-server/inline-typed.js
  50. +0 −11 packages/react-server/inline.dom-browser.js
  51. +0 −11 packages/react-server/inline.dom.js
  52. +2 −2 packages/react-test-renderer/src/ReactTestRenderer.js
  53. +0 −62 packages/shared/forks/ReactFeatureFlags.persistent.js
  54. +3 −0 scripts/flow/config/flowconfig
  55. +28 −18 scripts/flow/createFlowConfigs.js
  56. +22 −129 scripts/jest/setupHostConfigs.js
  57. +0 −9 scripts/rollup/bundles.js
  58. +0 −2 scripts/rollup/forks.js
  59. +26 −1 scripts/shared/inlinedHostConfigs.js
@@ -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';
@@ -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';
@@ -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';
@@ -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,
@@ -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';

@@ -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 = {
@@ -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,
@@ -28,7 +28,7 @@ import {
getNearestMountedFiber,
getContainerFromFiber,
getSuspenseInstanceFromFiber,
} from 'react-reconciler/reflection';
} from 'react-reconciler/src/ReactFiberTreeReflection';
import {
attemptToDispatchEvent,
addResponderEventSystemEvent,
@@ -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;
@@ -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);
@@ -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,
@@ -8,4 +8,4 @@
*/

export * from './index.classic.fb.js';
export {act} from 'react-reconciler/inline.dom';
export {act} from 'react-reconciler/src/ReactFiberReconciler';
@@ -8,4 +8,4 @@
*/

export * from './index.experimental.js';
export {act} from 'react-reconciler/inline.dom';
export {act} from 'react-reconciler/src/ReactFiberReconciler';
@@ -8,4 +8,4 @@
*/

export * from './index.js';
export {act} from 'react-reconciler/inline.dom';
export {act} from 'react-reconciler/src/ReactFiberReconciler';
@@ -8,4 +8,4 @@
*/

export * from './index.modern.fb.js';
export {act} from 'react-reconciler/inline.dom';
export {act} from 'react-reconciler/src/ReactFiberReconciler';
@@ -8,4 +8,4 @@
*/

export * from './index.stable.js';
export {act} from 'react-reconciler/inline.dom';
export {act} from 'react-reconciler/src/ReactFiberReconciler';
@@ -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();
@@ -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;
@@ -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);
@@ -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';

This file was deleted.

This file was deleted.

This file was deleted.

@@ -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';
@@ -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';
@@ -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';
@@ -14,7 +14,7 @@
* environment.
*/

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

import ReactFlightClient from 'react-flight';

@@ -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';

@@ -14,7 +14,7 @@
* environment.
*/

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

export const {
@@ -47,6 +47,6 @@ export const {
dumpTree,
getRoot,
} = createReactNoop(
ReactFiberPersistentReconciler, // reconciler
ReactFiberReconciler, // reconciler
false, // useMutation
);
@@ -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';

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 7a1691c

Please sign in to comment.
You can’t perform that action at this time.