Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add react-reconciler/constants entry point #21062

Merged
merged 2 commits into from
Mar 24, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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';
gaearon marked this conversation as resolved.
Show resolved Hide resolved
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