@samitouri / QOS-React / commits / 7a1691cdff

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.

Sebastian Markbåge committed Mar 6, 2020 at 16:20 UTC 7a1691cdff209249b49a4472ba87b542980a5f71
59 files changed +127 -561
packages/react-art/src/ReactART.js
+1 -1
@@ -12,7 +12,7 @@ import {
12 createContainer,
13 updateContainer,
14 injectIntoDevTools,
15 -} from 'react-reconciler/inline.art';
15 +} from 'react-reconciler/src/ReactFiberReconciler';
16 import Transform from 'art/core/transform';
17 import Mode from 'art/modes/current';
18 import FastNoSideEffects from 'art/modes/fast-noSideEffects';
packages/react-dom/src/client/ReactDOM.js
+1 -1
@@ -35,7 +35,7 @@ import {
35 attemptUserBlockingHydration,
36 attemptContinuousHydration,
37 attemptHydrationAtCurrentPriority,
38 -} from 'react-reconciler/inline.dom';
38 +} from 'react-reconciler/src/ReactFiberReconciler';
39 import {createPortal as createPortalImpl} from 'shared/ReactPortal';
40 import {canUseDOM} from 'shared/ExecutionEnvironment';
41 import {setBatchingImplementation} from 'legacy-events/ReactGenericBatching';
packages/react-dom/src/client/ReactDOMLegacy.js
+1 -1
@@ -31,7 +31,7 @@ import {
31 getPublicRootInstance,
32 findHostInstance,
33 findHostInstanceWithWarning,
34 -} from 'react-reconciler/inline.dom';
34 +} from 'react-reconciler/src/ReactFiberReconciler';
35 import getComponentName from 'shared/getComponentName';
36 import invariant from 'shared/invariant';
37 import ReactSharedInternals from 'shared/ReactSharedInternals';
packages/react-dom/src/client/ReactDOMRoot.js
+5 -2
@@ -13,7 +13,7 @@ import type {ReactNodeList} from 'shared/ReactTypes';
13 // TODO: This type is shared between the reconciler and ReactDOM, but will
14 // eventually be lifted out to the renderer.
15 import type {FiberRoot} from 'react-reconciler/src/ReactFiberRoot';
16 -import {findHostInstanceWithNoPortals} from 'react-reconciler/inline.dom';
16 +import {findHostInstanceWithNoPortals} from 'react-reconciler/src/ReactFiberReconciler';
17
18 export type RootType = {
19 render(children: ReactNodeList): void,
@@ -45,7 +45,10 @@ import {
45 DOCUMENT_FRAGMENT_NODE,
46 } from '../shared/HTMLNodeType';
47
48 -import {createContainer, updateContainer} from 'react-reconciler/inline.dom';
48 +import {
49 + createContainer,
50 + updateContainer,
51 +} from 'react-reconciler/src/ReactFiberReconciler';
52 import invariant from 'shared/invariant';
53 import {BlockingRoot, ConcurrentRoot, LegacyRoot} from 'shared/ReactRootTags';
54
packages/react-dom/src/events/EnterLeaveEventPlugin.js
+1 -1
@@ -21,7 +21,7 @@ import {
21 getNodeFromInstance,
22 } from '../client/ReactDOMComponentTree';
23 import {HostComponent, HostText} from 'shared/ReactWorkTags';
24 -import {getNearestMountedFiber} from 'react-reconciler/reflection';
24 +import {getNearestMountedFiber} from 'react-reconciler/src/ReactFiberTreeReflection';
25 import {enableModernEventSystem} from 'shared/ReactFeatureFlags';
26
27 const eventTypes = {
packages/react-dom/src/events/ReactDOMEventListener.js
+1 -1
@@ -32,7 +32,7 @@ import {
32 getNearestMountedFiber,
33 getContainerFromFiber,
34 getSuspenseInstanceFromFiber,
35 -} from 'react-reconciler/reflection';
35 +} from 'react-reconciler/src/ReactFiberTreeReflection';
36 import {HostRoot, SuspenseComponent} from 'shared/ReactWorkTags';
37 import {
38 type EventSystemFlags,
packages/react-dom/src/events/ReactDOMEventReplaying.js
+1 -1
@@ -28,7 +28,7 @@ import {
28 getNearestMountedFiber,
29 getContainerFromFiber,
30 getSuspenseInstanceFromFiber,
31 -} from 'react-reconciler/reflection';
31 +} from 'react-reconciler/src/ReactFiberTreeReflection';
32 import {
33 attemptToDispatchEvent,
34 addResponderEventSystemEvent,
packages/react-dom/src/server/ReactDOMFizzServerBrowser.js
+1 -1
@@ -13,7 +13,7 @@ import {
13 createRequest,
14 startWork,
15 startFlowing,
16 -} from 'react-server/inline.dom-browser';
16 +} from 'react-server/src/ReactFizzStreamer';
17
18 function renderToReadableStream(children: ReactNodeList): ReadableStream {
19 let request;
packages/react-dom/src/server/ReactDOMFizzServerNode.js
+5 -1
@@ -10,7 +10,11 @@
10 import type {ReactNodeList} from 'shared/ReactTypes';
11 import type {Writable} from 'stream';
12
13 -import {createRequest, startWork, startFlowing} from 'react-server/inline.dom';
13 +import {
14 + createRequest,
15 + startWork,
16 + startFlowing,
17 +} from 'react-server/src/ReactFizzStreamer';
18
19 function createDrainHandler(destination, request) {
20 return () => startFlowing(request);
packages/react-dom/src/test-utils/ReactTestUtils.js
+1 -1
@@ -7,7 +7,7 @@
7
8 import * as React from 'react';
9 import * as ReactDOM from 'react-dom';
10 -import {findCurrentFiberUsingSlowPath} from 'react-reconciler/reflection';
10 +import {findCurrentFiberUsingSlowPath} from 'react-reconciler/src/ReactFiberTreeReflection';
11 import {get as getInstance} from 'shared/ReactInstanceMap';
12 import {
13 ClassComponent,
packages/react-dom/testing.classic.fb.js
+1 -1
@@ -8,4 +8,4 @@
8 */
9
10 export * from './index.classic.fb.js';
11 -export {act} from 'react-reconciler/inline.dom';
11 +export {act} from 'react-reconciler/src/ReactFiberReconciler';
packages/react-dom/testing.experimental.js
+1 -1
@@ -8,4 +8,4 @@
8 */
9
10 export * from './index.experimental.js';
11 -export {act} from 'react-reconciler/inline.dom';
11 +export {act} from 'react-reconciler/src/ReactFiberReconciler';
packages/react-dom/testing.js
+1 -1
@@ -8,4 +8,4 @@
8 */
9
10 export * from './index.js';
11 -export {act} from 'react-reconciler/inline.dom';
11 +export {act} from 'react-reconciler/src/ReactFiberReconciler';
packages/react-dom/testing.modern.fb.js
+1 -1
@@ -8,4 +8,4 @@
8 */
9
10 export * from './index.modern.fb.js';
11 -export {act} from 'react-reconciler/inline.dom';
11 +export {act} from 'react-reconciler/src/ReactFiberReconciler';
packages/react-dom/testing.stable.js
+1 -1
@@ -8,4 +8,4 @@
8 */
9
10 export * from './index.stable.js';
11 -export {act} from 'react-reconciler/inline.dom';
11 +export {act} from 'react-reconciler/src/ReactFiberReconciler';
packages/react-flight-dom-webpack/src/ReactFlightDOMClient.js
+1 -1
@@ -16,7 +16,7 @@ import {
16 processStringChunk,
17 processBinaryChunk,
18 complete,
19 -} from 'react-flight/inline.dom';
19 +} from 'react-flight/src/ReactFlightClient';
20
21 function startReadingFromStream(response, stream: ReadableStream): void {
22 let reader = stream.getReader();
packages/react-flight-dom-webpack/src/ReactFlightDOMServerBrowser.js
+2 -2
@@ -7,13 +7,13 @@
7 * @flow
8 */
9
10 -import type {ReactModel} from 'react-server/flight.inline-typed';
10 +import type {ReactModel} from 'react-server/src/ReactFlightServer';
11
12 import {
13 createRequest,
14 startWork,
15 startFlowing,
16 -} from 'react-server/flight.inline.dom-browser';
16 +} from 'react-server/src/ReactFlightServer';
17
18 function renderToReadableStream(model: ReactModel): ReadableStream {
19 let request;
packages/react-flight-dom-webpack/src/ReactFlightDOMServerNode.js
+2 -2
@@ -7,14 +7,14 @@
7 * @flow
8 */
9
10 -import type {ReactModel} from 'react-server/flight.inline-typed';
10 +import type {ReactModel} from 'react-server/src/ReactFlightServer';
11 import type {Writable} from 'stream';
12
13 import {
14 createRequest,
15 startWork,
16 startFlowing,
17 -} from 'react-server/flight.inline.dom';
17 +} from 'react-server/src/ReactFlightServer';
18
19 function createDrainHandler(destination, request) {
20 return () => startFlowing(request);
packages/react-flight/index.js
+2 -12
@@ -3,18 +3,8 @@
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 + *
7 + * @flow
8 */
9
8 -// This entry point is intentionally not typed. It exists only for third-party
9 -// renderers. The renderers we ship (such as React DOM) instead import a named
10 -// "inline" entry point (for example, `react-server/inline.dom`). It uses
11 -// the same code, but the Flow configuration redirects the host config to its
12 -// real implementation so we can check it against exact intended host types.
13 -//
14 -// Only one renderer (the one you passed to `yarn flow <renderer>`) is fully
15 -// type-checked at any given time. The Flow config maps the
16 -// `react-server/inline.<renderer>` import (which is *not* Flow typed) to
17 -// `react-server/inline-typed` (which *is*) for the current renderer.
18 -// On CI, we run Flow checks for each renderer separately.
19 -
10 export * from './src/ReactFlightClient';
packages/react-flight/inline-typed.js deleted
-24
@@ -1,24 +0,0 @@
1 -/**
2 - * Copyright (c) Facebook, Inc. and its affiliates.
3 - *
4 - * This source code is licensed under the MIT license found in the
5 - * LICENSE file in the root directory of this source tree.
6 - *
7 - * @flow
8 - */
9 -
10 -// This file must have the Flow annotation.
11 -//
12 -// This is the Flow-typed entry point for the renderer. It should not be
13 -// imported directly in code. Instead, our Flow configuration uses this entry
14 -// point for the currently checked renderer (the one you passed to `yarn flow`).
15 -//
16 -// For example, if you run `yarn flow dom`, `react-server/inline.dom` points
17 -// to this module (and thus will be considered Flow-typed). But other renderers
18 -// (e.g. `react-test-renderer`) will see stream as untyped during the check.
19 -//
20 -// We can't make all entry points typed at the same time because different
21 -// renderers have different host config types. So we check them one by one.
22 -// We run Flow on all renderers on CI.
23 -
24 -export * from './src/ReactFlightClient';
packages/react-flight/inline.dom-browser.js deleted
-11
@@ -1,11 +0,0 @@
1 -/**
2 - * Copyright (c) Facebook, Inc. and its affiliates.
3 - *
4 - * This source code is licensed under the MIT license found in the
5 - * LICENSE file in the root directory of this source tree.
6 - */
7 -
8 -// This file intentionally does *not* have the Flow annotation.
9 -// Don't add it. See `./inline-typed.js` for an explanation.
10 -
11 -export * from './src/ReactFlightClient';
packages/react-flight/inline.dom.js deleted
-11
@@ -1,11 +0,0 @@
1 -/**
2 - * Copyright (c) Facebook, Inc. and its affiliates.
3 - *
4 - * This source code is licensed under the MIT license found in the
5 - * LICENSE file in the root directory of this source tree.
6 - */
7 -
8 -// This file intentionally does *not* have the Flow annotation.
9 -// Don't add it. See `./inline-typed.js` for an explanation.
10 -
11 -export * from './src/ReactFlightClient';
packages/react-native-renderer/src/ReactFabric.js
+1 -1
@@ -24,7 +24,7 @@ import {
24 updateContainer,
25 injectIntoDevTools,
26 getPublicRootInstance,
27 -} from 'react-reconciler/inline.fabric';
27 +} from 'react-reconciler/src/ReactFiberReconciler';
28
29 import {createPortal as createPortalImpl} from 'shared/ReactPortal';
30 import {setBatchingImplementation} from 'legacy-events/ReactGenericBatching';
packages/react-native-renderer/src/ReactNativeFiberInspector.js
+1 -1
@@ -12,7 +12,7 @@ import type {Fiber} from 'react-reconciler/src/ReactFiber';
12 import {
13 findCurrentHostFiber,
14 findCurrentFiberUsingSlowPath,
15 -} from 'react-reconciler/reflection';
15 +} from 'react-reconciler/src/ReactFiberTreeReflection';
16 import getComponentName from 'shared/getComponentName';
17 import {HostComponent} from 'shared/ReactWorkTags';
18 import invariant from 'shared/invariant';
packages/react-native-renderer/src/ReactNativeRenderer.js
+1 -1
@@ -23,7 +23,7 @@ import {
23 updateContainer,
24 injectIntoDevTools,
25 getPublicRootInstance,
26 -} from 'react-reconciler/inline.native';
26 +} from 'react-reconciler/src/ReactFiberReconciler';
27 // TODO: direct imports like some-package/src/* are bad. Fix me.
28 import {getStackByFiberInDevAndProd} from 'react-reconciler/src/ReactCurrentFiber';
29 import {createPortal as createPortalImpl} from 'shared/ReactPortal';
packages/react-noop-renderer/src/ReactNoopFlightClient.js
+1 -1
@@ -14,7 +14,7 @@
14 * environment.
15 */
16
17 -import type {ReactModelRoot} from 'react-flight/inline-typed';
17 +import type {ReactModelRoot} from 'react-flight';
18
19 import ReactFlightClient from 'react-flight';
20
packages/react-noop-renderer/src/ReactNoopFlightServer.js
+1 -1
@@ -14,7 +14,7 @@
14 * environment.
15 */
16
17 -import type {ReactModel} from 'react-server/flight.inline-typed';
17 +import type {ReactModel} from 'react-server/src/ReactFlightServer';
18
19 import ReactFlightServer from 'react-server/flight';
20
packages/react-noop-renderer/src/ReactNoopPersistent.js
+2 -2
@@ -14,7 +14,7 @@
14 * environment.
15 */
16
17 -import ReactFiberPersistentReconciler from 'react-reconciler/persistent';
17 +import ReactFiberReconciler from 'react-reconciler';
18 import createReactNoop from './createReactNoop';
19
20 export const {
@@ -47,6 +47,6 @@ export const {
47 dumpTree,
48 getRoot,
49 } = createReactNoop(
50 - ReactFiberPersistentReconciler, // reconciler
50 + ReactFiberReconciler, // reconciler
51 false, // useMutation
52 );
packages/react-reconciler/index.js
+2 -12
@@ -3,18 +3,8 @@
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 + *
7 + * @flow
8 */
9
8 -// This entry point is intentionally not typed. It exists only for third-party
9 -// renderers. The renderers we ship (such as React DOM) instead import a named
10 -// "inline" entry point (for example, `react-reconciler/inline.dom`). It uses
11 -// the same code, but the Flow configuration redirects the host config to its
12 -// real implementation so we can check it against exact intended host types.
13 -//
14 -// Only one renderer (the one you passed to `yarn flow <renderer>`) is fully
15 -// type-checked at any given time. The Flow config maps the
16 -// `react-reconciler/inline.<renderer>` import (which is *not* Flow typed) to
17 -// `react-reconciler/inline-typed` (which *is*) for the current renderer.
18 -// On CI, we run Flow checks for each renderer separately.
19 -
10 export * from './src/ReactFiberReconciler';
packages/react-reconciler/inline-typed.js deleted
-24
@@ -1,24 +0,0 @@
1 -/**
2 - * Copyright (c) Facebook, Inc. and its affiliates.
3 - *
4 - * This source code is licensed under the MIT license found in the
5 - * LICENSE file in the root directory of this source tree.
6 - *
7 - * @flow
8 - */
9 -
10 -// This file must have the Flow annotation.
11 -//
12 -// This is the Flow-typed entry point for the reconciler. It should not be
13 -// imported directly in code. Instead, our Flow configuration uses this entry
14 -// point for the currently checked renderer (the one you passed to `yarn flow`).
15 -//
16 -// For example, if you run `yarn flow dom`, `react-reconciler/inline.dom` points
17 -// to this module (and thus will be considered Flow-typed). But other renderers
18 -// (e.g. `react-test-renderer`) will see reconciler as untyped during the check.
19 -//
20 -// We can't make all entry points typed at the same time because different
21 -// renderers have different host config types. So we check them one by one.
22 -// We run Flow on all renderers on CI.
23 -
24 -export * from './src/ReactFiberReconciler';
packages/react-reconciler/inline.art.js deleted
-11
@@ -1,11 +0,0 @@
1 -/**
2 - * Copyright (c) Facebook, Inc. and its affiliates.
3 - *
4 - * This source code is licensed under the MIT license found in the
5 - * LICENSE file in the root directory of this source tree.
6 - */
7 -
8 -// This file intentionally does *not* have the Flow annotation.
9 -// Don't add it. See `./inline-typed.js` for an explanation.
10 -
11 -export * from './src/ReactFiberReconciler';
packages/react-reconciler/inline.dom-browser.js deleted
-11
@@ -1,11 +0,0 @@
1 -/**
2 - * Copyright (c) Facebook, Inc. and its affiliates.
3 - *
4 - * This source code is licensed under the MIT license found in the
5 - * LICENSE file in the root directory of this source tree.
6 - */
7 -
8 -// This file intentionally does *not* have the Flow annotation.
9 -// Don't add it. See `./inline-typed.js` for an explanation.
10 -
11 -export * from './src/ReactFiberReconciler';
packages/react-reconciler/inline.dom.js deleted
-11
@@ -1,11 +0,0 @@
1 -/**
2 - * Copyright (c) Facebook, Inc. and its affiliates.
3 - *
4 - * This source code is licensed under the MIT license found in the
5 - * LICENSE file in the root directory of this source tree.
6 - */
7 -
8 -// This file intentionally does *not* have the Flow annotation.
9 -// Don't add it. See `./inline-typed.js` for an explanation.
10 -
11 -export * from './src/ReactFiberReconciler';
packages/react-reconciler/inline.fabric.js deleted
-11
@@ -1,11 +0,0 @@
1 -/**
2 - * Copyright (c) Facebook, Inc. and its affiliates.
3 - *
4 - * This source code is licensed under the MIT license found in the
5 - * LICENSE file in the root directory of this source tree.
6 - */
7 -
8 -// This file intentionally does *not* have the Flow annotation.
9 -// Don't add it. See `./inline-typed.js` for an explanation.
10 -
11 -export * from './src/ReactFiberReconciler';
packages/react-reconciler/inline.fire.js deleted
-11
@@ -1,11 +0,0 @@
1 -/**
2 - * Copyright (c) Facebook, Inc. and its affiliates.
3 - *
4 - * This source code is licensed under the MIT license found in the
5 - * LICENSE file in the root directory of this source tree.
6 - */
7 -
8 -// This file intentionally does *not* have the Flow annotation.
9 -// Don't add it. See `./inline-typed.js` for an explanation.
10 -
11 -export * from './src/ReactFiberReconciler';
packages/react-reconciler/inline.native.js deleted
-11
@@ -1,11 +0,0 @@
1 -/**
2 - * Copyright (c) Facebook, Inc. and its affiliates.
3 - *
4 - * This source code is licensed under the MIT license found in the
5 - * LICENSE file in the root directory of this source tree.
6 - */
7 -
8 -// This file intentionally does *not* have the Flow annotation.
9 -// Don't add it. See `./inline-typed.js` for an explanation.
10 -
11 -export * from './src/ReactFiberReconciler';
packages/react-reconciler/inline.test.js deleted
-11
@@ -1,11 +0,0 @@
1 -/**
2 - * Copyright (c) Facebook, Inc. and its affiliates.
3 - *
4 - * This source code is licensed under the MIT license found in the
5 - * LICENSE file in the root directory of this source tree.
6 - */
7 -
8 -// This file intentionally does *not* have the Flow annotation.
9 -// Don't add it. See `./inline-typed.js` for an explanation.
10 -
11 -export * from './src/ReactFiberReconciler';
packages/react-reconciler/npm/persistent.js deleted
-7
@@ -1,7 +0,0 @@
1 -'use strict';
2 -
3 -if (process.env.NODE_ENV === 'production') {
4 - module.exports = require('./cjs/react-reconciler-persistent.production.min.js');
5 -} else {
6 - module.exports = require('./cjs/react-reconciler-persistent.development.js');
7 -}
packages/react-reconciler/package.json
-1
@@ -13,7 +13,6 @@
13 "README.md",
14 "build-info.json",
15 "index.js",
16 - "persistent.js",
16 "reflection.js",
17 "cjs/"
18 ],
packages/react-reconciler/persistent.js deleted
-12
@@ -1,12 +0,0 @@
1 -/**
2 - * Copyright (c) Facebook, Inc. and its affiliates.
3 - *
4 - * This source code is licensed under the MIT license found in the
5 - * LICENSE file in the root directory of this source tree.
6 - */
7 -
8 -'use strict';
9 -
10 -// This is the same export as in index.js,
11 -// with persistent reconciler flags turned on.
12 -export * from './src/ReactFiberReconciler';
packages/react-reconciler/src/ReactFiberClassComponent.js
+1 -1
@@ -19,7 +19,7 @@ import {
19 warnAboutDeprecatedLifecycles,
20 } from 'shared/ReactFeatureFlags';
21 import ReactStrictModeWarnings from './ReactStrictModeWarnings';
22 -import {isMounted} from 'react-reconciler/reflection';
22 +import {isMounted} from 'react-reconciler/src/ReactFiberTreeReflection';
23 import {get as getInstance, set as setInstance} from 'shared/ReactInstanceMap';
24 import shallowEqual from 'shared/shallowEqual';
25 import getComponentName from 'shared/getComponentName';
packages/react-reconciler/src/ReactFiberContext.js
+1 -1
@@ -10,7 +10,7 @@
10 import type {Fiber} from './ReactFiber';
11 import type {StackCursor} from './ReactFiberStack';
12
13 -import {isFiberMounted} from 'react-reconciler/reflection';
13 +import {isFiberMounted} from 'react-reconciler/src/ReactFiberTreeReflection';
14 import {disableLegacyContext} from 'shared/ReactFeatureFlags';
15 import {ClassComponent, HostRoot} from 'shared/ReactWorkTags';
16 import getComponentName from 'shared/getComponentName';
packages/react-reconciler/src/ReactFiberReconciler.js
+1 -1
@@ -27,7 +27,7 @@ import type {
27 import {
28 findCurrentHostFiber,
29 findCurrentHostFiberWithNoPortals,
30 -} from 'react-reconciler/reflection';
30 +} from 'react-reconciler/src/ReactFiberTreeReflection';
31 import {get as getInstance} from 'shared/ReactInstanceMap';
32 import {
33 HostComponent,
packages/react-server/flight.inline-typed.js deleted
-24
@@ -1,24 +0,0 @@
1 -/**
2 - * Copyright (c) Facebook, Inc. and its affiliates.
3 - *
4 - * This source code is licensed under the MIT license found in the
5 - * LICENSE file in the root directory of this source tree.
6 - *
7 - * @flow
8 - */
9 -
10 -// This file must have the Flow annotation.
11 -//
12 -// This is the Flow-typed entry point for the renderer. It should not be
13 -// imported directly in code. Instead, our Flow configuration uses this entry
14 -// point for the currently checked renderer (the one you passed to `yarn flow`).
15 -//
16 -// For example, if you run `yarn flow dom`, `react-server/flight.inline.dom` points
17 -// to this module (and thus will be considered Flow-typed). But other renderers
18 -// (e.g. `react-test-renderer`) will see stream as untyped during the check.
19 -//
20 -// We can't make all entry points typed at the same time because different
21 -// renderers have different host config types. So we check them one by one.
22 -// We run Flow on all renderers on CI.
23 -
24 -export * from './src/ReactFlightServer';
packages/react-server/flight.inline.dom-browser.js deleted
-11
@@ -1,11 +0,0 @@
1 -/**
2 - * Copyright (c) Facebook, Inc. and its affiliates.
3 - *
4 - * This source code is licensed under the MIT license found in the
5 - * LICENSE file in the root directory of this source tree.
6 - */
7 -
8 -// This file intentionally does *not* have the Flow annotation.
9 -// Don't add it. See `./inline-typed.js` for an explanation.
10 -
11 -export * from './src/ReactFlightServer';
packages/react-server/flight.inline.dom.js deleted
-11
@@ -1,11 +0,0 @@
1 -/**
2 - * Copyright (c) Facebook, Inc. and its affiliates.
3 - *
4 - * This source code is licensed under the MIT license found in the
5 - * LICENSE file in the root directory of this source tree.
6 - */
7 -
8 -// This file intentionally does *not* have the Flow annotation.
9 -// Don't add it. See `./inline-typed.js` for an explanation.
10 -
11 -export * from './src/ReactFlightServer';
packages/react-server/flight.js
+2 -12
@@ -3,18 +3,8 @@
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 + *
7 + * @flow
8 */
9
8 -// This entry point is intentionally not typed. It exists only for third-party
9 -// renderers. The renderers we ship (such as React DOM) instead import a named
10 -// "inline" entry point (for example, `react-server/flight.inline.dom`). It uses
11 -// the same code, but the Flow configuration redirects the host config to its
12 -// real implementation so we can check it against exact intended host types.
13 -//
14 -// Only one renderer (the one you passed to `yarn flow <renderer>`) is fully
15 -// type-checked at any given time. The Flow config maps the
16 -// `react-server/flight.inline.<renderer>` import (which is *not* Flow typed) to
17 -// `react-server/flight.inline-typed` (which *is*) for the current renderer.
18 -// On CI, we run Flow checks for each renderer separately.
19 -
10 export * from './src/ReactFlightServer';
packages/react-server/index.js
+2 -12
@@ -3,18 +3,8 @@
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 + *
7 + * @flow
8 */
9
8 -// This entry point is intentionally not typed. It exists only for third-party
9 -// renderers. The renderers we ship (such as React DOM) instead import a named
10 -// "inline" entry point (for example, `react-server/inline.dom`). It uses
11 -// the same code, but the Flow configuration redirects the host config to its
12 -// real implementation so we can check it against exact intended host types.
13 -//
14 -// Only one renderer (the one you passed to `yarn flow <renderer>`) is fully
15 -// type-checked at any given time. The Flow config maps the
16 -// `react-server/inline.<renderer>` import (which is *not* Flow typed) to
17 -// `react-server/inline-typed` (which *is*) for the current renderer.
18 -// On CI, we run Flow checks for each renderer separately.
19 -
10 export * from './src/ReactFizzStreamer';
packages/react-server/inline-typed.js deleted
-24
@@ -1,24 +0,0 @@
1 -/**
2 - * Copyright (c) Facebook, Inc. and its affiliates.
3 - *
4 - * This source code is licensed under the MIT license found in the
5 - * LICENSE file in the root directory of this source tree.
6 - *
7 - * @flow
8 - */
9 -
10 -// This file must have the Flow annotation.
11 -//
12 -// This is the Flow-typed entry point for the renderer. It should not be
13 -// imported directly in code. Instead, our Flow configuration uses this entry
14 -// point for the currently checked renderer (the one you passed to `yarn flow`).
15 -//
16 -// For example, if you run `yarn flow dom`, `react-server/inline.dom` points
17 -// to this module (and thus will be considered Flow-typed). But other renderers
18 -// (e.g. `react-test-renderer`) will see stream as untyped during the check.
19 -//
20 -// We can't make all entry points typed at the same time because different
21 -// renderers have different host config types. So we check them one by one.
22 -// We run Flow on all renderers on CI.
23 -
24 -export * from './src/ReactFizzStreamer';
packages/react-server/inline.dom-browser.js deleted
-11
@@ -1,11 +0,0 @@
1 -/**
2 - * Copyright (c) Facebook, Inc. and its affiliates.
3 - *
4 - * This source code is licensed under the MIT license found in the
5 - * LICENSE file in the root directory of this source tree.
6 - */
7 -
8 -// This file intentionally does *not* have the Flow annotation.
9 -// Don't add it. See `./inline-typed.js` for an explanation.
10 -
11 -export * from './src/ReactFizzStreamer';
packages/react-server/inline.dom.js deleted
-11
@@ -1,11 +0,0 @@
1 -/**
2 - * Copyright (c) Facebook, Inc. and its affiliates.
3 - *
4 - * This source code is licensed under the MIT license found in the
5 - * LICENSE file in the root directory of this source tree.
6 - */
7 -
8 -// This file intentionally does *not* have the Flow annotation.
9 -// Don't add it. See `./inline-typed.js` for an explanation.
10 -
11 -export * from './src/ReactFizzStreamer';
packages/react-test-renderer/src/ReactTestRenderer.js
+2 -2
@@ -20,8 +20,8 @@ import {
20 injectIntoDevTools,
21 batchedUpdates,
22 act,
23 -} from 'react-reconciler/inline.test';
24 -import {findCurrentFiberUsingSlowPath} from 'react-reconciler/reflection';
23 +} from 'react-reconciler/src/ReactFiberReconciler';
24 +import {findCurrentFiberUsingSlowPath} from 'react-reconciler/src/ReactFiberTreeReflection';
25 import {
26 Fragment,
27 FunctionComponent,
packages/shared/forks/ReactFeatureFlags.persistent.js deleted
-62
@@ -1,62 +0,0 @@
1 -/**
2 - * Copyright (c) Facebook, Inc. and its affiliates.
3 - *
4 - * This source code is licensed under the MIT license found in the
5 - * LICENSE file in the root directory of this source tree.
6 - *
7 - * @flow
8 - */
9 -
10 -import invariant from 'shared/invariant';
11 -
12 -import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags';
13 -import typeof * as ExportsType from './ReactFeatureFlags.persistent';
14 -
15 -export const debugRenderPhaseSideEffectsForStrictMode = false;
16 -export const enableUserTimingAPI = __DEV__;
17 -export const warnAboutDeprecatedLifecycles = true;
18 -export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
19 -export const enableProfilerTimer = __PROFILE__;
20 -export const enableProfilerCommitHooks = false;
21 -export const enableSchedulerTracing = __PROFILE__;
22 -export const enableSuspenseServerRenderer = false;
23 -export const enableSelectiveHydration = false;
24 -export const enableBlocksAPI = false;
25 -export const disableJavaScriptURLs = false;
26 -export const disableInputAttributeSyncing = false;
27 -export const warnAboutShorthandPropertyCollision = true;
28 -export const enableSchedulerDebugging = false;
29 -export const enableDeprecatedFlareAPI = false;
30 -export const enableFundamentalAPI = false;
31 -export const enableScopeAPI = false;
32 -export const warnAboutUnmockedScheduler = true;
33 -export const flushSuspenseFallbacksInTests = true;
34 -export const enableSuspenseCallback = false;
35 -export const warnAboutDefaultPropsOnFunctionComponents = false;
36 -export const warnAboutStringRefs = false;
37 -export const disableLegacyContext = false;
38 -export const disableSchedulerTimeoutBasedOnReactExpirationTime = false;
39 -export const enableTrustedTypesIntegration = false;
40 -export const disableTextareaChildren = false;
41 -export const disableMapsAsChildren = false;
42 -export const disableModulePatternComponents = false;
43 -export const warnUnstableRenderSubtreeIntoContainer = false;
44 -export const deferPassiveEffectCleanupDuringUnmount = false;
45 -export const runAllPassiveEffectDestroysBeforeCreates = false;
46 -export const enableModernEventSystem = false;
47 -export const warnAboutSpreadingKeyToJSX = false;
48 -export const enableLegacyFBPrimerSupport = false;
49 -
50 -// Internal-only attempt to debug a React Native issue. See D20130868.
51 -export const throwEarlyForMysteriousError = false;
52 -
53 -// Only used in www builds.
54 -export function addUserTimingListener() {
55 - invariant(false, 'Not implemented.');
56 -}
57 -
58 -// Flow magic to verify the exports of this file match the original version.
59 -// eslint-disable-next-line no-unused-vars
60 -type Check<_X, Y: _X, X: Y = _X> = null;
61 -// eslint-disable-next-line no-unused-expressions
62 -(null: Check<ExportsType, FeatureFlagsType>);
scripts/flow/config/flowconfig
+3
@@ -14,6 +14,9 @@
14 .*/__mocks__/.*
15 .*/__tests__/.*
16
17 +# TODO: noop should get its own inlinedHostConfig entry
18 +.*/packages/react-noop-renderer/.*
19 +
20 %REACT_RENDERER_FLOW_IGNORES%
21
22 [include]
scripts/flow/createFlowConfigs.js
+28 -18
@@ -18,37 +18,43 @@ const configTemplate = fs
18 .readFileSync(__dirname + '/config/flowconfig')
19 .toString();
20
21 -function writeConfig(renderer, isServerSupported) {
21 +function writeConfig(renderer, rendererInfo, isServerSupported) {
22 const folder = __dirname + '/' + renderer;
23 mkdirp.sync(folder);
24
25 const serverRenderer = isServerSupported ? renderer : 'custom';
26 +
27 + let ignoredPaths = [];
28 +
29 + inlinedHostConfigs.forEach(otherRenderer => {
30 + if (otherRenderer === rendererInfo) {
31 + return;
32 + }
33 + otherRenderer.paths.forEach(otherPath => {
34 + if (rendererInfo.paths.indexOf(otherPath) !== -1) {
35 + return;
36 + }
37 + ignoredPaths.push(`.*/packages/${otherPath}`);
38 + });
39 +
40 + if (otherRenderer.shortName !== serverRenderer) {
41 + ignoredPaths.push(
42 + `.*/packages/.*/forks/.*.${otherRenderer.shortName}.js`,
43 + );
44 + }
45 + });
46 +
47 const config = configTemplate
48 .replace(
49 '%REACT_RENDERER_FLOW_OPTIONS%',
50 `
30 -module.name_mapper='react-reconciler/inline.${renderer}$$' -> 'react-reconciler/inline-typed'
51 module.name_mapper='ReactFiberHostConfig$$' -> 'forks/ReactFiberHostConfig.${renderer}'
32 -module.name_mapper='react-server/inline.${renderer}$$' -> 'react-server/inline-typed'
33 -module.name_mapper='react-server/flight.inline.${renderer}$$' -> 'react-server/flight.inline-typed'
52 module.name_mapper='ReactServerHostConfig$$' -> 'forks/ReactServerHostConfig.${serverRenderer}'
53 module.name_mapper='ReactServerFormatConfig$$' -> 'forks/ReactServerFormatConfig.${serverRenderer}'
36 -module.name_mapper='react-flight/inline.${renderer}$$' -> 'react-flight/inline-typed'
54 module.name_mapper='ReactFlightClientHostConfig$$' -> 'forks/ReactFlightClientHostConfig.${serverRenderer}'
55 `.trim(),
56 )
40 - .replace(
41 - '%REACT_RENDERER_FLOW_IGNORES%',
42 - renderer === 'dom' || renderer === 'dom-browser'
43 - ? ''
44 - : // If we're not checking DOM, ignore the DOM package since it
45 - // won't be consistent.
46 - `
47 - .*/packages/react-dom/.*
48 - .*/packages/.*/forks/.*.dom.js
49 - .*/packages/.*/forks/.*.dom-browser.js
50 - `.trim(),
51 - );
57 + .replace('%REACT_RENDERER_FLOW_IGNORES%', ignoredPaths.join('\n'));
58
59 const disclaimer = `
60 # ---------------------------------------------------------------#
@@ -81,6 +87,10 @@ ${disclaimer}
87 // so that we can run those checks in parallel if we want.
88 inlinedHostConfigs.forEach(rendererInfo => {
89 if (rendererInfo.isFlowTyped) {
84 - writeConfig(rendererInfo.shortName, rendererInfo.isServerSupported);
90 + writeConfig(
91 + rendererInfo.shortName,
92 + rendererInfo,
93 + rendererInfo.isServerSupported,
94 + );
95 }
96 });
scripts/jest/setupHostConfigs.js
+22 -129
@@ -11,12 +11,6 @@ jest.mock('react-reconciler', () => {
11 return require.requireActual('react-reconciler');
12 };
13 });
14 -jest.mock('react-reconciler/persistent', () => {
15 - return config => {
16 - jest.mock(shimHostConfigPath, () => config);
17 - return require.requireActual('react-reconciler/persistent');
18 - };
19 -});
14 const shimServerHostConfigPath = 'react-server/src/ReactServerHostConfig';
15 const shimServerFormatConfigPath = 'react-server/src/ReactServerFormatConfig';
16 jest.mock('react-server', () => {
@@ -42,6 +36,24 @@ jest.mock('react-flight', () => {
36 };
37 });
38
39 +const configPaths = [
40 + 'react-reconciler/src/ReactFiberHostConfig',
41 + 'react-flight/src/ReactFlightClientHostConfig',
42 + 'react-server/src/ReactServerHostConfig',
43 + 'react-server/src/ReactServerFormatConfig',
44 +];
45 +
46 +function mockAllConfigs(rendererInfo) {
47 + configPaths.forEach(path => {
48 + // We want the reconciler to pick up the host config for this renderer.
49 + jest.mock(path, () => {
50 + let idx = path.lastIndexOf('/');
51 + let forkPath = path.substr(0, idx) + '/forks' + path.substr(idx);
52 + return require.requireActual(`${forkPath}.${rendererInfo.shortName}.js`);
53 + });
54 + });
55 +}
56 +
57 // But for inlined host configs (such as React DOM, Native, etc), we
58 // mock their named entry points to establish a host config mapping.
59 inlinedHostConfigs.forEach(rendererInfo => {
@@ -50,131 +62,12 @@ inlinedHostConfigs.forEach(rendererInfo => {
62 // Instead, it's handled by the generic `react-reconciler` entry point above.
63 return;
64 }
53 - jest.mock(`react-reconciler/inline.${rendererInfo.shortName}`, () => {
54 - let hasImportedShimmedConfig = false;
55 -
56 - // We want the reconciler to pick up the host config for this renderer.
57 - jest.mock(shimHostConfigPath, () => {
58 - hasImportedShimmedConfig = true;
59 - return require.requireActual(
60 - `react-reconciler/src/forks/ReactFiberHostConfig.${rendererInfo.shortName}.js`
61 - );
65 + rendererInfo.entryPoints.forEach(entryPoint => {
66 + jest.mock(entryPoint, () => {
67 + mockAllConfigs(rendererInfo);
68 + return require.requireActual(entryPoint);
69 });
63 -
64 - const renderer = require.requireActual('react-reconciler');
65 - // If the shimmed config factory function above has not run,
66 - // it means this test file loads more than one renderer
67 - // but doesn't reset modules between them. This won't work.
68 - if (!hasImportedShimmedConfig) {
69 - throw new Error(
70 - `Could not import the "${rendererInfo.shortName}" renderer ` +
71 - `in this suite because another renderer has already been ` +
72 - `loaded earlier. Call jest.resetModules() before importing any ` +
73 - `of the following entry points:\n\n` +
74 - rendererInfo.entryPoints.map(entry => ` * ${entry}`)
75 - );
76 - }
77 -
78 - return renderer;
70 });
80 -
81 - if (rendererInfo.isServerSupported) {
82 - jest.mock(`react-server/inline.${rendererInfo.shortName}`, () => {
83 - let hasImportedShimmedConfig = false;
84 -
85 - // We want the renderer to pick up the host config for this renderer.
86 - jest.mock(shimServerHostConfigPath, () => {
87 - hasImportedShimmedConfig = true;
88 - return require.requireActual(
89 - `react-server/src/forks/ReactServerHostConfig.${rendererInfo.shortName}.js`
90 - );
91 - });
92 - jest.mock(shimServerFormatConfigPath, () => {
93 - hasImportedShimmedConfig = true;
94 - return require.requireActual(
95 - `react-server/src/forks/ReactServerFormatConfig.${rendererInfo.shortName}.js`
96 - );
97 - });
98 -
99 - const renderer = require.requireActual('react-server');
100 - // If the shimmed config factory function above has not run,
101 - // it means this test file loads more than one renderer
102 - // but doesn't reset modules between them. This won't work.
103 - if (!hasImportedShimmedConfig) {
104 - throw new Error(
105 - `Could not import the "${rendererInfo.shortName}" renderer ` +
106 - `in this suite because another renderer has already been ` +
107 - `loaded earlier. Call jest.resetModules() before importing any ` +
108 - `of the following entry points:\n\n` +
109 - rendererInfo.entryPoints.map(entry => ` * ${entry}`)
110 - );
111 - }
112 -
113 - return renderer;
114 - });
115 -
116 - jest.mock(`react-server/flight.inline.${rendererInfo.shortName}`, () => {
117 - let hasImportedShimmedConfig = false;
118 -
119 - // We want the renderer to pick up the host config for this renderer.
120 - jest.mock(shimServerHostConfigPath, () => {
121 - hasImportedShimmedConfig = true;
122 - return require.requireActual(
123 - `react-server/src/forks/ReactServerHostConfig.${rendererInfo.shortName}.js`
124 - );
125 - });
126 - jest.mock(shimServerFormatConfigPath, () => {
127 - hasImportedShimmedConfig = true;
128 - return require.requireActual(
129 - `react-server/src/forks/ReactServerFormatConfig.${rendererInfo.shortName}.js`
130 - );
131 - });
132 -
133 - const renderer = require.requireActual('react-server/flight');
134 - // If the shimmed config factory function above has not run,
135 - // it means this test file loads more than one renderer
136 - // but doesn't reset modules between them. This won't work.
137 - if (!hasImportedShimmedConfig) {
138 - throw new Error(
139 - `Could not import the "${rendererInfo.shortName}" renderer ` +
140 - `in this suite because another renderer has already been ` +
141 - `loaded earlier. Call jest.resetModules() before importing any ` +
142 - `of the following entry points:\n\n` +
143 - rendererInfo.entryPoints.map(entry => ` * ${entry}`)
144 - );
145 - }
146 -
147 - return renderer;
148 - });
149 -
150 - jest.mock(`react-flight/inline.${rendererInfo.shortName}`, () => {
151 - let hasImportedShimmedConfig = false;
152 -
153 - // We want the renderer to pick up the host config for this renderer.
154 - jest.mock(shimFlightClientHostConfigPath, () => {
155 - hasImportedShimmedConfig = true;
156 - return require.requireActual(
157 - `react-flight/src/forks/ReactFlightClientHostConfig.${rendererInfo.shortName}.js`
158 - );
159 - });
160 -
161 - const renderer = require.requireActual('react-flight');
162 - // If the shimmed config factory function above has not run,
163 - // it means this test file loads more than one renderer
164 - // but doesn't reset modules between them. This won't work.
165 - if (!hasImportedShimmedConfig) {
166 - throw new Error(
167 - `Could not import the "${rendererInfo.shortName}" renderer ` +
168 - `in this suite because another renderer has already been ` +
169 - `loaded earlier. Call jest.resetModules() before importing any ` +
170 - `of the following entry points:\n\n` +
171 - rendererInfo.entryPoints.map(entry => ` * ${entry}`)
172 - );
173 - }
174 -
175 - return renderer;
176 - });
177 - }
71 });
72
73 // Make it possible to import this module inside
scripts/rollup/bundles.js
-9
@@ -362,15 +362,6 @@ const bundles = [
362 externals: ['react'],
363 },
364
365 - /******* React Persistent Reconciler *******/
366 - {
367 - bundleTypes: [NODE_DEV, NODE_PROD],
368 - moduleType: RECONCILER,
369 - entry: 'react-reconciler/persistent',
370 - global: 'ReactPersistentReconciler',
371 - externals: ['react'],
372 - },
373 -
365 /******* React Server *******/
366 {
367 bundleTypes: [NODE_DEV, NODE_PROD],
scripts/rollup/forks.js
-2
@@ -100,8 +100,6 @@ const forks = Object.freeze({
100 `Unexpected entry (${entry}) and bundleType (${bundleType})`
101 );
102 }
103 - case 'react-reconciler/persistent':
104 - return 'shared/forks/ReactFeatureFlags.persistent.js';
103 case 'react-test-renderer':
104 switch (bundleType) {
105 case FB_WWW_DEV:
scripts/shared/inlinedHostConfigs.js
+26 -1
@@ -16,40 +16,65 @@ module.exports = [
16 'react-flight-dom-webpack/server.node',
17 'react-flight-dom-webpack',
18 ],
19 + paths: [
20 + 'react-dom',
21 + 'react-dom/unstable-fizz',
22 + 'react-dom/unstable-fizz.node',
23 + 'react-dom/src/server/ReactDOMFizzServerNode.js', // react-dom/unstable-fizz.node
24 + 'react-flight-dom-webpack',
25 + 'react-flight-dom-webpack/server',
26 + 'react-flight-dom-webpack/server.node',
27 + 'react-flight-dom-webpack/src/ReactFlightDOMServerNode.js', // react-flight-dom-webpack/server.browser
28 + ],
29 isFlowTyped: true,
30 isServerSupported: true,
31 },
32 {
33 shortName: 'dom-browser',
34 entryPoints: [
35 + 'react-dom',
36 + 'react-dom/testing',
37 'react-dom/unstable-fizz.browser',
38 'react-flight-dom-webpack/server.browser',
39 'react-flight-dom-webpack',
40 ],
41 + paths: [
42 + 'react-dom',
43 + 'react-dom/testing',
44 + 'react-dom/unstable-fizz.browser',
45 + 'react-dom/src/server/ReactDOMFizzServerBrowser.js', // react-dom/unstable-fizz.browser
46 + 'react-flight-dom-webpack',
47 + 'react-flight-dom-webpack/server.browser',
48 + 'react-flight-dom-webpack/src/ReactFlightDOMServerBrowser.js', // react-flight-dom-webpack/server.browser
49 + ],
50 isFlowTyped: true,
51 isServerSupported: true,
52 },
53 {
54 shortName: 'art',
55 entryPoints: ['react-art'],
56 + paths: ['react-art'],
57 isFlowTyped: false, // TODO: type it.
58 isServerSupported: false,
59 },
60 {
61 shortName: 'native',
62 entryPoints: ['react-native-renderer'],
63 + paths: ['react-native-renderer'],
64 isFlowTyped: true,
65 isServerSupported: false,
66 },
67 {
68 shortName: 'fabric',
69 entryPoints: ['react-native-renderer/fabric'],
70 + paths: ['react-native-renderer'],
71 isFlowTyped: true,
72 isServerSupported: false,
73 },
74 {
75 shortName: 'test',
76 entryPoints: ['react-test-renderer'],
77 + paths: ['react-test-renderer'],
78 isFlowTyped: true,
79 isServerSupported: false,
80 },
@@ -57,11 +82,11 @@ module.exports = [
82 shortName: 'custom',
83 entryPoints: [
84 'react-reconciler',
60 - 'react-reconciler/persistent',
85 'react-flight',
86 'react-server',
87 'react-server/flight',
88 ],
89 + paths: [],
90 isFlowTyped: true,
91 isServerSupported: true,
92 },