Add react-reconciler/constants entry point (#21062)
* Add react-reconciler/constants entry point * Move root tags to /constants
Dan Abramov committed
Mar 24, 2021 at 02:13 UTC
2c9d8efc8e8202929d3c737459050205f2848d79
8 files changed
+56
-7
packages/react-noop-renderer/src/createReactNoop.js
+5
-4
@@ -21,15 +21,16 @@ import type {RootTag} from 'react-reconciler/src/ReactRootTags';
21
22
import * as Scheduler from 'scheduler/unstable_mock';
23
import {REACT_FRAGMENT_TYPE, REACT_ELEMENT_TYPE} from 'shared/ReactSymbols';
24
-import {ConcurrentRoot, LegacyRoot} from 'react-reconciler/src/ReactRootTags';
24
+import {
25
+ DefaultEventPriority,
26
+ ConcurrentRoot,
27
+ LegacyRoot,
28
+} from 'react-reconciler/constants';
29
30
import ReactSharedInternals from 'shared/ReactSharedInternals';
31
import enqueueTask from 'shared/enqueueTask';
32
const {IsSomeRendererActing} = ReactSharedInternals;
33
30
-// TODO: Publish public entry point that exports the event priority constants
31
-const DefaultEventPriority = 8;
32
-
34
type Container = {
35
rootID: string,
36
children: Array<Instance | TextInstance>,
packages/react-reconciler/README.md
+2
-2
@@ -216,14 +216,14 @@ This is a property (not a function) that should be set to `true` if your rendere
216
217
#### `getCurrentEventPriority`
218
219
-To implement this method, you'll need some constants available on the _returned_ `Renderer` object:
219
+To implement this method, you'll need some constants available on the special `react-reconciler/constants` entry point:
220
221
```js
222
import {
223
DiscreteEventPriority,
224
ContinuousEventPriority,
225
DefaultEventPriority,
226
-} from './ReactFiberReconciler/src/ReactEventPriorities';
226
+} from 'react-reconciler/constants';
227
228
const HostConfig = {
229
// ...
packages/react-reconciler/constants.js
new
+12
@@ -0,0 +1,12 @@
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
+'use strict';
11
+
12
+export * from './src/ReactReconcilerConstants';
packages/react-reconciler/npm/constants.js
new
+7
@@ -0,0 +1,7 @@
1
+'use strict';
2
+
3
+if (process.env.NODE_ENV === 'production') {
4
+ module.exports = require('./cjs/react-reconciler-constants.production.min.js');
5
+} else {
6
+ module.exports = require('./cjs/react-reconciler-constants.development.js');
7
+}
packages/react-reconciler/package.json
+1
@@ -12,6 +12,7 @@
12
"LICENSE",
13
"README.md",
14
"build-info.json",
15
+ "constants.js",
16
"index.js",
17
"reflection.js",
18
"cjs/"
packages/react-reconciler/src/ReactReconcilerConstants.js
new
+18
@@ -0,0 +1,18 @@
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
+// These are semi-public constants exposed to any third-party renderers.
11
+// Only expose the minimal subset necessary to implement a host config.
12
+
13
+export {
14
+ DiscreteEventPriority,
15
+ ContinuousEventPriority,
16
+ DefaultEventPriority,
17
+} from './ReactEventPriorities';
18
+export {ConcurrentRoot, LegacyRoot} from './ReactRootTags';
scripts/rollup/bundles.js
+10
-1
@@ -604,7 +604,7 @@ const bundles = [
604
externals: ['react'],
605
},
606
607
- /******* Reflection *******/
607
+ /******* Reconciler Reflection *******/
608
{
609
moduleType: RENDERER_UTILS,
610
bundleTypes: [NODE_DEV, NODE_PROD],
@@ -613,6 +613,15 @@ const bundles = [
613
externals: [],
614
},
615
616
+ /******* Reconciler Constants *******/
617
+ {
618
+ moduleType: RENDERER_UTILS,
619
+ bundleTypes: [NODE_DEV, NODE_PROD],
620
+ entry: 'react-reconciler/constants',
621
+ global: 'ReactReconcilerConstants',
622
+ externals: [],
623
+ },
624
+
625
/******* React Is *******/
626
{
627
bundleTypes: [
scripts/rollup/modules.js
+1
@@ -16,6 +16,7 @@ const importSideEffects = Object.freeze({
16
'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface': HAS_NO_SIDE_EFFECTS_ON_IMPORT,
17
scheduler: HAS_NO_SIDE_EFFECTS_ON_IMPORT,
18
'scheduler/tracing': HAS_NO_SIDE_EFFECTS_ON_IMPORT,
19
+ react: HAS_NO_SIDE_EFFECTS_ON_IMPORT,
20
'react-dom/server': HAS_NO_SIDE_EFFECTS_ON_IMPORT,
21
'react/jsx-dev-runtime': HAS_NO_SIDE_EFFECTS_ON_IMPORT,
22
'react-fetch/node': HAS_NO_SIDE_EFFECTS_ON_IMPORT,