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

[CS] Split Host Config Out into a Mutable or Immutable Mode #11213

Merged
merged 8 commits into from
Oct 13, 2017
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
64 changes: 33 additions & 31 deletions fixtures/reconciler/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,28 +115,12 @@ var NoopRenderer = ReactFiberReconciler({
return UPDATE_SIGNAL;
},

commitMount(instance: Instance, type: string, newProps: Props): void {
// Noop
},

commitUpdate(
instance: Instance,
updatePayload: Object,
type: string,
oldProps: Props,
newProps: Props
): void {
instance.prop = newProps.prop;
},

shouldSetTextContent(type: string, props: Props): boolean {
return (
typeof props.children === 'string' || typeof props.children === 'number'
);
},

resetTextContent(instance: Instance): void {},

shouldDeprioritizeSubtree(type: string, props: Props): boolean {
return !!props.hidden;
},
Expand All @@ -155,21 +139,6 @@ var NoopRenderer = ReactFiberReconciler({
return inst;
},

commitTextUpdate(
textInstance: TextInstance,
oldText: string,
newText: string
): void {
textInstance.text = newText;
},

appendChild: appendChild,
appendChildToContainer: appendChild,
insertBefore: insertBefore,
insertInContainerBefore: insertBefore,
removeChild: removeChild,
removeChildFromContainer: removeChild,

scheduleDeferredCallback(callback) {
if (scheduledCallback) {
throw new Error(
Expand All @@ -183,6 +152,39 @@ var NoopRenderer = ReactFiberReconciler({
prepareForCommit(): void {},

resetAfterCommit(): void {},

mutation: {
commitMount(instance: Instance, type: string, newProps: Props): void {
// Noop
},

commitUpdate(
instance: Instance,
updatePayload: Object,
type: string,
oldProps: Props,
newProps: Props
): void {
instance.prop = newProps.prop;
},

commitTextUpdate(
textInstance: TextInstance,
oldText: string,
newText: string
): void {
textInstance.text = newText;
},

appendChild: appendChild,
appendChildToContainer: appendChild,
insertBefore: insertBefore,
insertInContainerBefore: insertBefore,
removeChild: removeChild,
removeChildFromContainer: removeChild,

resetTextContent(instance: Instance): void {},
},
});

var rootContainers = new Map();
Expand Down
5 changes: 5 additions & 0 deletions scripts/rollup/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const Stats = require('./stats');
const syncReactDom = require('./sync').syncReactDom;
const syncReactNative = require('./sync').syncReactNative;
const syncReactNativeRT = require('./sync').syncReactNativeRT;
const syncReactNativeCS = require('./sync').syncReactNativeCS;
const Packaging = require('./packaging');
const Header = require('./header');
const closure = require('rollup-plugin-closure-compiler-js');
Expand Down Expand Up @@ -571,6 +572,7 @@ rimraf('build', () => {
Packaging.createFacebookWWWBuild,
Packaging.createReactNativeBuild,
Packaging.createReactNativeRTBuild,
Packaging.createReactNativeCSBuild,
];
for (const bundle of Bundles.bundles) {
tasks.push(
Expand All @@ -591,6 +593,9 @@ rimraf('build', () => {
tasks.push(() =>
syncReactNativeRT(join('build', 'react-native-rt'), syncFbsource)
);
tasks.push(() =>
syncReactNativeCS(join('build', 'react-native-cs'), syncFbsource)
);
} else if (syncWww) {
tasks.push(() => syncReactDom(join('build', 'facebook-www'), syncWww));
}
Expand Down
28 changes: 27 additions & 1 deletion scripts/rollup/bundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ const bundles = [
useFiber: true,
},

/******* React Native *******/
/******* React Native RT *******/
{
babelOpts: babelOptsReact,
bundleTypes: [RN_DEV, RN_PROD],
Expand Down Expand Up @@ -332,6 +332,32 @@ const bundles = [
useFiber: true,
},

/******* React Native CS *******/
{
babelOpts: babelOptsReact,
bundleTypes: [RN_DEV, RN_PROD],
config: {
destDir: 'build/',
moduleName: 'ReactNativeCSFiber',
sourceMap: false,
},
entry: 'src/renderers/native-cs/ReactNativeCSFiberEntry',
externals: ['prop-types/checkPropTypes'],
hasteName: 'ReactNativeCSFiber',
isRenderer: true,
label: 'native-cs-fiber',
manglePropertiesOnProd: false,
name: 'react-native-cs-renderer',
paths: [
'src/renderers/native-cs/**/*.js',
'src/renderers/shared/**/*.js',

'src/ReactVersion.js',
'src/shared/**/*.js',
],
useFiber: true,
},

/******* React Test Renderer *******/
{
babelOpts: babelOptsReact,
Expand Down
25 changes: 25 additions & 0 deletions scripts/rollup/packaging.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ const reactNativeRTSrcDependencies = [
'src/renderers/native-rt/ReactNativeRTTypes.js',
];

// these files need to be copied to the react-native-cs build
const reactNativeCSSrcDependencies = [
'src/renderers/native-cs/ReactNativeCSTypes.js',
];

function getPackageName(name) {
if (name.indexOf('/') !== -1) {
return name.split('/')[0];
Expand Down Expand Up @@ -81,6 +86,25 @@ function createReactNativeRTBuild() {
return Promise.all(promises);
}

function createReactNativeCSBuild() {
// create the react-native-cs folder for FB bundles
fs.mkdirSync(join('build', 'react-native-cs'));
// create the react-native-cs shims folder for FB shims
fs.mkdirSync(join('build', 'react-native-cs', 'shims'));

const to = join('build', 'react-native-cs', 'shims');

let promises = [];
// we also need to copy over some specific files from src
// defined in reactNativeCSSrcDependencies
for (const srcDependency of reactNativeCSSrcDependencies) {
promises.push(
asyncCopyTo(resolve(srcDependency), join(to, basename(srcDependency)))
);
}
return Promise.all(promises);
}

function createFacebookWWWBuild() {
// create the facebookWWW folder for FB bundles
fs.mkdirSync(join('build', facebookWWW));
Expand Down Expand Up @@ -191,4 +215,5 @@ module.exports = {
createFacebookWWWBuild,
createReactNativeBuild,
createReactNativeRTBuild,
createReactNativeCSBuild,
};
96 changes: 52 additions & 44 deletions scripts/rollup/results.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,28 @@
"gzip": 6703
},
"react-dom.development.js (UMD_DEV)": {
"size": 630418,
"gzip": 145239
"size": 625837,
"gzip": 144320
},
"react-dom.production.min.js (UMD_PROD)": {
"size": 101638,
"gzip": 32128
"size": 100866,
"gzip": 31848
},
"react-dom.development.js (NODE_DEV)": {
"size": 592683,
"gzip": 136496
"size": 588106,
"gzip": 135609
},
"react-dom.production.min.js (NODE_PROD)": {
"size": 106507,
"gzip": 33538
"size": 105343,
"gzip": 33129
},
"ReactDOMFiber-dev.js (FB_DEV)": {
"size": 589582,
"gzip": 135915
"size": 584995,
"gzip": 135013
},
"ReactDOMFiber-prod.js (FB_PROD)": {
"size": 419983,
"gzip": 93676
"size": 414881,
"gzip": 92663
},
"react-dom-test-utils.development.js (NODE_DEV)": {
"size": 41660,
Expand Down Expand Up @@ -113,44 +113,44 @@
"gzip": 6214
},
"react-art.development.js (UMD_DEV)": {
"size": 376896,
"gzip": 83318
"size": 372576,
"gzip": 82452
},
"react-art.production.min.js (UMD_PROD)": {
"size": 83700,
"gzip": 25995
"size": 83057,
"gzip": 25828
},
"react-art.development.js (NODE_DEV)": {
"size": 301201,
"gzip": 64095
"size": 296909,
"gzip": 63228
},
"react-art.production.min.js (NODE_PROD)": {
"size": 53531,
"gzip": 16898
"size": 52508,
"gzip": 16427
},
"ReactARTFiber-dev.js (FB_DEV)": {
"size": 300073,
"gzip": 64131
"size": 295771,
"gzip": 63258
},
"ReactARTFiber-prod.js (FB_PROD)": {
"size": 224585,
"gzip": 46566
"size": 219800,
"gzip": 45628
},
"ReactNativeFiber-dev.js (RN_DEV)": {
"size": 283095,
"gzip": 49176
"size": 279764,
"gzip": 48665
},
"ReactNativeFiber-prod.js (RN_PROD)": {
"size": 221913,
"gzip": 38509
"size": 218506,
"gzip": 37873
},
"react-test-renderer.development.js (NODE_DEV)": {
"size": 304971,
"gzip": 64484
"size": 300619,
"gzip": 63624
},
"ReactTestRendererFiber-dev.js (FB_DEV)": {
"size": 303833,
"gzip": 64527
"size": 299471,
"gzip": 63657
},
"react-test-renderer-shallow.development.js (NODE_DEV)": {
"size": 9215,
Expand All @@ -161,8 +161,8 @@
"gzip": 2221
},
"react-noop-renderer.development.js (NODE_DEV)": {
"size": 292571,
"gzip": 61440
"size": 288214,
"gzip": 60549
},
"react-dom-server.development.js (UMD_DEV)": {
"size": 120897,
Expand All @@ -189,16 +189,16 @@
"gzip": 7520
},
"ReactNativeRTFiber-dev.js (RN_DEV)": {
"size": 215098,
"gzip": 36673
"size": 211687,
"gzip": 36145
},
"ReactNativeRTFiber-prod.js (RN_PROD)": {
"size": 163687,
"gzip": 27527
"size": 160200,
"gzip": 26880
},
"react-test-renderer.production.min.js (NODE_PROD)": {
"size": 55085,
"gzip": 17135
"size": 54076,
"gzip": 16776
},
"react-test-renderer-shallow.production.min.js (NODE_PROD)": {
"size": 4536,
Expand All @@ -209,12 +209,20 @@
"gzip": 4241
},
"react-reconciler.development.js (NODE_DEV)": {
"size": 279927,
"gzip": 58576
"size": 275518,
"gzip": 57698
},
"react-reconciler.production.min.js (NODE_PROD)": {
"size": 38630,
"gzip": 12165
"size": 37979,
"gzip": 11842
},
"ReactNativeCSFiber-dev.js (RN_DEV)": {
"size": 204077,
"gzip": 34318
},
"ReactNativeCSFiber-prod.js (RN_PROD)": {
"size": 155097,
"gzip": 25642
}
}
}
Loading