mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
* Write size info to separate file per bundle `bundle-sizes.json` contains the combined size information for every build. This makes it easier to store and process, but it prevents us from parallelizing the build script, because each process would need to write to the same file. So I've updated the Rollup script to output individual files per build. A downstream CI job consolidates them into a single file. I have not parallelized the Rollup script yet. I'll do that next. * Parallelize the build script Uses CircleCI's `parallelism` config option to spin up multiple build processes.
26 lines
763 B
JavaScript
26 lines
763 B
JavaScript
'use strict';
|
|
|
|
// Script that combines bundle size information for each build into a single
|
|
// JSON file for easier storage and processing.
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const BUILD_DIR = path.join(__dirname, '../../build');
|
|
|
|
const filenames = fs.readdirSync(path.join(BUILD_DIR, 'sizes'));
|
|
|
|
let bundleSizes = [];
|
|
for (let i = 0; i < filenames.length; i++) {
|
|
const filename = filenames[i];
|
|
if (filename.endsWith('.size.json')) {
|
|
const json = fs.readFileSync(path.join(BUILD_DIR, 'sizes', filename));
|
|
bundleSizes.push(JSON.parse(json));
|
|
}
|
|
}
|
|
|
|
const outputFilename = path.join(BUILD_DIR, 'bundle-sizes.json');
|
|
const outputContents = JSON.stringify({bundleSizes}, null, 2);
|
|
|
|
fs.writeFileSync(outputFilename, outputContents);
|