Skip to content

Commit 2c9d8ef

Browse files
authored
Add react-reconciler/constants entry point (#21062)
* Add react-reconciler/constants entry point * Move root tags to /constants
1 parent d0eaf78 commit 2c9d8ef

File tree

8 files changed

+56
-7
lines changed

8 files changed

+56
-7
lines changed

packages/react-noop-renderer/src/createReactNoop.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,16 @@ import type {RootTag} from 'react-reconciler/src/ReactRootTags';
2121

2222
import * as Scheduler from 'scheduler/unstable_mock';
2323
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';
2529

2630
import ReactSharedInternals from 'shared/ReactSharedInternals';
2731
import enqueueTask from 'shared/enqueueTask';
2832
const {IsSomeRendererActing} = ReactSharedInternals;
2933

30-
// TODO: Publish public entry point that exports the event priority constants
31-
const DefaultEventPriority = 8;
32-
3334
type Container = {
3435
rootID: string,
3536
children: Array<Instance | TextInstance>,

packages/react-reconciler/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -216,14 +216,14 @@ This is a property (not a function) that should be set to `true` if your rendere
216216

217217
#### `getCurrentEventPriority`
218218

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:
220220

221221
```js
222222
import {
223223
DiscreteEventPriority,
224224
ContinuousEventPriority,
225225
DefaultEventPriority,
226-
} from './ReactFiberReconciler/src/ReactEventPriorities';
226+
} from 'react-reconciler/constants';
227227

228228
const HostConfig = {
229229
// ...
+12
Original file line numberDiff line numberDiff line change
@@ -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';
Original file line numberDiff line numberDiff line change
@@ -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
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"LICENSE",
1313
"README.md",
1414
"build-info.json",
15+
"constants.js",
1516
"index.js",
1617
"reflection.js",
1718
"cjs/"
Original file line numberDiff line numberDiff line change
@@ -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
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ const bundles = [
604604
externals: ['react'],
605605
},
606606

607-
/******* Reflection *******/
607+
/******* Reconciler Reflection *******/
608608
{
609609
moduleType: RENDERER_UTILS,
610610
bundleTypes: [NODE_DEV, NODE_PROD],
@@ -613,6 +613,15 @@ const bundles = [
613613
externals: [],
614614
},
615615

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+
616625
/******* React Is *******/
617626
{
618627
bundleTypes: [

scripts/rollup/modules.js

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const importSideEffects = Object.freeze({
1616
'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface': HAS_NO_SIDE_EFFECTS_ON_IMPORT,
1717
scheduler: HAS_NO_SIDE_EFFECTS_ON_IMPORT,
1818
'scheduler/tracing': HAS_NO_SIDE_EFFECTS_ON_IMPORT,
19+
react: HAS_NO_SIDE_EFFECTS_ON_IMPORT,
1920
'react-dom/server': HAS_NO_SIDE_EFFECTS_ON_IMPORT,
2021
'react/jsx-dev-runtime': HAS_NO_SIDE_EFFECTS_ON_IMPORT,
2122
'react-fetch/node': HAS_NO_SIDE_EFFECTS_ON_IMPORT,

0 commit comments

Comments
 (0)