Skip to content
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
12 changes: 11 additions & 1 deletion scripts/rollup/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const sizes = require('./plugins/sizes-plugin');
const Stats = require('./stats');
const syncReactDom = require('./sync').syncReactDom;
const syncReactNative = require('./sync').syncReactNative;
const syncReactNativeRT = require('./sync').syncReactNativeRT;
const Packaging = require('./packaging');
const Header = require('./header');
const closure = require('rollup-plugin-closure-compiler-js');
Expand Down Expand Up @@ -168,7 +169,12 @@ function handleRollupWarnings(warning) {
function updateBundleConfig(config, filename, format, bundleType, hasteName) {
return Object.assign({}, config, {
banner: getBanner(bundleType, hasteName, filename),
dest: Packaging.getPackageDestination(config, bundleType, filename),
dest: Packaging.getPackageDestination(
config,
bundleType,
filename,
hasteName
),
footer: getFooter(bundleType),
format,
interop: false,
Expand Down Expand Up @@ -503,6 +509,7 @@ rimraf('build', () => {
const tasks = [
Packaging.createFacebookWWWBuild,
Packaging.createReactNativeBuild,
Packaging.createReactNativeRTBuild,
];
for (const bundle of Bundles.bundles) {
tasks.push(
Expand All @@ -520,6 +527,9 @@ rimraf('build', () => {
tasks.push(() =>
syncReactNative(join('build', 'react-native'), syncFbsource)
);
tasks.push(() =>
syncReactNativeRT(join('build', 'react-native-rt'), syncFbsource)
);
} else if (syncWww) {
tasks.push(() => syncReactDom(join('build', 'facebook-www'), syncWww));
}
Expand Down
33 changes: 31 additions & 2 deletions scripts/rollup/packaging.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ const reactNativeSrcDependencies = [
'src/renderers/native/ReactNativeTypes.js',
];

// these files need to be copied to the react-native-rt build
const reactNativeRTSrcDependencies = [
'src/renderers/native-rt/ReactNativeRTTypes.js',
];

function getPackageName(name) {
if (name.indexOf('/') !== -1) {
return name.split('/')[0];
Expand Down Expand Up @@ -57,6 +62,25 @@ function createReactNativeBuild() {
});
}

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

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

let promises = [];
// we also need to copy over some specific files from src
// defined in reactNativeRTSrcDependencies
for (const srcDependency of reactNativeRTSrcDependencies) {
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 @@ -143,15 +167,19 @@ function createNodePackage(bundleType, packageName, filename) {
return Promise.resolve();
}

function getPackageDestination(config, bundleType, filename) {
function getPackageDestination(config, bundleType, filename, hasteName) {
let dest = config.destDir + filename;

if (bundleType === FB_DEV || bundleType === FB_PROD) {
dest = `${config.destDir}${facebookWWW}/${filename}`;
} else if (bundleType === UMD_DEV || bundleType === UMD_PROD) {
dest = `${config.destDir}dist/${filename}`;
} else if (bundleType === RN_DEV || bundleType === RN_PROD) {
dest = `${config.destDir}react-native/${filename}`;
if (hasteName === 'ReactNativeRTFiber') {
dest = `${config.destDir}react-native-rt/${filename}`;
} else {
dest = `${config.destDir}react-native/${filename}`;
}
}
return dest;
}
Expand All @@ -162,4 +190,5 @@ module.exports = {
getPackageName,
createFacebookWWWBuild,
createReactNativeBuild,
createReactNativeRTBuild,
};
16 changes: 16 additions & 0 deletions scripts/rollup/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const resolvePath = require('./utils').resolvePath;
const DEFAULT_FB_SOURCE_PATH = '~/fbsource/';
const DEFAULT_WWW_PATH = '~/www/';
const RELATIVE_RN_PATH = 'xplat/js/react-native-github/Libraries/Renderer/';
const RELATIVE_RN_RT_PATH = 'xplat/js/RKJSModules/Libraries/RT/downstream/';
const RELATIVE_WWW_PATH = 'html/shared/react/';

function doSync(buildPath, destPath) {
Expand Down Expand Up @@ -46,7 +47,22 @@ function syncReactNative(buildPath, fbSourcePath) {
return doSync(buildPath, destPath);
}

function syncReactNativeRT(buildPath, fbSourcePath) {
fbSourcePath = typeof fbSourcePath === 'string'
? fbSourcePath
: DEFAULT_FB_SOURCE_PATH;

if (fbSourcePath.charAt(fbSourcePath.length - 1) !== '/') {
fbSourcePath += '/';
}

const destPath = resolvePath(fbSourcePath + RELATIVE_RN_RT_PATH);

return doSync(buildPath, destPath);
}

module.exports = {
syncReactDom,
syncReactNative,
syncReactNativeRT,
};