diff --git a/package.json b/package.json index 07ebb1cc5411..42fa148eb071 100644 --- a/package.json +++ b/package.json @@ -78,12 +78,12 @@ "random-seed": "^0.3.0", "react-lifecycles-compat": "^3.0.4", "rimraf": "^3.0.0", - "rollup": "^0.52.1", + "rollup": "^1.19.4", "rollup-plugin-babel": "^4.0.1", - "rollup-plugin-commonjs": "^8.2.6", + "rollup-plugin-commonjs": "^9.3.4", "rollup-plugin-node-resolve": "^2.1.1", - "rollup-plugin-prettier": "^0.3.0", - "rollup-plugin-replace": "^2.0.0", + "rollup-plugin-prettier": "^0.6.0", + "rollup-plugin-replace": "^2.2.0", "rollup-plugin-strip-banner": "^0.2.0", "semver": "^7.1.1", "targz": "^1.0.1", diff --git a/scripts/rollup/build.js b/scripts/rollup/build.js index efdc6bef1b35..b1e4ff887e3a 100644 --- a/scripts/rollup/build.js +++ b/scripts/rollup/build.js @@ -410,10 +410,16 @@ function getPlugins( // Note that this plugin must be called after closure applies DCE. isProduction && stripUnusedImports(pureExternalModules), // Add the whitespace back if necessary. - shouldStayReadable && prettier({parser: 'babel'}), + shouldStayReadable && + prettier({ + parser: 'babel', + singleQuote: false, + trailingComma: 'none', + bracketSpacing: true, + }), // License and haste headers, top-level `if` blocks. { - transformBundle(source) { + renderChunk(source) { return Wrappers.wrapBundle( source, bundleType, @@ -541,6 +547,12 @@ async function createBundle(bundle, bundleType) { bundle.moduleType, pureExternalModules ), + output: { + externalLiveBindings: false, + freeze: false, + interop: false, + esModule: false, + }, }; const [mainOutputPath, ...otherOutputPaths] = Packaging.getBundleOutputPaths( bundleType, @@ -616,7 +628,9 @@ function handleRollupWarning(warning) { return; } - if (typeof warning.code === 'string') { + if (warning.code === 'CIRCULAR_DEPENDENCY') { + // Ignored + } else if (typeof warning.code === 'string') { // This is a warning coming from Rollup itself. // These tend to be important (e.g. clashes in namespaced exports) // so we'll fail the build on any of them. diff --git a/scripts/rollup/plugins/closure-plugin.js b/scripts/rollup/plugins/closure-plugin.js index 0c95ee99e22e..258f3b6be785 100644 --- a/scripts/rollup/plugins/closure-plugin.js +++ b/scripts/rollup/plugins/closure-plugin.js @@ -22,7 +22,7 @@ function compile(flags) { module.exports = function closure(flags = {}) { return { name: 'scripts/rollup/plugins/closure-plugin', - async transformBundle(code) { + async renderChunk(code) { const inputFile = tmp.fileSync(); const tempPath = inputFile.name; flags = Object.assign({}, flags, {js: tempPath}); diff --git a/scripts/rollup/plugins/sizes-plugin.js b/scripts/rollup/plugins/sizes-plugin.js index d2b994ef48ba..bab1978144a8 100644 --- a/scripts/rollup/plugins/sizes-plugin.js +++ b/scripts/rollup/plugins/sizes-plugin.js @@ -11,11 +11,15 @@ const gzip = require('gzip-size'); module.exports = function sizes(options) { return { name: 'scripts/rollup/plugins/sizes-plugin', - ongenerate(bundle, obj) { - const size = Buffer.byteLength(obj.code); - const gzipSize = gzip.sync(obj.code); - - options.getSize(size, gzipSize); + generateBundle(outputOptions, bundle, isWrite) { + Object.keys(bundle).forEach(id => { + const chunk = bundle[id]; + if (chunk) { + const size = Buffer.byteLength(chunk.code); + const gzipSize = gzip.sync(chunk.code); + options.getSize(size, gzipSize); + } + }); }, }; }; diff --git a/scripts/rollup/plugins/strip-unused-imports.js b/scripts/rollup/plugins/strip-unused-imports.js index b5da1f292e0b..c0cd811d6462 100644 --- a/scripts/rollup/plugins/strip-unused-imports.js +++ b/scripts/rollup/plugins/strip-unused-imports.js @@ -9,7 +9,7 @@ module.exports = function stripUnusedImports(pureExternalModules) { return { name: 'scripts/rollup/plugins/strip-unused-imports', - transformBundle(code) { + renderChunk(code) { pureExternalModules.forEach(module => { // Ideally this would use a negative lookbehind: (?