Skip to content

Commit

Permalink
Add react-reconciler/constants entry point (facebook#21062)
Browse files Browse the repository at this point in the history
* Add react-reconciler/constants entry point

* Move root tags to /constants
  • Loading branch information
gaearon authored and koto committed Jun 15, 2021
1 parent 15754f7 commit e9ab684
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 7 deletions.
9 changes: 5 additions & 4 deletions packages/react-noop-renderer/src/createReactNoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ import type {RootTag} from 'react-reconciler/src/ReactRootTags';

import * as Scheduler from 'scheduler/unstable_mock';
import {REACT_FRAGMENT_TYPE, REACT_ELEMENT_TYPE} from 'shared/ReactSymbols';
import {ConcurrentRoot, LegacyRoot} from 'react-reconciler/src/ReactRootTags';
import {
DefaultEventPriority,
ConcurrentRoot,
LegacyRoot,
} from 'react-reconciler/constants';

import ReactSharedInternals from 'shared/ReactSharedInternals';
import enqueueTask from 'shared/enqueueTask';
const {IsSomeRendererActing} = ReactSharedInternals;

// TODO: Publish public entry point that exports the event priority constants
const DefaultEventPriority = 8;

type Container = {
rootID: string,
children: Array<Instance | TextInstance>,
Expand Down
4 changes: 2 additions & 2 deletions packages/react-reconciler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,14 @@ This is a property (not a function) that should be set to `true` if your rendere

#### `getCurrentEventPriority`

To implement this method, you'll need some constants available on the _returned_ `Renderer` object:
To implement this method, you'll need some constants available on the special `react-reconciler/constants` entry point:

```js
import {
DiscreteEventPriority,
ContinuousEventPriority,
DefaultEventPriority,
} from './ReactFiberReconciler/src/ReactEventPriorities';
} from 'react-reconciler/constants';

const HostConfig = {
// ...
Expand Down
12 changes: 12 additions & 0 deletions packages/react-reconciler/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* 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
*/

'use strict';

export * from './src/ReactReconcilerConstants';
7 changes: 7 additions & 0 deletions packages/react-reconciler/npm/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react-reconciler-constants.production.min.js');
} else {
module.exports = require('./cjs/react-reconciler-constants.development.js');
}
1 change: 1 addition & 0 deletions packages/react-reconciler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"LICENSE",
"README.md",
"build-info.json",
"constants.js",
"index.js",
"reflection.js",
"cjs/"
Expand Down
18 changes: 18 additions & 0 deletions packages/react-reconciler/src/ReactReconcilerConstants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* 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
*/

// These are semi-public constants exposed to any third-party renderers.
// Only expose the minimal subset necessary to implement a host config.

export {
DiscreteEventPriority,
ContinuousEventPriority,
DefaultEventPriority,
} from './ReactEventPriorities';
export {ConcurrentRoot, LegacyRoot} from './ReactRootTags';
11 changes: 10 additions & 1 deletion scripts/rollup/bundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ const bundles = [
externals: ['react'],
},

/******* Reflection *******/
/******* Reconciler Reflection *******/
{
moduleType: RENDERER_UTILS,
bundleTypes: [NODE_DEV, NODE_PROD],
Expand All @@ -613,6 +613,15 @@ const bundles = [
externals: [],
},

/******* Reconciler Constants *******/
{
moduleType: RENDERER_UTILS,
bundleTypes: [NODE_DEV, NODE_PROD],
entry: 'react-reconciler/constants',
global: 'ReactReconcilerConstants',
externals: [],
},

/******* React Is *******/
{
bundleTypes: [
Expand Down
1 change: 1 addition & 0 deletions scripts/rollup/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const importSideEffects = Object.freeze({
'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface': HAS_NO_SIDE_EFFECTS_ON_IMPORT,
scheduler: HAS_NO_SIDE_EFFECTS_ON_IMPORT,
'scheduler/tracing': HAS_NO_SIDE_EFFECTS_ON_IMPORT,
react: HAS_NO_SIDE_EFFECTS_ON_IMPORT,
'react-dom/server': HAS_NO_SIDE_EFFECTS_ON_IMPORT,
'react/jsx-dev-runtime': HAS_NO_SIDE_EFFECTS_ON_IMPORT,
'react-fetch/node': HAS_NO_SIDE_EFFECTS_ON_IMPORT,
Expand Down

0 comments on commit e9ab684

Please sign in to comment.