diff --git a/package.json b/package.json index 84724e4a56..d62a325c60 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,7 @@ "fbjs-scripts": "^0.6.0", "filesize": "^3.5.6", "flow-bin": "^0.41.0", + "git-branch": "^0.3.0", "glob": "^6.0.4", "glob-stream": "^6.1.0", "gzip-js": "~0.3.2", diff --git a/scripts/rollup/build.js b/scripts/rollup/build.js index 7934cfff89..a7e221eebb 100644 --- a/scripts/rollup/build.js +++ b/scripts/rollup/build.js @@ -43,6 +43,7 @@ const { } = require('./bundles'); const { propertyMangleWhitelist } = require('./mangle'); const sizes = require('./sizes-plugin'); +const branch = require('git-branch'); const errorCodeOpts = { errorMapFilePath: 'scripts/error-codes/codes.json', @@ -388,7 +389,9 @@ function createNodePackage(bundleType, packageName, filename) { } function saveResults() { - const contents = {}; + const contents = { + branch: branch.sync(), + }; results.forEach(({ filename, size, gzip }) => { contents[filename] = { @@ -404,7 +407,7 @@ function percentChange(prev, current) { const change = Math.floor((current - prev) / prev * 100); if (change > 0) { - return chalk.red.bold(change + ' %'); + return chalk.red.bold(`+${change} %`); } else if (change <= 0) { return chalk.green.bold(change + ' %'); } @@ -437,7 +440,10 @@ function printResults() { percentChange(prevGzip, gzip), ]); }); - return table.toString(); + return ( + table.toString() + + `\n\nThe difference was compared to the last build on "${ chalk.green.bold(prevResults.branch) }" branch.\n` + ); } function getPlugins(entry, babelOpts, paths, filename, bundleType, isRenderer, manglePropertiesOnProd) { diff --git a/scripts/rollup/results.json b/scripts/rollup/results.json index 5c893af21e..c0e6d25382 100644 --- a/scripts/rollup/results.json +++ b/scripts/rollup/results.json @@ -1 +1 @@ -{"React-prod.js":{"filename":"React-prod.js","gzip":14394,"size":56438},"ReactDOMStack-prod.js":{"filename":"ReactDOMStack-prod.js","gzip":85702,"size":355558},"ReactDOMFiber-prod.js":{"filename":"ReactDOMFiber-prod.js","gzip":94702,"size":412153},"ReactDOMServerStack-prod.js":{"filename":"ReactDOMServerStack-prod.js","gzip":81496,"size":336791},"ReactARTStack-prod.js":{"filename":"ReactARTStack-prod.js","gzip":88945,"size":368987},"ReactARTFiber-prod.js":{"filename":"ReactARTFiber-prod.js","gzip":43477,"size":207824}} \ No newline at end of file +{"branch":"rollup","ReactNative.js":{"filename":"ReactNative.js","gzip":555,"size":1569}} \ No newline at end of file