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 all commits
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
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