@samitouri / QOS-React / commits / 8b3ad851fd

Update build scripts to put RN-RT files in the right places (#11183)

Brian Vaughn committed Oct 10, 2017 at 13:44 UTC 8b3ad851fdab43e5bc43077f98f1791ca87bfe95
3 files changed +58 -3
scripts/rollup/build.js
+11 -1
@@ -20,6 +20,7 @@ const sizes = require('./plugins/sizes-plugin');
20 const Stats = require('./stats');
21 const syncReactDom = require('./sync').syncReactDom;
22 const syncReactNative = require('./sync').syncReactNative;
23 +const syncReactNativeRT = require('./sync').syncReactNativeRT;
24 const Packaging = require('./packaging');
25 const Header = require('./header');
26 const closure = require('rollup-plugin-closure-compiler-js');
@@ -168,7 +169,12 @@ function handleRollupWarnings(warning) {
169 function updateBundleConfig(config, filename, format, bundleType, hasteName) {
170 return Object.assign({}, config, {
171 banner: getBanner(bundleType, hasteName, filename),
171 - dest: Packaging.getPackageDestination(config, bundleType, filename),
172 + dest: Packaging.getPackageDestination(
173 + config,
174 + bundleType,
175 + filename,
176 + hasteName
177 + ),
178 footer: getFooter(bundleType),
179 format,
180 interop: false,
@@ -503,6 +509,7 @@ rimraf('build', () => {
509 const tasks = [
510 Packaging.createFacebookWWWBuild,
511 Packaging.createReactNativeBuild,
512 + Packaging.createReactNativeRTBuild,
513 ];
514 for (const bundle of Bundles.bundles) {
515 tasks.push(
@@ -520,6 +527,9 @@ rimraf('build', () => {
527 tasks.push(() =>
528 syncReactNative(join('build', 'react-native'), syncFbsource)
529 );
530 + tasks.push(() =>
531 + syncReactNativeRT(join('build', 'react-native-rt'), syncFbsource)
532 + );
533 } else if (syncWww) {
534 tasks.push(() => syncReactDom(join('build', 'facebook-www'), syncWww));
535 }
scripts/rollup/packaging.js
+31 -2
@@ -28,6 +28,11 @@ const reactNativeSrcDependencies = [
28 'src/renderers/native/ReactNativeTypes.js',
29 ];
30
31 +// these files need to be copied to the react-native-rt build
32 +const reactNativeRTSrcDependencies = [
33 + 'src/renderers/native-rt/ReactNativeRTTypes.js',
34 +];
35 +
36 function getPackageName(name) {
37 if (name.indexOf('/') !== -1) {
38 return name.split('/')[0];
@@ -57,6 +62,25 @@ function createReactNativeBuild() {
62 });
63 }
64
65 +function createReactNativeRTBuild() {
66 + // create the react-native-rt folder for FB bundles
67 + fs.mkdirSync(join('build', 'react-native-rt'));
68 + // create the react-native-rt shims folder for FB shims
69 + fs.mkdirSync(join('build', 'react-native-rt', 'shims'));
70 +
71 + const to = join('build', 'react-native-rt', 'shims');
72 +
73 + let promises = [];
74 + // we also need to copy over some specific files from src
75 + // defined in reactNativeRTSrcDependencies
76 + for (const srcDependency of reactNativeRTSrcDependencies) {
77 + promises.push(
78 + asyncCopyTo(resolve(srcDependency), join(to, basename(srcDependency)))
79 + );
80 + }
81 + return Promise.all(promises);
82 +}
83 +
84 function createFacebookWWWBuild() {
85 // create the facebookWWW folder for FB bundles
86 fs.mkdirSync(join('build', facebookWWW));
@@ -143,7 +167,7 @@ function createNodePackage(bundleType, packageName, filename) {
167 return Promise.resolve();
168 }
169
146 -function getPackageDestination(config, bundleType, filename) {
170 +function getPackageDestination(config, bundleType, filename, hasteName) {
171 let dest = config.destDir + filename;
172
173 if (bundleType === FB_DEV || bundleType === FB_PROD) {
@@ -151,7 +175,11 @@ function getPackageDestination(config, bundleType, filename) {
175 } else if (bundleType === UMD_DEV || bundleType === UMD_PROD) {
176 dest = `${config.destDir}dist/${filename}`;
177 } else if (bundleType === RN_DEV || bundleType === RN_PROD) {
154 - dest = `${config.destDir}react-native/${filename}`;
178 + if (hasteName === 'ReactNativeRTFiber') {
179 + dest = `${config.destDir}react-native-rt/${filename}`;
180 + } else {
181 + dest = `${config.destDir}react-native/${filename}`;
182 + }
183 }
184 return dest;
185 }
@@ -162,4 +190,5 @@ module.exports = {
190 getPackageName,
191 createFacebookWWWBuild,
192 createReactNativeBuild,
193 + createReactNativeRTBuild,
194 };
scripts/rollup/sync.js
+16
@@ -7,6 +7,7 @@ const resolvePath = require('./utils').resolvePath;
7 const DEFAULT_FB_SOURCE_PATH = '~/fbsource/';
8 const DEFAULT_WWW_PATH = '~/www/';
9 const RELATIVE_RN_PATH = 'xplat/js/react-native-github/Libraries/Renderer/';
10 +const RELATIVE_RN_RT_PATH = 'xplat/js/RKJSModules/Libraries/RT/downstream/';
11 const RELATIVE_WWW_PATH = 'html/shared/react/';
12
13 function doSync(buildPath, destPath) {
@@ -46,7 +47,22 @@ function syncReactNative(buildPath, fbSourcePath) {
47 return doSync(buildPath, destPath);
48 }
49
50 +function syncReactNativeRT(buildPath, fbSourcePath) {
51 + fbSourcePath = typeof fbSourcePath === 'string'
52 + ? fbSourcePath
53 + : DEFAULT_FB_SOURCE_PATH;
54 +
55 + if (fbSourcePath.charAt(fbSourcePath.length - 1) !== '/') {
56 + fbSourcePath += '/';
57 + }
58 +
59 + const destPath = resolvePath(fbSourcePath + RELATIVE_RN_RT_PATH);
60 +
61 + return doSync(buildPath, destPath);
62 +}
63 +
64 module.exports = {
65 syncReactDom,
66 syncReactNative,
67 + syncReactNativeRT,
68 };