mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
further improved and tidied up build process
This commit is contained in:
+2
-1
@@ -74,6 +74,8 @@
|
||||
"minimist": "^1.2.0",
|
||||
"object-assign": "^4.1.1",
|
||||
"platform": "^1.1.0",
|
||||
"prettier": "^0.22.0",
|
||||
"rimraf": "^2.6.1",
|
||||
"rollup": "^0.41.4",
|
||||
"rollup-plugin-alias": "^1.2.1",
|
||||
"rollup-plugin-babel": "^2.7.1",
|
||||
@@ -83,7 +85,6 @@
|
||||
"rollup-plugin-node-resolve": "^2.0.0",
|
||||
"rollup-plugin-replace": "^1.1.1",
|
||||
"rollup-plugin-uglify": "^1.0.1",
|
||||
"prettier": "^0.22.0",
|
||||
"run-sequence": "^1.1.4",
|
||||
"through2": "^2.0.0",
|
||||
"tmp": "~0.0.28",
|
||||
|
||||
+18
-25
@@ -9,7 +9,8 @@ const uglify = require('rollup-plugin-uglify');
|
||||
const replace = require('rollup-plugin-replace');
|
||||
const chalk = require('chalk');
|
||||
const boxen = require('boxen');
|
||||
const { resolve } = require('path');
|
||||
const { resolve, join } = require('path');
|
||||
const rimraf = require('rimraf');
|
||||
const argv = require('minimist')(process.argv.slice(2));
|
||||
const {
|
||||
createModuleMap,
|
||||
@@ -18,6 +19,8 @@ const {
|
||||
replaceInternalModules,
|
||||
getFbjsModuleAliases,
|
||||
replaceFbjsModuleAliases,
|
||||
ignoreFBModules,
|
||||
ignoreReactNativeModules,
|
||||
} = require('./modules');
|
||||
const {
|
||||
bundles,
|
||||
@@ -150,27 +153,13 @@ function getCommonJsConfig(bundleType) {
|
||||
return {};
|
||||
case bundleTypes.RN:
|
||||
return {
|
||||
ignore: [
|
||||
// This imports NativeMethodsMixin, causing
|
||||
// a circular dependency.
|
||||
'View',
|
||||
]
|
||||
ignore: ignoreReactNativeModules(),
|
||||
};
|
||||
case bundleTypes.FB:
|
||||
// Modules we don't want to inline in the bundle.
|
||||
// Force them to stay as require()s in the output.
|
||||
return {
|
||||
ignore: [
|
||||
// Shared mutable state.
|
||||
// We forked an implementation of this into forwarding/.
|
||||
'react/lib/ReactCurrentOwner',
|
||||
'ReactCurrentOwner',
|
||||
// At FB, we don't know them statically:
|
||||
'ReactFeatureFlags',
|
||||
'ReactDOMFeatureFlags',
|
||||
// At FB, we fork this module for custom reporting flow:
|
||||
'ReactErrorUtils',
|
||||
],
|
||||
ignore: ignoreFBModules(),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -245,15 +234,19 @@ function createBundle({
|
||||
)).catch(console.error);
|
||||
}
|
||||
|
||||
bundles.forEach(bundle =>
|
||||
createBundle(bundle, bundleTypes.DEV).then(() =>
|
||||
createBundle(bundle, bundleTypes.PROD).then(() =>
|
||||
createBundle(bundle, bundleTypes.NODE).then(() =>
|
||||
createBundle(bundle, bundleTypes.FB).then(() =>
|
||||
createBundle(bundle, bundleTypes.RN)
|
||||
// clear the build folder
|
||||
rimraf(join('build', 'rollup'), () => {
|
||||
bundles.forEach(bundle =>
|
||||
createBundle(bundle, bundleTypes.DEV).then(() =>
|
||||
createBundle(bundle, bundleTypes.PROD).then(() =>
|
||||
createBundle(bundle, bundleTypes.NODE).then(() =>
|
||||
createBundle(bundle, bundleTypes.FB).then(() =>
|
||||
createBundle(bundle, bundleTypes.RN)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
|
||||
+40
-19
@@ -41,33 +41,44 @@ function getExternalModules(bundleType) {
|
||||
}
|
||||
}
|
||||
|
||||
function ignoreFBModules() {
|
||||
return [
|
||||
// Shared mutable state.
|
||||
// We forked an implementation of this into forwarding/.
|
||||
'react/lib/ReactCurrentOwner',
|
||||
'ReactCurrentOwner',
|
||||
// At FB, we don't know them statically:
|
||||
'ReactFeatureFlags',
|
||||
'ReactDOMFeatureFlags',
|
||||
// At FB, we fork this module for custom reporting flow:
|
||||
'ReactErrorUtils',
|
||||
];
|
||||
}
|
||||
|
||||
function getCommonInternalModules() {
|
||||
// we tell Rollup where these files are located internally, otherwise
|
||||
// it doesn't pick them up and assumes they're external
|
||||
return {
|
||||
reactProdInvariant: resolve('./src/shared/utils/reactProdInvariant.js'),
|
||||
'ReactComponentTreeHook': resolve('./src/isomorphic/hooks/ReactComponentTreeHook.js'),
|
||||
'react/lib/checkPropTypes': resolve('./src/isomorphic/classic/types/checkPropTypes.js'),
|
||||
'react/lib/ReactDebugCurrentFrame': resolve('./src/isomorphic/classic/element/ReactDebugCurrentFrame.js'),
|
||||
'react/lib/ReactComponentTreeHook': resolve('./src/isomorphic/hooks/ReactComponentTreeHook.js'),
|
||||
};
|
||||
}
|
||||
|
||||
function getInternalModules(bundleType) {
|
||||
switch (bundleType) {
|
||||
case bundleTypes.DEV:
|
||||
case bundleTypes.PROD:
|
||||
return {
|
||||
// we tell Rollup where these files are located internally, otherwise
|
||||
// it doesn't pick them up and assumes they're external
|
||||
// for DEV and PROD UMD bundles we also need to bundle ReactCurrentOwner
|
||||
return Object.assign(getCommonInternalModules(), {
|
||||
'ReactCurrentOwner': resolve('./src/isomorphic/classic/element/ReactCurrentOwner.js'),
|
||||
'react/lib/ReactCurrentOwner': resolve('./src/isomorphic/classic/element/ReactCurrentOwner.js'),
|
||||
//
|
||||
reactProdInvariant: resolve('./src/shared/utils/reactProdInvariant.js'),
|
||||
'ReactComponentTreeHook': resolve('./src/isomorphic/hooks/ReactComponentTreeHook.js'),
|
||||
'react/lib/checkPropTypes': resolve('./src/isomorphic/classic/types/checkPropTypes.js'),
|
||||
'react/lib/ReactDebugCurrentFrame': resolve('./src/isomorphic/classic/element/ReactDebugCurrentFrame.js'),
|
||||
'react/lib/ReactComponentTreeHook': resolve('./src/isomorphic/hooks/ReactComponentTreeHook.js'),
|
||||
};
|
||||
});
|
||||
case bundleTypes.NODE:
|
||||
case bundleTypes.FB:
|
||||
return {
|
||||
// we tell Rollup where these files are located internally, otherwise
|
||||
// it doesn't pick them up and assumes they're external
|
||||
reactProdInvariant: resolve('./src/shared/utils/reactProdInvariant.js'),
|
||||
'ReactComponentTreeHook': resolve('./src/isomorphic/hooks/ReactComponentTreeHook.js'),
|
||||
'react/lib/checkPropTypes': resolve('./src/isomorphic/classic/types/checkPropTypes.js'),
|
||||
'react/lib/ReactDebugCurrentFrame': resolve('./src/isomorphic/classic/element/ReactDebugCurrentFrame.js'),
|
||||
'react/lib/ReactComponentTreeHook': resolve('./src/isomorphic/hooks/ReactComponentTreeHook.js'),
|
||||
};
|
||||
return getCommonInternalModules();
|
||||
case bundleTypes.RN:
|
||||
return {};
|
||||
}
|
||||
@@ -123,6 +134,14 @@ function getFbjsModuleAliases(bundleType) {
|
||||
}
|
||||
}
|
||||
|
||||
function ignoreReactNativeModules() {
|
||||
return [
|
||||
// This imports NativeMethodsMixin, causing
|
||||
// a circular dependency.
|
||||
'View',
|
||||
];
|
||||
}
|
||||
|
||||
function replaceFbjsModuleAliases(bundleType) {
|
||||
switch (bundleType) {
|
||||
case bundleTypes.DEV:
|
||||
@@ -163,4 +182,6 @@ module.exports = {
|
||||
getInternalModules,
|
||||
getFbjsModuleAliases,
|
||||
replaceFbjsModuleAliases,
|
||||
ignoreFBModules,
|
||||
ignoreReactNativeModules,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user