2017-11-30 20:11:00 +08:00
|
|
|
'use strict';
|
|
|
|
|
|
2020-02-04 07:31:31 +08:00
|
|
|
const {bundleTypes, moduleTypes} = require('./bundles');
|
2018-05-19 18:29:11 +08:00
|
|
|
const inlinedHostConfigs = require('../shared/inlinedHostConfigs');
|
2017-11-30 20:11:00 +08:00
|
|
|
|
2020-02-04 07:31:31 +08:00
|
|
|
const {
|
|
|
|
|
UMD_DEV,
|
|
|
|
|
UMD_PROD,
|
|
|
|
|
UMD_PROFILING,
|
|
|
|
|
FB_WWW_DEV,
|
|
|
|
|
FB_WWW_PROD,
|
|
|
|
|
FB_WWW_PROFILING,
|
|
|
|
|
RN_OSS_DEV,
|
|
|
|
|
RN_OSS_PROD,
|
|
|
|
|
RN_OSS_PROFILING,
|
|
|
|
|
RN_FB_DEV,
|
|
|
|
|
RN_FB_PROD,
|
|
|
|
|
RN_FB_PROFILING,
|
|
|
|
|
} = bundleTypes;
|
|
|
|
|
const {RENDERER, RECONCILER} = moduleTypes;
|
2017-11-30 20:11:00 +08:00
|
|
|
|
2020-03-18 21:13:50 +08:00
|
|
|
const RELEASE_CHANNEL = process.env.RELEASE_CHANNEL;
|
|
|
|
|
|
|
|
|
|
// Default to building in experimental mode. If the release channel is set via
|
|
|
|
|
// an environment variable, then check if it's "experimental".
|
|
|
|
|
const __EXPERIMENTAL__ =
|
|
|
|
|
typeof RELEASE_CHANNEL === 'string'
|
|
|
|
|
? RELEASE_CHANNEL === 'experimental'
|
|
|
|
|
: true;
|
|
|
|
|
|
2017-11-30 20:11:00 +08:00
|
|
|
// If you need to replace a file with another file for a specific environment,
|
|
|
|
|
// add it to this list with the logic for choosing the right replacement.
|
2022-02-10 00:44:02 +08:00
|
|
|
|
|
|
|
|
// Fork paths are relative to the project root. They must include the full path,
|
|
|
|
|
// including the extension. We intentionally don't use Node's module resolution
|
|
|
|
|
// algorithm because 1) require.resolve doesn't work with ESM modules, and 2)
|
|
|
|
|
// the behavior is easier to predict.
|
2017-11-30 20:11:00 +08:00
|
|
|
const forks = Object.freeze({
|
2018-07-13 09:45:37 +08:00
|
|
|
// Without this fork, importing `shared/ReactSharedInternals` inside
|
|
|
|
|
// the `react` package itself would not work due to a cyclical dependency.
|
2022-02-10 00:44:02 +08:00
|
|
|
'./packages/shared/ReactSharedInternals.js': (
|
|
|
|
|
bundleType,
|
|
|
|
|
entry,
|
|
|
|
|
dependencies
|
|
|
|
|
) => {
|
2022-02-23 09:03:51 +08:00
|
|
|
if (entry === 'react' || entry === 'react/src/ReactSharedSubset.js') {
|
2022-02-10 00:44:02 +08:00
|
|
|
return './packages/react/src/ReactSharedInternals.js';
|
2018-07-13 09:45:37 +08:00
|
|
|
}
|
2020-03-18 04:22:19 +08:00
|
|
|
if (!entry.startsWith('react/') && dependencies.indexOf('react') === -1) {
|
2018-07-17 05:31:59 +08:00
|
|
|
// React internals are unavailable if we can't reference the package.
|
|
|
|
|
// We return an error because we only want to throw if this module gets used.
|
|
|
|
|
return new Error(
|
|
|
|
|
'Cannot use a module that depends on ReactSharedInternals ' +
|
|
|
|
|
'from "' +
|
|
|
|
|
entry +
|
|
|
|
|
'" because it does not declare "react" in the package ' +
|
2019-12-15 02:09:25 +08:00
|
|
|
'dependencies or peerDependencies.'
|
2022-09-16 06:31:31 +08:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// Without this fork, importing `shared/ReactDOMSharedInternals` inside
|
|
|
|
|
// the `react-dom` package itself would not work due to a cyclical dependency.
|
|
|
|
|
'./packages/shared/ReactDOMSharedInternals.js': (
|
|
|
|
|
bundleType,
|
|
|
|
|
entry,
|
|
|
|
|
dependencies
|
|
|
|
|
) => {
|
2022-10-11 02:06:22 +08:00
|
|
|
if (entry === 'react-dom' || entry === 'react-dom/server-rendering-stub') {
|
2022-09-16 06:31:31 +08:00
|
|
|
return './packages/react-dom/src/ReactDOMSharedInternals.js';
|
|
|
|
|
}
|
|
|
|
|
if (
|
|
|
|
|
!entry.startsWith('react-dom/') &&
|
|
|
|
|
dependencies.indexOf('react-dom') === -1
|
|
|
|
|
) {
|
|
|
|
|
// React DOM internals are unavailable if we can't reference the package.
|
|
|
|
|
// We return an error because we only want to throw if this module gets used.
|
|
|
|
|
return new Error(
|
|
|
|
|
'Cannot use a module that depends on ReactDOMSharedInternals ' +
|
|
|
|
|
'from "' +
|
|
|
|
|
entry +
|
|
|
|
|
'" because it does not declare "react-dom" in the package ' +
|
|
|
|
|
'dependencies or peerDependencies.'
|
2018-07-17 05:31:59 +08:00
|
|
|
);
|
|
|
|
|
}
|
2018-07-13 09:45:37 +08:00
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
|
2017-11-30 20:11:00 +08:00
|
|
|
// We have a few forks for different environments.
|
2022-02-10 00:44:02 +08:00
|
|
|
'./packages/shared/ReactFeatureFlags.js': (bundleType, entry) => {
|
2017-11-30 20:11:00 +08:00
|
|
|
switch (entry) {
|
|
|
|
|
case 'react-native-renderer':
|
2018-04-19 04:16:50 +08:00
|
|
|
switch (bundleType) {
|
|
|
|
|
case RN_FB_DEV:
|
|
|
|
|
case RN_FB_PROD:
|
2018-06-27 04:28:41 +08:00
|
|
|
case RN_FB_PROFILING:
|
2022-02-10 00:44:02 +08:00
|
|
|
return './packages/shared/forks/ReactFeatureFlags.native-fb.js';
|
2018-04-19 04:16:50 +08:00
|
|
|
case RN_OSS_DEV:
|
|
|
|
|
case RN_OSS_PROD:
|
2018-06-12 04:16:27 +08:00
|
|
|
case RN_OSS_PROFILING:
|
2022-02-10 00:44:02 +08:00
|
|
|
return './packages/shared/forks/ReactFeatureFlags.native-oss.js';
|
2018-04-19 04:16:50 +08:00
|
|
|
default:
|
|
|
|
|
throw Error(
|
|
|
|
|
`Unexpected entry (${entry}) and bundleType (${bundleType})`
|
|
|
|
|
);
|
|
|
|
|
}
|
2018-02-09 05:28:17 +08:00
|
|
|
case 'react-native-renderer/fabric':
|
2018-04-19 04:16:50 +08:00
|
|
|
switch (bundleType) {
|
|
|
|
|
case RN_FB_DEV:
|
|
|
|
|
case RN_FB_PROD:
|
2018-06-27 04:28:41 +08:00
|
|
|
case RN_FB_PROFILING:
|
2022-02-10 00:44:02 +08:00
|
|
|
return './packages/shared/forks/ReactFeatureFlags.native-fb.js';
|
2018-04-19 04:16:50 +08:00
|
|
|
case RN_OSS_DEV:
|
|
|
|
|
case RN_OSS_PROD:
|
2018-06-12 04:16:27 +08:00
|
|
|
case RN_OSS_PROFILING:
|
2022-02-10 00:44:02 +08:00
|
|
|
return './packages/shared/forks/ReactFeatureFlags.native-oss.js';
|
2018-04-19 04:16:50 +08:00
|
|
|
default:
|
|
|
|
|
throw Error(
|
|
|
|
|
`Unexpected entry (${entry}) and bundleType (${bundleType})`
|
|
|
|
|
);
|
|
|
|
|
}
|
2018-03-29 05:57:25 +08:00
|
|
|
case 'react-test-renderer':
|
2018-07-07 03:55:29 +08:00
|
|
|
switch (bundleType) {
|
2020-07-30 04:31:05 +08:00
|
|
|
case RN_FB_DEV:
|
|
|
|
|
case RN_FB_PROD:
|
|
|
|
|
case RN_FB_PROFILING:
|
|
|
|
|
case RN_OSS_DEV:
|
|
|
|
|
case RN_OSS_PROD:
|
|
|
|
|
case RN_OSS_PROFILING:
|
2022-02-10 00:44:02 +08:00
|
|
|
return './packages/shared/forks/ReactFeatureFlags.test-renderer.native.js';
|
2018-07-07 03:55:29 +08:00
|
|
|
case FB_WWW_DEV:
|
|
|
|
|
case FB_WWW_PROD:
|
|
|
|
|
case FB_WWW_PROFILING:
|
2022-02-10 00:44:02 +08:00
|
|
|
return './packages/shared/forks/ReactFeatureFlags.test-renderer.www.js';
|
2018-07-07 03:55:29 +08:00
|
|
|
}
|
2022-02-10 00:44:02 +08:00
|
|
|
return './packages/shared/forks/ReactFeatureFlags.test-renderer.js';
|
2022-02-09 12:12:31 +08:00
|
|
|
case 'react-dom/unstable_testing':
|
2020-02-14 04:33:53 +08:00
|
|
|
switch (bundleType) {
|
|
|
|
|
case FB_WWW_DEV:
|
|
|
|
|
case FB_WWW_PROD:
|
|
|
|
|
case FB_WWW_PROFILING:
|
2022-02-10 00:44:02 +08:00
|
|
|
return './packages/shared/forks/ReactFeatureFlags.testing.www.js';
|
2020-02-14 04:33:53 +08:00
|
|
|
}
|
2022-02-10 00:44:02 +08:00
|
|
|
return './packages/shared/forks/ReactFeatureFlags.testing.js';
|
2020-08-04 05:40:58 +08:00
|
|
|
default:
|
2020-08-04 02:45:50 +08:00
|
|
|
switch (bundleType) {
|
|
|
|
|
case FB_WWW_DEV:
|
|
|
|
|
case FB_WWW_PROD:
|
|
|
|
|
case FB_WWW_PROFILING:
|
2022-02-10 00:44:02 +08:00
|
|
|
return './packages/shared/forks/ReactFeatureFlags.www.js';
|
2020-08-04 02:45:50 +08:00
|
|
|
case RN_FB_DEV:
|
|
|
|
|
case RN_FB_PROD:
|
|
|
|
|
case RN_FB_PROFILING:
|
2022-02-10 00:44:02 +08:00
|
|
|
return './packages/shared/forks/ReactFeatureFlags.native-fb.js';
|
2017-11-30 20:11:00 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
|
2022-02-10 00:44:02 +08:00
|
|
|
'./packages/scheduler/index.js': (bundleType, entry, dependencies) => {
|
2018-05-30 04:30:04 +08:00
|
|
|
switch (bundleType) {
|
2018-09-02 03:00:00 +08:00
|
|
|
case UMD_DEV:
|
|
|
|
|
case UMD_PROD:
|
2018-09-14 08:44:08 +08:00
|
|
|
case UMD_PROFILING:
|
2018-09-02 03:00:00 +08:00
|
|
|
if (dependencies.indexOf('react') === -1) {
|
|
|
|
|
// It's only safe to use this fork for modules that depend on React,
|
|
|
|
|
// because they read the re-exported API from the SECRET_INTERNALS object.
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
// Optimization: for UMDs, use the API that is already a part of the React
|
|
|
|
|
// package instead of requiring it to be loaded via a separate <script> tag
|
2022-02-10 00:44:02 +08:00
|
|
|
return './packages/shared/forks/Scheduler.umd.js';
|
2018-09-02 03:00:00 +08:00
|
|
|
default:
|
2018-09-04 02:55:58 +08:00
|
|
|
// For other bundles, use the shared NPM package.
|
2018-09-02 03:00:00 +08:00
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2022-02-10 00:44:02 +08:00
|
|
|
'./packages/scheduler/src/SchedulerFeatureFlags.js': (
|
|
|
|
|
bundleType,
|
|
|
|
|
entry,
|
|
|
|
|
dependencies
|
|
|
|
|
) => {
|
2018-12-18 09:55:34 +08:00
|
|
|
if (
|
Add new mock build of Scheduler with flush, yield API (#14964)
* Add new mock build of Scheduler with flush, yield API
Test environments need a way to take control of the Scheduler queue and
incrementally flush work. Our current tests accomplish this either using
dynamic injection, or by using Jest's fake timers feature. Both of these
options are fragile and rely too much on implementation details.
In this new approach, we have a separate build of Scheduler that is
specifically designed for test environments. We mock the default
implementation like we would any other module; in our case, via Jest.
This special build has methods like `flushAll` and `yieldValue` that
control when work is flushed. These methods are based on equivalent
methods we've been using to write incremental React tests. Eventually
we may want to migrate the React tests to interact with the mock
Scheduler directly, instead of going through the host config like we
currently do.
For now, I'm using our custom static injection infrastructure to create
the two builds of Scheduler — a default build for DOM (which falls back
to a naive timer based implementation), and the new mock build. I did it
this way because it allows me to share most of the implementation, which
isn't specific to a host environment — e.g. everything related to the
priority queue. It may be better to duplicate the shared code instead,
especially considering that future environments (like React Native) may
have entirely forked implementations. I'd prefer to wait until the
implementation stabilizes before worrying about that, but I'm open to
changing this now if we decide it's important enough.
* Mock Scheduler in bundle tests, too
* Remove special case by making regex more restrictive
2019-02-27 12:51:17 +08:00
|
|
|
bundleType === FB_WWW_DEV ||
|
|
|
|
|
bundleType === FB_WWW_PROD ||
|
|
|
|
|
bundleType === FB_WWW_PROFILING
|
2018-12-18 09:55:34 +08:00
|
|
|
) {
|
2022-02-10 00:44:02 +08:00
|
|
|
return './packages/scheduler/src/forks/SchedulerFeatureFlags.www.js';
|
2018-12-18 09:55:34 +08:00
|
|
|
}
|
2022-02-10 00:44:02 +08:00
|
|
|
return './packages/scheduler/src/SchedulerFeatureFlags.js';
|
2018-12-18 09:55:34 +08:00
|
|
|
},
|
|
|
|
|
|
2022-02-10 00:44:02 +08:00
|
|
|
'./packages/shared/consoleWithStackDev.js': (bundleType, entry) => {
|
2017-11-30 20:11:00 +08:00
|
|
|
switch (bundleType) {
|
2018-04-19 04:16:50 +08:00
|
|
|
case FB_WWW_DEV:
|
2022-02-10 00:44:02 +08:00
|
|
|
return './packages/shared/forks/consoleWithStackDev.www.js';
|
2018-06-19 23:03:45 +08:00
|
|
|
default:
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
},
|
2017-11-30 20:11:00 +08:00
|
|
|
|
2022-02-10 00:44:02 +08:00
|
|
|
'./packages/react/src/ReactSharedInternals.js': (bundleType, entry) => {
|
2019-05-11 04:51:39 +08:00
|
|
|
switch (bundleType) {
|
|
|
|
|
case UMD_DEV:
|
|
|
|
|
case UMD_PROD:
|
|
|
|
|
case UMD_PROFILING:
|
2022-02-10 00:44:02 +08:00
|
|
|
return './packages/react/src/forks/ReactSharedInternals.umd.js';
|
2019-05-11 04:51:39 +08:00
|
|
|
default:
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2017-12-01 03:10:46 +08:00
|
|
|
// Different wrapping/reporting for caught errors.
|
2022-02-10 00:44:02 +08:00
|
|
|
'./packages/shared/invokeGuardedCallbackImpl.js': (bundleType, entry) => {
|
2017-12-01 03:10:46 +08:00
|
|
|
switch (bundleType) {
|
2018-04-19 04:16:50 +08:00
|
|
|
case FB_WWW_DEV:
|
|
|
|
|
case FB_WWW_PROD:
|
2018-06-27 04:28:41 +08:00
|
|
|
case FB_WWW_PROFILING:
|
2022-02-10 00:44:02 +08:00
|
|
|
return './packages/shared/forks/invokeGuardedCallbackImpl.www.js';
|
2017-12-01 03:10:46 +08:00
|
|
|
default:
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2022-02-10 00:44:02 +08:00
|
|
|
'./packages/react-reconciler/src/ReactFiberReconciler.js': (
|
2020-03-13 02:38:32 +08:00
|
|
|
bundleType,
|
|
|
|
|
entry,
|
|
|
|
|
dependencies,
|
|
|
|
|
moduleType,
|
|
|
|
|
bundle
|
|
|
|
|
) => {
|
|
|
|
|
if (bundle.enableNewReconciler) {
|
|
|
|
|
switch (bundleType) {
|
|
|
|
|
case FB_WWW_DEV:
|
|
|
|
|
case FB_WWW_PROD:
|
|
|
|
|
case FB_WWW_PROFILING:
|
|
|
|
|
// Use the forked version of the reconciler
|
2022-02-10 00:44:02 +08:00
|
|
|
return './packages/react-reconciler/src/ReactFiberReconciler.new.js';
|
2020-03-13 02:38:32 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Otherwise, use the non-forked version.
|
2022-02-10 00:44:02 +08:00
|
|
|
return './packages/react-reconciler/src/ReactFiberReconciler.old.js';
|
2020-03-13 02:38:32 +08:00
|
|
|
},
|
|
|
|
|
|
2022-02-10 00:44:02 +08:00
|
|
|
'./packages/react-reconciler/src/ReactEventPriorities.js': (
|
2021-03-24 04:57:28 +08:00
|
|
|
bundleType,
|
|
|
|
|
entry,
|
|
|
|
|
dependencies,
|
|
|
|
|
moduleType,
|
|
|
|
|
bundle
|
|
|
|
|
) => {
|
|
|
|
|
if (bundle.enableNewReconciler) {
|
|
|
|
|
switch (bundleType) {
|
|
|
|
|
case FB_WWW_DEV:
|
|
|
|
|
case FB_WWW_PROD:
|
|
|
|
|
case FB_WWW_PROFILING:
|
|
|
|
|
// Use the forked version of the reconciler
|
2022-02-10 00:44:02 +08:00
|
|
|
return './packages/react-reconciler/src/ReactEventPriorities.new.js';
|
2021-03-24 04:57:28 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Otherwise, use the non-forked version.
|
2022-02-10 00:44:02 +08:00
|
|
|
return './packages/react-reconciler/src/ReactEventPriorities.old.js';
|
2021-03-24 04:57:28 +08:00
|
|
|
},
|
|
|
|
|
|
2022-02-10 00:44:02 +08:00
|
|
|
'./packages/react-reconciler/src/ReactFiberHotReloading.js': (
|
2020-04-09 10:44:52 +08:00
|
|
|
bundleType,
|
|
|
|
|
entry,
|
|
|
|
|
dependencies,
|
|
|
|
|
moduleType,
|
|
|
|
|
bundle
|
|
|
|
|
) => {
|
|
|
|
|
if (bundle.enableNewReconciler) {
|
|
|
|
|
switch (bundleType) {
|
|
|
|
|
case FB_WWW_DEV:
|
|
|
|
|
case FB_WWW_PROD:
|
|
|
|
|
case FB_WWW_PROFILING:
|
|
|
|
|
// Use the forked version of the reconciler
|
2022-02-10 00:44:02 +08:00
|
|
|
return './packages/react-reconciler/src/ReactFiberHotReloading.new.js';
|
2020-04-09 10:44:52 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Otherwise, use the non-forked version.
|
2022-02-10 00:44:02 +08:00
|
|
|
return './packages/react-reconciler/src/ReactFiberHotReloading.old.js';
|
2020-04-09 10:44:52 +08:00
|
|
|
},
|
|
|
|
|
|
2017-12-01 03:10:46 +08:00
|
|
|
// Different dialogs for caught errors.
|
2022-02-10 00:44:02 +08:00
|
|
|
'./packages/react-reconciler/src/ReactFiberErrorDialog.js': (
|
|
|
|
|
bundleType,
|
|
|
|
|
entry
|
|
|
|
|
) => {
|
2017-12-01 01:57:13 +08:00
|
|
|
switch (bundleType) {
|
2018-04-19 04:16:50 +08:00
|
|
|
case FB_WWW_DEV:
|
|
|
|
|
case FB_WWW_PROD:
|
2018-06-27 04:28:41 +08:00
|
|
|
case FB_WWW_PROFILING:
|
2017-12-01 01:57:13 +08:00
|
|
|
// Use the www fork which shows an error dialog.
|
2022-02-10 00:44:02 +08:00
|
|
|
return './packages/react-reconciler/src/forks/ReactFiberErrorDialog.www.js';
|
2018-04-19 04:16:50 +08:00
|
|
|
case RN_OSS_DEV:
|
|
|
|
|
case RN_OSS_PROD:
|
2018-06-12 04:16:27 +08:00
|
|
|
case RN_OSS_PROFILING:
|
2018-04-19 04:16:50 +08:00
|
|
|
case RN_FB_DEV:
|
|
|
|
|
case RN_FB_PROD:
|
2018-06-27 04:28:41 +08:00
|
|
|
case RN_FB_PROFILING:
|
2017-12-01 01:57:13 +08:00
|
|
|
switch (entry) {
|
|
|
|
|
case 'react-native-renderer':
|
2018-05-15 09:47:40 +08:00
|
|
|
case 'react-native-renderer/fabric':
|
2017-12-01 01:57:13 +08:00
|
|
|
// Use the RN fork which plays well with redbox.
|
2022-02-10 00:44:02 +08:00
|
|
|
return './packages/react-reconciler/src/forks/ReactFiberErrorDialog.native.js';
|
2017-12-01 01:57:13 +08:00
|
|
|
default:
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
},
|
2017-12-08 06:28:59 +08:00
|
|
|
|
2022-02-10 00:44:02 +08:00
|
|
|
'./packages/react-reconciler/src/ReactFiberHostConfig.js': (
|
2018-05-19 18:29:11 +08:00
|
|
|
bundleType,
|
|
|
|
|
entry,
|
|
|
|
|
dependencies,
|
|
|
|
|
moduleType
|
|
|
|
|
) => {
|
|
|
|
|
if (dependencies.indexOf('react-reconciler') !== -1) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
if (moduleType !== RENDERER && moduleType !== RECONCILER) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
// eslint-disable-next-line no-for-of-loops/no-for-of-loops
|
|
|
|
|
for (let rendererInfo of inlinedHostConfigs) {
|
|
|
|
|
if (rendererInfo.entryPoints.indexOf(entry) !== -1) {
|
2022-02-10 00:44:02 +08:00
|
|
|
return `./packages/react-reconciler/src/forks/ReactFiberHostConfig.${rendererInfo.shortName}.js`;
|
2018-05-19 18:29:11 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
throw new Error(
|
|
|
|
|
'Expected ReactFiberHostConfig to always be replaced with a shim, but ' +
|
|
|
|
|
`found no mention of "${entry}" entry point in ./scripts/shared/inlinedHostConfigs.js. ` +
|
|
|
|
|
'Did you mean to add it there to associate it with a specific renderer?'
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2022-02-10 00:44:02 +08:00
|
|
|
'./packages/react-server/src/ReactServerStreamConfig.js': (
|
2018-12-01 03:38:22 +08:00
|
|
|
bundleType,
|
|
|
|
|
entry,
|
|
|
|
|
dependencies,
|
|
|
|
|
moduleType
|
|
|
|
|
) => {
|
2019-10-30 05:45:47 +08:00
|
|
|
if (dependencies.indexOf('react-server') !== -1) {
|
2018-12-01 03:38:22 +08:00
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
if (moduleType !== RENDERER && moduleType !== RECONCILER) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
// eslint-disable-next-line no-for-of-loops/no-for-of-loops
|
|
|
|
|
for (let rendererInfo of inlinedHostConfigs) {
|
|
|
|
|
if (rendererInfo.entryPoints.indexOf(entry) !== -1) {
|
2019-10-30 05:45:47 +08:00
|
|
|
if (!rendererInfo.isServerSupported) {
|
2018-12-01 03:38:22 +08:00
|
|
|
return null;
|
|
|
|
|
}
|
2022-02-10 00:44:02 +08:00
|
|
|
return `./packages/react-server/src/forks/ReactServerStreamConfig.${rendererInfo.shortName}.js`;
|
2018-12-01 03:38:22 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
throw new Error(
|
2020-03-08 03:23:30 +08:00
|
|
|
'Expected ReactServerStreamConfig to always be replaced with a shim, but ' +
|
2018-12-01 03:38:22 +08:00
|
|
|
`found no mention of "${entry}" entry point in ./scripts/shared/inlinedHostConfigs.js. ` +
|
|
|
|
|
'Did you mean to add it there to associate it with a specific renderer?'
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2022-02-10 00:44:02 +08:00
|
|
|
'./packages/react-server/src/ReactServerFormatConfig.js': (
|
2018-12-01 03:38:22 +08:00
|
|
|
bundleType,
|
|
|
|
|
entry,
|
|
|
|
|
dependencies,
|
|
|
|
|
moduleType
|
|
|
|
|
) => {
|
2019-10-30 05:45:47 +08:00
|
|
|
if (dependencies.indexOf('react-server') !== -1) {
|
2018-12-01 03:38:22 +08:00
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
if (moduleType !== RENDERER && moduleType !== RECONCILER) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
// eslint-disable-next-line no-for-of-loops/no-for-of-loops
|
|
|
|
|
for (let rendererInfo of inlinedHostConfigs) {
|
|
|
|
|
if (rendererInfo.entryPoints.indexOf(entry) !== -1) {
|
2019-10-30 05:45:47 +08:00
|
|
|
if (!rendererInfo.isServerSupported) {
|
2018-12-01 03:38:22 +08:00
|
|
|
return null;
|
|
|
|
|
}
|
2022-02-10 00:44:02 +08:00
|
|
|
return `./packages/react-server/src/forks/ReactServerFormatConfig.${rendererInfo.shortName}.js`;
|
2018-12-01 03:38:22 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
throw new Error(
|
2019-10-30 05:45:47 +08:00
|
|
|
'Expected ReactServerFormatConfig to always be replaced with a shim, but ' +
|
|
|
|
|
`found no mention of "${entry}" entry point in ./scripts/shared/inlinedHostConfigs.js. ` +
|
|
|
|
|
'Did you mean to add it there to associate it with a specific renderer?'
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2022-02-10 00:44:02 +08:00
|
|
|
'./packages/react-server/src/ReactFlightServerConfig.js': (
|
2020-03-11 05:55:04 +08:00
|
|
|
bundleType,
|
|
|
|
|
entry,
|
|
|
|
|
dependencies,
|
|
|
|
|
moduleType
|
|
|
|
|
) => {
|
|
|
|
|
if (dependencies.indexOf('react-server') !== -1) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
if (moduleType !== RENDERER && moduleType !== RECONCILER) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
// eslint-disable-next-line no-for-of-loops/no-for-of-loops
|
|
|
|
|
for (let rendererInfo of inlinedHostConfigs) {
|
|
|
|
|
if (rendererInfo.entryPoints.indexOf(entry) !== -1) {
|
|
|
|
|
if (!rendererInfo.isServerSupported) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2022-02-10 00:44:02 +08:00
|
|
|
return `./packages/react-server/src/forks/ReactFlightServerConfig.${rendererInfo.shortName}.js`;
|
2020-03-11 05:55:04 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
throw new Error(
|
|
|
|
|
'Expected ReactFlightServerConfig to always be replaced with a shim, but ' +
|
|
|
|
|
`found no mention of "${entry}" entry point in ./scripts/shared/inlinedHostConfigs.js. ` +
|
|
|
|
|
'Did you mean to add it there to associate it with a specific renderer?'
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2022-02-10 00:44:02 +08:00
|
|
|
'./packages/react-client/src/ReactFlightClientHostConfig.js': (
|
2019-10-30 05:45:47 +08:00
|
|
|
bundleType,
|
|
|
|
|
entry,
|
|
|
|
|
dependencies,
|
|
|
|
|
moduleType
|
|
|
|
|
) => {
|
2020-03-08 03:23:30 +08:00
|
|
|
if (dependencies.indexOf('react-client') !== -1) {
|
2019-10-30 05:45:47 +08:00
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
if (moduleType !== RENDERER && moduleType !== RECONCILER) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
// eslint-disable-next-line no-for-of-loops/no-for-of-loops
|
|
|
|
|
for (let rendererInfo of inlinedHostConfigs) {
|
|
|
|
|
if (rendererInfo.entryPoints.indexOf(entry) !== -1) {
|
|
|
|
|
if (!rendererInfo.isServerSupported) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2022-02-10 00:44:02 +08:00
|
|
|
return `./packages/react-client/src/forks/ReactFlightClientHostConfig.${rendererInfo.shortName}.js`;
|
2019-10-30 05:45:47 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
throw new Error(
|
|
|
|
|
'Expected ReactFlightClientHostConfig to always be replaced with a shim, but ' +
|
2018-12-01 03:38:22 +08:00
|
|
|
`found no mention of "${entry}" entry point in ./scripts/shared/inlinedHostConfigs.js. ` +
|
|
|
|
|
'Did you mean to add it there to associate it with a specific renderer?'
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2017-12-08 06:28:59 +08:00
|
|
|
// We wrap top-level listeners into guards on www.
|
2022-09-29 07:45:59 +08:00
|
|
|
'./packages/react-dom-bindings/src/events/EventListener.js': (
|
|
|
|
|
bundleType,
|
|
|
|
|
entry
|
|
|
|
|
) => {
|
2017-12-08 06:28:59 +08:00
|
|
|
switch (bundleType) {
|
2018-04-19 04:16:50 +08:00
|
|
|
case FB_WWW_DEV:
|
|
|
|
|
case FB_WWW_PROD:
|
2018-06-27 04:28:41 +08:00
|
|
|
case FB_WWW_PROFILING:
|
2020-03-18 21:13:50 +08:00
|
|
|
if (__EXPERIMENTAL__) {
|
|
|
|
|
// In modern builds we don't use the indirection. We just use raw DOM.
|
|
|
|
|
return null;
|
|
|
|
|
} else {
|
|
|
|
|
// Use the www fork which is integrated with TimeSlice profiling.
|
2022-09-29 07:45:59 +08:00
|
|
|
return './packages/react-dom-bindings/src/events/forks/EventListener-www.js';
|
2020-03-18 21:13:50 +08:00
|
|
|
}
|
2017-12-08 06:28:59 +08:00
|
|
|
default:
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-11-01 06:38:03 +08:00
|
|
|
|
2022-02-10 00:44:02 +08:00
|
|
|
'./packages/use-sync-external-store/src/useSyncExternalStore.js': (
|
|
|
|
|
bundleType,
|
|
|
|
|
entry
|
|
|
|
|
) => {
|
2021-11-01 06:38:03 +08:00
|
|
|
if (entry.startsWith('use-sync-external-store/shim')) {
|
2022-02-10 00:44:02 +08:00
|
|
|
return './packages/use-sync-external-store/src/forks/useSyncExternalStore.forward-to-shim.js';
|
2021-11-01 06:38:03 +08:00
|
|
|
}
|
|
|
|
|
if (entry !== 'use-sync-external-store') {
|
|
|
|
|
// Internal modules that aren't shims should use the native API from the
|
|
|
|
|
// react package.
|
2022-02-10 00:44:02 +08:00
|
|
|
return './packages/use-sync-external-store/src/forks/useSyncExternalStore.forward-to-built-in.js';
|
2021-11-01 06:38:03 +08:00
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
|
2022-02-10 00:44:02 +08:00
|
|
|
'./packages/use-sync-external-store/src/isServerEnvironment.js': (
|
|
|
|
|
bundleType,
|
|
|
|
|
entry
|
|
|
|
|
) => {
|
2021-11-01 06:38:03 +08:00
|
|
|
if (entry.endsWith('.native')) {
|
2022-02-10 00:44:02 +08:00
|
|
|
return './packages/use-sync-external-store/src/forks/isServerEnvironment.native.js';
|
2021-11-01 06:38:03 +08:00
|
|
|
}
|
|
|
|
|
},
|
2017-11-30 20:11:00 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
module.exports = forks;
|