Skip to content

Commit f828ca4

Browse files
authored
Expose persistent reconciler to custom renderers (#12156)
1 parent 8b83ea0 commit f828ca4

File tree

7 files changed

+90
-0
lines changed

7 files changed

+90
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';
2+
3+
if (process.env.NODE_ENV === 'production') {
4+
module.exports = require('./cjs/react-reconciler-persistent.production.min.js');
5+
} else {
6+
module.exports = require('./cjs/react-reconciler-persistent.development.js');
7+
}

packages/react-reconciler/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"LICENSE",
1313
"README.md",
1414
"index.js",
15+
"persistent.js",
1516
"reflection.js",
1617
"cjs/"
1718
],
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Copyright (c) 2013-present, Facebook, Inc.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
*/
9+
10+
'use strict';
11+
12+
// This is the same export as in index.js,
13+
// with persistent reconciler flags turned on.
14+
const ReactFiberReconciler = require('./src/ReactFiberReconciler');
15+
16+
// TODO: decide on the top-level export form.
17+
// This is hacky but makes it work with both Rollup and Jest.
18+
module.exports = ReactFiberReconciler.default
19+
? ReactFiberReconciler.default
20+
: ReactFiberReconciler;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Copyright (c) 2013-present, Facebook, Inc.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
*/
9+
10+
import invariant from 'fbjs/lib/invariant';
11+
12+
import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags';
13+
import typeof * as PersistentFeatureFlagsType from './ReactFeatureFlags.persistent';
14+
15+
export const debugRenderPhaseSideEffects = false;
16+
export const debugRenderPhaseSideEffectsForStrictMode = false;
17+
export const enableCreateRoot = false;
18+
export const enableUserTimingAPI = __DEV__;
19+
export const warnAboutDeprecatedLifecycles = false;
20+
21+
// react-reconciler/persistent entry point
22+
// uses a persistent reconciler.
23+
export const enableMutatingReconciler = false;
24+
export const enableNoopReconciler = false;
25+
export const enablePersistentReconciler = true;
26+
27+
// Only used in www builds.
28+
export function addUserTimingListener() {
29+
invariant(false, 'Not implemented.');
30+
}
31+
32+
// Flow magic to verify the exports of this file match the original version.
33+
// eslint-disable-next-line no-unused-vars
34+
type Check<_X, Y: _X, X: Y = _X> = null;
35+
// eslint-disable-next-line no-unused-expressions
36+
(null: Check<PersistentFeatureFlagsType, FeatureFlagsType>);

scripts/rollup/bundles.js

+10
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,16 @@ const bundles = [
205205
externals: ['react'],
206206
},
207207

208+
/******* React Persistent Reconciler *******/
209+
{
210+
label: 'react-reconciler-persistent',
211+
bundleTypes: [NODE_DEV, NODE_PROD],
212+
moduleType: RECONCILER,
213+
entry: 'react-reconciler/persistent',
214+
global: 'ReactPersistentReconciler',
215+
externals: ['react'],
216+
},
217+
208218
/******* Reflection *******/
209219
{
210220
label: 'reconciler-reflection',

scripts/rollup/forks.js

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ const forks = Object.freeze({
3636
return 'shared/forks/ReactFeatureFlags.native.js';
3737
case 'react-native-renderer/src/ReactFabric':
3838
return 'shared/forks/ReactFeatureFlags.native-fabric.js';
39+
case 'react-reconciler/persistent':
40+
return 'shared/forks/ReactFeatureFlags.persistent.js';
3941
default:
4042
switch (bundleType) {
4143
case FB_DEV:

scripts/rollup/results.json

+14
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,20 @@
384384
"packageName": "react-native-renderer",
385385
"size": 204787,
386386
"gzip": 35784
387+
},
388+
{
389+
"filename": "react-reconciler-persistent.development.js",
390+
"bundleType": "NODE_DEV",
391+
"packageName": "react-reconciler",
392+
"size": 288790,
393+
"gzip": 60630
394+
},
395+
{
396+
"filename": "react-reconciler-persistent.production.min.js",
397+
"bundleType": "NODE_PROD",
398+
"packageName": "react-reconciler",
399+
"size": 41151,
400+
"gzip": 13111
387401
}
388402
]
389403
}

0 commit comments

Comments
 (0)