Skip to content

Commit

Permalink
Add react-reconciler/constants entry point
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Mar 24, 2021
1 parent d0eaf78 commit 480b96e
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 6 deletions.
4 changes: 1 addition & 3 deletions packages/react-noop-renderer/src/createReactNoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@ 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} 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/ReactEventPriorities';
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
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

0 comments on commit 480b96e

Please sign in to comment.