mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
improved the build tool
This commit is contained in:
@@ -70,6 +70,7 @@
|
||||
"jest-runtime": "^19.0.1",
|
||||
"loose-envify": "^1.1.0",
|
||||
"merge-stream": "^1.0.0",
|
||||
"minimist": "^1.2.0",
|
||||
"object-assign": "^4.1.1",
|
||||
"platform": "^1.1.0",
|
||||
"rollup": "^0.41.4",
|
||||
|
||||
+15
-3
@@ -11,6 +11,7 @@ const chalk = require('chalk');
|
||||
const boxen = require('boxen');
|
||||
const { resolve } = require('path');
|
||||
const fixHasteImports = require('./fixHasteImports');
|
||||
const argv = require('minimist')(process.argv.slice(2));
|
||||
const {
|
||||
createModuleMap,
|
||||
getExternalModules,
|
||||
@@ -76,6 +77,13 @@ function updateBabelConfig(babelOpts, bundleType) {
|
||||
}
|
||||
}
|
||||
|
||||
function handleRollupWarnings(warning) {
|
||||
if (warning.code === 'UNRESOLVED_IMPORT') {
|
||||
return;
|
||||
}
|
||||
console.warn(warning.message || warning);
|
||||
}
|
||||
|
||||
function updateBundleConfig(config, filename, format, bundleType, hastName) {
|
||||
return Object.assign({}, config, {
|
||||
banner: getBanner(bundleType, hastName),
|
||||
@@ -200,16 +208,19 @@ function getPlugins(entry, babelOpts, paths, filename, bundleType) {
|
||||
return plugins;
|
||||
}
|
||||
|
||||
const inputBundleType = argv.type;
|
||||
|
||||
function createBundle({babelOpts, entry, fbEntry, config, paths, name, hasteName}, bundleType) {
|
||||
if (inputBundleType && inputBundleType !== bundleType) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
const filename = getFilename(name, hasteName, bundleType);
|
||||
const format = getFormat(bundleType);
|
||||
|
||||
return rollup({
|
||||
entry: bundleType === bundleTypes.FB ? fbEntry : entry,
|
||||
plugins: getPlugins(entry, babelOpts, paths, filename, bundleType),
|
||||
external: [
|
||||
'react',
|
||||
],
|
||||
onwarn: handleRollupWarnings,
|
||||
}).then(({write}) => write(
|
||||
updateBundleConfig(config, filename, format, bundleType, hasteName)
|
||||
)).catch(console.error);
|
||||
@@ -230,3 +241,4 @@ bundles.forEach(bundle => {
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user