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.
This commit is contained in:
Sebastian Markbåge authored and GitHub committed 2020-03-06 16:20:42 -08:00
1 parent 238b57f0f7
commit 7a1691cdff
59 files changed
+127 -561

No files matched your search

+1 -1
View File
@@ -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';
+1 -1
View File
@@ -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';
+1 -1
View File
@@ -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';
+5 -2
View File
@@ -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';
+1 -1
View File
@@ -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 = {
+1 -1
View File
@@ -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,
+1 -1
View File
@@ -28,7 +28,7 @@ import {
getNearestMountedFiber,
getContainerFromFiber,
getSuspenseInstanceFromFiber,
} from 'react-reconciler/reflection';
} from 'react-reconciler/src/ReactFiberTreeReflection';
import {
attemptToDispatchEvent,
addResponderEventSystemEvent,
+1 -1
View File
@@ -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;
+5 -1
View File
@@ -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);
+1 -1
View File
@@ -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,
+1 -1
View File
@@ -8,4 +8,4 @@
*/
export * from './index.classic.fb.js';
export {act} from 'react-reconciler/inline.dom';
export {act} from 'react-reconciler/src/ReactFiberReconciler';
+1 -1
View File
@@ -8,4 +8,4 @@
*/
export * from './index.experimental.js';
export {act} from 'react-reconciler/inline.dom';
export {act} from 'react-reconciler/src/ReactFiberReconciler';
+1 -1
View File
@@ -8,4 +8,4 @@
*/
export * from './index.js';
export {act} from 'react-reconciler/inline.dom';
export {act} from 'react-reconciler/src/ReactFiberReconciler';
+1 -1
View File
@@ -8,4 +8,4 @@
*/
export * from './index.modern.fb.js';
export {act} from 'react-reconciler/inline.dom';
export {act} from 'react-reconciler/src/ReactFiberReconciler';
+1 -1
View File
@@ -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);
+2 -12
View File
@@ -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
View File
@@ -1,24 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
// This file must have the Flow annotation.
//
// This is the Flow-typed entry point for the renderer. It should not be
// imported directly in code. Instead, our Flow configuration uses this entry
// point for the currently checked renderer (the one you passed to `yarn flow`).
//
// For example, if you run `yarn flow dom`, `react-server/inline.dom` points
// to this module (and thus will be considered Flow-typed). But other renderers
// (e.g. `react-test-renderer`) will see stream as untyped during the check.
//
// We can't make all entry points typed at the same time because different
// renderers have different host config types. So we check them one by one.
// We run Flow on all renderers on CI.
export * from './src/ReactFlightClient';
@@ -1,11 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// This file intentionally does *not* have the Flow annotation.
// Don't add it. See `./inline-typed.js` for an explanation.
export * from './src/ReactFlightClient';
-11
View File
@@ -1,11 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// This file intentionally does *not* have the Flow annotation.
// Don't add it. See `./inline-typed.js` for an explanation.
export * from './src/ReactFlightClient';
+1 -1
View File
@@ -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';
+1 -1
View File
@@ -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';
+1 -1
View File
@@ -14,7 +14,7 @@
* environment.
*/
import type {ReactModelRoot} from 'react-flight/inline-typed';
import type {ReactModelRoot} from 'react-flight';
import ReactFlightClient from 'react-flight';
+1 -1
View File
@@ -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';
+2 -2
View File
@@ -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
);
+2 -12
View File
@@ -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
View File
@@ -1,24 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
// This file must have the Flow annotation.
//
// This is the Flow-typed entry point for the reconciler. It should not be
// imported directly in code. Instead, our Flow configuration uses this entry
// point for the currently checked renderer (the one you passed to `yarn flow`).
//
// For example, if you run `yarn flow dom`, `react-reconciler/inline.dom` points
// to this module (and thus will be considered Flow-typed). But other renderers
// (e.g. `react-test-renderer`) will see reconciler as untyped during the check.
//
// We can't make all entry points typed at the same time because different
// renderers have different host config types. So we check them one by one.
// We run Flow on all renderers on CI.
export * from './src/ReactFiberReconciler';
-11
View File
@@ -1,11 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// This file intentionally does *not* have the Flow annotation.
// Don't add it. See `./inline-typed.js` for an explanation.
export * from './src/ReactFiberReconciler';
@@ -1,11 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// This file intentionally does *not* have the Flow annotation.
// Don't add it. See `./inline-typed.js` for an explanation.
export * from './src/ReactFiberReconciler';
-11
View File
@@ -1,11 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// This file intentionally does *not* have the Flow annotation.
// Don't add it. See `./inline-typed.js` for an explanation.
export * from './src/ReactFiberReconciler';
@@ -1,11 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// This file intentionally does *not* have the Flow annotation.
// Don't add it. See `./inline-typed.js` for an explanation.
export * from './src/ReactFiberReconciler';
-11
View File
@@ -1,11 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// This file intentionally does *not* have the Flow annotation.
// Don't add it. See `./inline-typed.js` for an explanation.
export * from './src/ReactFiberReconciler';
@@ -1,11 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// This file intentionally does *not* have the Flow annotation.
// Don't add it. See `./inline-typed.js` for an explanation.
export * from './src/ReactFiberReconciler';
-11
View File
@@ -1,11 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// This file intentionally does *not* have the Flow annotation.
// Don't add it. See `./inline-typed.js` for an explanation.
export * from './src/ReactFiberReconciler';
-7
View File
@@ -1,7 +0,0 @@
'use strict';
if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react-reconciler-persistent.production.min.js');
} else {
module.exports = require('./cjs/react-reconciler-persistent.development.js');
}
-1
View File
@@ -13,7 +13,6 @@
"README.md",
"build-info.json",
"index.js",
"persistent.js",
"reflection.js",
"cjs/"
],
-12
View File
@@ -1,12 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
// This is the same export as in index.js,
// with persistent reconciler flags turned on.
export * from './src/ReactFiberReconciler';
+1 -1
View File
@@ -19,7 +19,7 @@ import {
warnAboutDeprecatedLifecycles,
} from 'shared/ReactFeatureFlags';
import ReactStrictModeWarnings from './ReactStrictModeWarnings';
import {isMounted} from 'react-reconciler/reflection';
import {isMounted} from 'react-reconciler/src/ReactFiberTreeReflection';
import {get as getInstance, set as setInstance} from 'shared/ReactInstanceMap';
import shallowEqual from 'shared/shallowEqual';
import getComponentName from 'shared/getComponentName';
+1 -1
View File
@@ -10,7 +10,7 @@
import type {Fiber} from './ReactFiber';
import type {StackCursor} from './ReactFiberStack';
import {isFiberMounted} from 'react-reconciler/reflection';
import {isFiberMounted} from 'react-reconciler/src/ReactFiberTreeReflection';
import {disableLegacyContext} from 'shared/ReactFeatureFlags';
import {ClassComponent, HostRoot} from 'shared/ReactWorkTags';
import getComponentName from 'shared/getComponentName';
+1 -1
View File
@@ -27,7 +27,7 @@ import type {
import {
findCurrentHostFiber,
findCurrentHostFiberWithNoPortals,
} from 'react-reconciler/reflection';
} from 'react-reconciler/src/ReactFiberTreeReflection';
import {get as getInstance} from 'shared/ReactInstanceMap';
import {
HostComponent,
@@ -1,24 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
// This file must have the Flow annotation.
//
// This is the Flow-typed entry point for the renderer. It should not be
// imported directly in code. Instead, our Flow configuration uses this entry
// point for the currently checked renderer (the one you passed to `yarn flow`).
//
// For example, if you run `yarn flow dom`, `react-server/flight.inline.dom` points
// to this module (and thus will be considered Flow-typed). But other renderers
// (e.g. `react-test-renderer`) will see stream as untyped during the check.
//
// We can't make all entry points typed at the same time because different
// renderers have different host config types. So we check them one by one.
// We run Flow on all renderers on CI.
export * from './src/ReactFlightServer';
@@ -1,11 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// This file intentionally does *not* have the Flow annotation.
// Don't add it. See `./inline-typed.js` for an explanation.
export * from './src/ReactFlightServer';
@@ -1,11 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// This file intentionally does *not* have the Flow annotation.
// Don't add it. See `./inline-typed.js` for an explanation.
export * from './src/ReactFlightServer';
+2 -12
View File
@@ -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/flight.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/flight.inline.<renderer>` import (which is *not* Flow typed) to
// `react-server/flight.inline-typed` (which *is*) for the current renderer.
// On CI, we run Flow checks for each renderer separately.
export * from './src/ReactFlightServer';
+2 -12
View File
@@ -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/ReactFizzStreamer';
-24
View File
@@ -1,24 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
// This file must have the Flow annotation.
//
// This is the Flow-typed entry point for the renderer. It should not be
// imported directly in code. Instead, our Flow configuration uses this entry
// point for the currently checked renderer (the one you passed to `yarn flow`).
//
// For example, if you run `yarn flow dom`, `react-server/inline.dom` points
// to this module (and thus will be considered Flow-typed). But other renderers
// (e.g. `react-test-renderer`) will see stream as untyped during the check.
//
// We can't make all entry points typed at the same time because different
// renderers have different host config types. So we check them one by one.
// We run Flow on all renderers on CI.
export * from './src/ReactFizzStreamer';
@@ -1,11 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// This file intentionally does *not* have the Flow annotation.
// Don't add it. See `./inline-typed.js` for an explanation.
export * from './src/ReactFizzStreamer';
-11
View File
@@ -1,11 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// This file intentionally does *not* have the Flow annotation.
// Don't add it. See `./inline-typed.js` for an explanation.
export * from './src/ReactFizzStreamer';
+2 -2
View File
@@ -20,8 +20,8 @@ import {
injectIntoDevTools,
batchedUpdates,
act,
} from 'react-reconciler/inline.test';
import {findCurrentFiberUsingSlowPath} from 'react-reconciler/reflection';
} from 'react-reconciler/src/ReactFiberReconciler';
import {findCurrentFiberUsingSlowPath} from 'react-reconciler/src/ReactFiberTreeReflection';
import {
Fragment,
FunctionComponent,
@@ -1,62 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import invariant from 'shared/invariant';
import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags';
import typeof * as ExportsType from './ReactFeatureFlags.persistent';
export const debugRenderPhaseSideEffectsForStrictMode = false;
export const enableUserTimingAPI = __DEV__;
export const warnAboutDeprecatedLifecycles = true;
export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
export const enableProfilerTimer = __PROFILE__;
export const enableProfilerCommitHooks = false;
export const enableSchedulerTracing = __PROFILE__;
export const enableSuspenseServerRenderer = false;
export const enableSelectiveHydration = false;
export const enableBlocksAPI = false;
export const disableJavaScriptURLs = false;
export const disableInputAttributeSyncing = false;
export const warnAboutShorthandPropertyCollision = true;
export const enableSchedulerDebugging = false;
export const enableDeprecatedFlareAPI = false;
export const enableFundamentalAPI = false;
export const enableScopeAPI = false;
export const warnAboutUnmockedScheduler = true;
export const flushSuspenseFallbacksInTests = true;
export const enableSuspenseCallback = false;
export const warnAboutDefaultPropsOnFunctionComponents = false;
export const warnAboutStringRefs = false;
export const disableLegacyContext = false;
export const disableSchedulerTimeoutBasedOnReactExpirationTime = false;
export const enableTrustedTypesIntegration = false;
export const disableTextareaChildren = false;
export const disableMapsAsChildren = false;
export const disableModulePatternComponents = false;
export const warnUnstableRenderSubtreeIntoContainer = false;
export const deferPassiveEffectCleanupDuringUnmount = false;
export const runAllPassiveEffectDestroysBeforeCreates = false;
export const enableModernEventSystem = false;
export const warnAboutSpreadingKeyToJSX = false;
export const enableLegacyFBPrimerSupport = false;
// Internal-only attempt to debug a React Native issue. See D20130868.
export const throwEarlyForMysteriousError = false;
// Only used in www builds.
export function addUserTimingListener() {
invariant(false, 'Not implemented.');
}
// Flow magic to verify the exports of this file match the original version.
// eslint-disable-next-line no-unused-vars
type Check<_X, Y: _X, X: Y = _X> = null;
// eslint-disable-next-line no-unused-expressions
(null: Check<ExportsType, FeatureFlagsType>);
+3
View File
@@ -14,6 +14,9 @@
.*/__mocks__/.*
.*/__tests__/.*
# TODO: noop should get its own inlinedHostConfig entry
.*/packages/react-noop-renderer/.*
%REACT_RENDERER_FLOW_IGNORES%
[include]
+28 -18
View File
@@ -18,37 +18,43 @@ const configTemplate = fs
.readFileSync(__dirname + '/config/flowconfig')
.toString();
function writeConfig(renderer, isServerSupported) {
function writeConfig(renderer, rendererInfo, isServerSupported) {
const folder = __dirname + '/' + renderer;
mkdirp.sync(folder);
const serverRenderer = isServerSupported ? renderer : 'custom';
let ignoredPaths = [];
inlinedHostConfigs.forEach(otherRenderer => {
if (otherRenderer === rendererInfo) {
return;
}
otherRenderer.paths.forEach(otherPath => {
if (rendererInfo.paths.indexOf(otherPath) !== -1) {
return;
}
ignoredPaths.push(`.*/packages/${otherPath}`);
});
if (otherRenderer.shortName !== serverRenderer) {
ignoredPaths.push(
`.*/packages/.*/forks/.*.${otherRenderer.shortName}.js`,
);
}
});
const config = configTemplate
.replace(
'%REACT_RENDERER_FLOW_OPTIONS%',
`
module.name_mapper='react-reconciler/inline.${renderer}$$' -> 'react-reconciler/inline-typed'
module.name_mapper='ReactFiberHostConfig$$' -> 'forks/ReactFiberHostConfig.${renderer}'
module.name_mapper='react-server/inline.${renderer}$$' -> 'react-server/inline-typed'
module.name_mapper='react-server/flight.inline.${renderer}$$' -> 'react-server/flight.inline-typed'
module.name_mapper='ReactServerHostConfig$$' -> 'forks/ReactServerHostConfig.${serverRenderer}'
module.name_mapper='ReactServerFormatConfig$$' -> 'forks/ReactServerFormatConfig.${serverRenderer}'
module.name_mapper='react-flight/inline.${renderer}$$' -> 'react-flight/inline-typed'
module.name_mapper='ReactFlightClientHostConfig$$' -> 'forks/ReactFlightClientHostConfig.${serverRenderer}'
`.trim(),
)
.replace(
'%REACT_RENDERER_FLOW_IGNORES%',
renderer === 'dom' || renderer === 'dom-browser'
? ''
: // If we're not checking DOM, ignore the DOM package since it
// won't be consistent.
`
.*/packages/react-dom/.*
.*/packages/.*/forks/.*.dom.js
.*/packages/.*/forks/.*.dom-browser.js
`.trim(),
);
.replace('%REACT_RENDERER_FLOW_IGNORES%', ignoredPaths.join('\n'));
const disclaimer = `
# ---------------------------------------------------------------#
@@ -81,6 +87,10 @@ ${disclaimer}
// so that we can run those checks in parallel if we want.
inlinedHostConfigs.forEach(rendererInfo => {
if (rendererInfo.isFlowTyped) {
writeConfig(rendererInfo.shortName, rendererInfo.isServerSupported);
writeConfig(
rendererInfo.shortName,
rendererInfo,
rendererInfo.isServerSupported,
);
}
});
+22 -129
View File
@@ -11,12 +11,6 @@ jest.mock('react-reconciler', () => {
return require.requireActual('react-reconciler');
};
});
jest.mock('react-reconciler/persistent', () => {
return config => {
jest.mock(shimHostConfigPath, () => config);
return require.requireActual('react-reconciler/persistent');
};
});
const shimServerHostConfigPath = 'react-server/src/ReactServerHostConfig';
const shimServerFormatConfigPath = 'react-server/src/ReactServerFormatConfig';
jest.mock('react-server', () => {
@@ -42,6 +36,24 @@ jest.mock('react-flight', () => {
};
});
const configPaths = [
'react-reconciler/src/ReactFiberHostConfig',
'react-flight/src/ReactFlightClientHostConfig',
'react-server/src/ReactServerHostConfig',
'react-server/src/ReactServerFormatConfig',
];
function mockAllConfigs(rendererInfo) {
configPaths.forEach(path => {
// We want the reconciler to pick up the host config for this renderer.
jest.mock(path, () => {
let idx = path.lastIndexOf('/');
let forkPath = path.substr(0, idx) + '/forks' + path.substr(idx);
return require.requireActual(`${forkPath}.${rendererInfo.shortName}.js`);
});
});
}
// But for inlined host configs (such as React DOM, Native, etc), we
// mock their named entry points to establish a host config mapping.
inlinedHostConfigs.forEach(rendererInfo => {
@@ -50,131 +62,12 @@ inlinedHostConfigs.forEach(rendererInfo => {
// Instead, it's handled by the generic `react-reconciler` entry point above.
return;
}
jest.mock(`react-reconciler/inline.${rendererInfo.shortName}`, () => {
let hasImportedShimmedConfig = false;
// We want the reconciler to pick up the host config for this renderer.
jest.mock(shimHostConfigPath, () => {
hasImportedShimmedConfig = true;
return require.requireActual(
`react-reconciler/src/forks/ReactFiberHostConfig.${rendererInfo.shortName}.js`
);
rendererInfo.entryPoints.forEach(entryPoint => {
jest.mock(entryPoint, () => {
mockAllConfigs(rendererInfo);
return require.requireActual(entryPoint);
});
const renderer = require.requireActual('react-reconciler');
// If the shimmed config factory function above has not run,
// it means this test file loads more than one renderer
// but doesn't reset modules between them. This won't work.
if (!hasImportedShimmedConfig) {
throw new Error(
`Could not import the "${rendererInfo.shortName}" renderer ` +
`in this suite because another renderer has already been ` +
`loaded earlier. Call jest.resetModules() before importing any ` +
`of the following entry points:\n\n` +
rendererInfo.entryPoints.map(entry => ` * ${entry}`)
);
}
return renderer;
});
if (rendererInfo.isServerSupported) {
jest.mock(`react-server/inline.${rendererInfo.shortName}`, () => {
let hasImportedShimmedConfig = false;
// We want the renderer to pick up the host config for this renderer.
jest.mock(shimServerHostConfigPath, () => {
hasImportedShimmedConfig = true;
return require.requireActual(
`react-server/src/forks/ReactServerHostConfig.${rendererInfo.shortName}.js`
);
});
jest.mock(shimServerFormatConfigPath, () => {
hasImportedShimmedConfig = true;
return require.requireActual(
`react-server/src/forks/ReactServerFormatConfig.${rendererInfo.shortName}.js`
);
});
const renderer = require.requireActual('react-server');
// If the shimmed config factory function above has not run,
// it means this test file loads more than one renderer
// but doesn't reset modules between them. This won't work.
if (!hasImportedShimmedConfig) {
throw new Error(
`Could not import the "${rendererInfo.shortName}" renderer ` +
`in this suite because another renderer has already been ` +
`loaded earlier. Call jest.resetModules() before importing any ` +
`of the following entry points:\n\n` +
rendererInfo.entryPoints.map(entry => ` * ${entry}`)
);
}
return renderer;
});
jest.mock(`react-server/flight.inline.${rendererInfo.shortName}`, () => {
let hasImportedShimmedConfig = false;
// We want the renderer to pick up the host config for this renderer.
jest.mock(shimServerHostConfigPath, () => {
hasImportedShimmedConfig = true;
return require.requireActual(
`react-server/src/forks/ReactServerHostConfig.${rendererInfo.shortName}.js`
);
});
jest.mock(shimServerFormatConfigPath, () => {
hasImportedShimmedConfig = true;
return require.requireActual(
`react-server/src/forks/ReactServerFormatConfig.${rendererInfo.shortName}.js`
);
});
const renderer = require.requireActual('react-server/flight');
// If the shimmed config factory function above has not run,
// it means this test file loads more than one renderer
// but doesn't reset modules between them. This won't work.
if (!hasImportedShimmedConfig) {
throw new Error(
`Could not import the "${rendererInfo.shortName}" renderer ` +
`in this suite because another renderer has already been ` +
`loaded earlier. Call jest.resetModules() before importing any ` +
`of the following entry points:\n\n` +
rendererInfo.entryPoints.map(entry => ` * ${entry}`)
);
}
return renderer;
});
jest.mock(`react-flight/inline.${rendererInfo.shortName}`, () => {
let hasImportedShimmedConfig = false;
// We want the renderer to pick up the host config for this renderer.
jest.mock(shimFlightClientHostConfigPath, () => {
hasImportedShimmedConfig = true;
return require.requireActual(
`react-flight/src/forks/ReactFlightClientHostConfig.${rendererInfo.shortName}.js`
);
});
const renderer = require.requireActual('react-flight');
// If the shimmed config factory function above has not run,
// it means this test file loads more than one renderer
// but doesn't reset modules between them. This won't work.
if (!hasImportedShimmedConfig) {
throw new Error(
`Could not import the "${rendererInfo.shortName}" renderer ` +
`in this suite because another renderer has already been ` +
`loaded earlier. Call jest.resetModules() before importing any ` +
`of the following entry points:\n\n` +
rendererInfo.entryPoints.map(entry => ` * ${entry}`)
);
}
return renderer;
});
}
});
// Make it possible to import this module inside
-9
View File
@@ -362,15 +362,6 @@ const bundles = [
externals: ['react'],
},
/******* React Persistent Reconciler *******/
{
bundleTypes: [NODE_DEV, NODE_PROD],
moduleType: RECONCILER,
entry: 'react-reconciler/persistent',
global: 'ReactPersistentReconciler',
externals: ['react'],
},
/******* React Server *******/
{
bundleTypes: [NODE_DEV, NODE_PROD],
-2
View File
@@ -100,8 +100,6 @@ const forks = Object.freeze({
`Unexpected entry (${entry}) and bundleType (${bundleType})`
);
}
case 'react-reconciler/persistent':
return 'shared/forks/ReactFeatureFlags.persistent.js';
case 'react-test-renderer':
switch (bundleType) {
case FB_WWW_DEV:
+26 -1
View File
@@ -16,40 +16,65 @@ module.exports = [
'react-flight-dom-webpack/server.node',
'react-flight-dom-webpack',
],
paths: [
'react-dom',
'react-dom/unstable-fizz',
'react-dom/unstable-fizz.node',
'react-dom/src/server/ReactDOMFizzServerNode.js', // react-dom/unstable-fizz.node
'react-flight-dom-webpack',
'react-flight-dom-webpack/server',
'react-flight-dom-webpack/server.node',
'react-flight-dom-webpack/src/ReactFlightDOMServerNode.js', // react-flight-dom-webpack/server.browser
],
isFlowTyped: true,
isServerSupported: true,
},
{
shortName: 'dom-browser',
entryPoints: [
'react-dom',
'react-dom/testing',
'react-dom/unstable-fizz.browser',
'react-flight-dom-webpack/server.browser',
'react-flight-dom-webpack',
],
paths: [
'react-dom',
'react-dom/testing',
'react-dom/unstable-fizz.browser',
'react-dom/src/server/ReactDOMFizzServerBrowser.js', // react-dom/unstable-fizz.browser
'react-flight-dom-webpack',
'react-flight-dom-webpack/server.browser',
'react-flight-dom-webpack/src/ReactFlightDOMServerBrowser.js', // react-flight-dom-webpack/server.browser
],
isFlowTyped: true,
isServerSupported: true,
},
{
shortName: 'art',
entryPoints: ['react-art'],
paths: ['react-art'],
isFlowTyped: false, // TODO: type it.
isServerSupported: false,
},
{
shortName: 'native',
entryPoints: ['react-native-renderer'],
paths: ['react-native-renderer'],
isFlowTyped: true,
isServerSupported: false,
},
{
shortName: 'fabric',
entryPoints: ['react-native-renderer/fabric'],
paths: ['react-native-renderer'],
isFlowTyped: true,
isServerSupported: false,
},
{
shortName: 'test',
entryPoints: ['react-test-renderer'],
paths: ['react-test-renderer'],
isFlowTyped: true,
isServerSupported: false,
},
@@ -57,11 +82,11 @@ module.exports = [
shortName: 'custom',
entryPoints: [
'react-reconciler',
'react-reconciler/persistent',
'react-flight',
'react-server',
'react-server/flight',
],
paths: [],
isFlowTyped: true,
isServerSupported: true,
},