diff --git a/packages/react-noop-renderer/src/createReactNoop.js b/packages/react-noop-renderer/src/createReactNoop.js index 6cef4f7ade498..1f90af7bac00f 100644 --- a/packages/react-noop-renderer/src/createReactNoop.js +++ b/packages/react-noop-renderer/src/createReactNoop.js @@ -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, diff --git a/packages/react-reconciler/README.md b/packages/react-reconciler/README.md index 4a0ce2aa427d9..ec15ffd27436d 100644 --- a/packages/react-reconciler/README.md +++ b/packages/react-reconciler/README.md @@ -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 = { // ... diff --git a/packages/react-reconciler/constants.js b/packages/react-reconciler/constants.js new file mode 100644 index 0000000000000..c98f17cf9cc07 --- /dev/null +++ b/packages/react-reconciler/constants.js @@ -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'; diff --git a/packages/react-reconciler/npm/constants.js b/packages/react-reconciler/npm/constants.js new file mode 100644 index 0000000000000..df4f2b61987c0 --- /dev/null +++ b/packages/react-reconciler/npm/constants.js @@ -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'); +} diff --git a/packages/react-reconciler/package.json b/packages/react-reconciler/package.json index a6fd3a05a9627..7a681953eeb2e 100644 --- a/packages/react-reconciler/package.json +++ b/packages/react-reconciler/package.json @@ -12,6 +12,7 @@ "LICENSE", "README.md", "build-info.json", + "constants.js", "index.js", "reflection.js", "cjs/" diff --git a/packages/react-reconciler/src/ReactReconcilerConstants.js b/packages/react-reconciler/src/ReactReconcilerConstants.js new file mode 100644 index 0000000000000..ce41e42dc0b2f --- /dev/null +++ b/packages/react-reconciler/src/ReactReconcilerConstants.js @@ -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'; diff --git a/scripts/rollup/bundles.js b/scripts/rollup/bundles.js index 9c6a8c8a95d86..e37e7bbfe644a 100644 --- a/scripts/rollup/bundles.js +++ b/scripts/rollup/bundles.js @@ -604,7 +604,7 @@ const bundles = [ externals: ['react'], }, - /******* Reflection *******/ + /******* Reconciler Reflection *******/ { moduleType: RENDERER_UTILS, bundleTypes: [NODE_DEV, NODE_PROD], @@ -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: [ diff --git a/scripts/rollup/modules.js b/scripts/rollup/modules.js index 80c0a6c2cddbe..1585e307aa7b4 100644 --- a/scripts/rollup/modules.js +++ b/scripts/rollup/modules.js @@ -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,