diff --git a/package.json b/package.json index 570e1878a8..52acba1eda 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/scripts/rollup/build.js b/scripts/rollup/build.js index 3fa92b2230..315039be61 100644 --- a/scripts/rollup/build.js +++ b/scripts/rollup/build.js @@ -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 => { ); } }); +