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

Expose persistent reconciler to custom renderers #12156

Merged
merged 1 commit into from
Feb 5, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/react-reconciler/npm/persistent.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-persistent.production.min.js');
} else {
module.exports = require('./cjs/react-reconciler-persistent.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",
"index.js",
"persistent.js",
"reflection.js",
"cjs/"
],
Expand Down
20 changes: 20 additions & 0 deletions packages/react-reconciler/persistent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* 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';

// This is the same export as in index.js,
// with persistent reconciler flags turned on.
const ReactFiberReconciler = require('./src/ReactFiberReconciler');

// TODO: decide on the top-level export form.
// This is hacky but makes it work with both Rollup and Jest.
module.exports = ReactFiberReconciler.default
? ReactFiberReconciler.default
: ReactFiberReconciler;
36 changes: 36 additions & 0 deletions packages/shared/forks/ReactFeatureFlags.persistent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

import invariant from 'fbjs/lib/invariant';

import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags';
import typeof * as PersistentFeatureFlagsType from './ReactFeatureFlags.persistent';

export const debugRenderPhaseSideEffects = false;
export const debugRenderPhaseSideEffectsForStrictMode = false;
export const enableCreateRoot = false;
export const enableUserTimingAPI = __DEV__;
export const warnAboutDeprecatedLifecycles = false;

// react-reconciler/persistent entry point
// uses a persistent reconciler.
export const enableMutatingReconciler = false;
export const enableNoopReconciler = false;
export const enablePersistentReconciler = true;

// Only used in www builds.
export function addUserTimingListener() {
invariant(false, 'Not implemented.');
}

// Flow magic to verify the exports of this file match the original version.
// eslint-disable-next-line no-unused-vars
type Check<_X, Y: _X, X: Y = _X> = null;
// eslint-disable-next-line no-unused-expressions
(null: Check<PersistentFeatureFlagsType, FeatureFlagsType>);
10 changes: 10 additions & 0 deletions scripts/rollup/bundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,16 @@ const bundles = [
externals: ['react'],
},

/******* React Persistent Reconciler *******/
{
label: 'react-reconciler-persistent',
bundleTypes: [NODE_DEV, NODE_PROD],
moduleType: RECONCILER,
entry: 'react-reconciler/persistent',
global: 'ReactPersistentReconciler',
externals: ['react'],
},

/******* Reflection *******/
{
label: 'reconciler-reflection',
Expand Down
2 changes: 2 additions & 0 deletions scripts/rollup/forks.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ const forks = Object.freeze({
return 'shared/forks/ReactFeatureFlags.native.js';
case 'react-native-renderer/src/ReactFabric':
return 'shared/forks/ReactFeatureFlags.native-fabric.js';
case 'react-reconciler/persistent':
return 'shared/forks/ReactFeatureFlags.persistent.js';
default:
switch (bundleType) {
case FB_DEV:
Expand Down
14 changes: 14 additions & 0 deletions scripts/rollup/results.json
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,20 @@
"packageName": "react-native-renderer",
"size": 204787,
"gzip": 35784
},
{
"filename": "react-reconciler-persistent.development.js",
"bundleType": "NODE_DEV",
"packageName": "react-reconciler",
"size": 288790,
"gzip": 60630
},
{
"filename": "react-reconciler-persistent.production.min.js",
"bundleType": "NODE_PROD",
"packageName": "react-reconciler",
"size": 41151,
"gzip": 13111
}
]
}