From 251193d4fcaa6cd28aeb4566129705ef9c8dcb5e Mon Sep 17 00:00:00 2001 From: Dan Date: Sun, 24 Dec 2017 01:44:08 +0000 Subject: [PATCH] Fix writing stats to the file --- scripts/rollup/build.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/rollup/build.js b/scripts/rollup/build.js index 7cb84e0714..1b3c0d34bb 100644 --- a/scripts/rollup/build.js +++ b/scripts/rollup/build.js @@ -264,13 +264,19 @@ function getPlugins( // Record bundle size. sizes({ getSize: (size, gzip) => { - Stats.currentBuildResults.bundleSizes.push({ + const currentSizes = Stats.currentBuildResults.bundleSizes; + const recordIndex = currentSizes.findIndex( + record => + record.filename === filename && record.bundleType === bundleType + ); + const index = recordIndex !== -1 ? recordIndex : currentSizes.length; + currentSizes[index] = { filename, bundleType, packageName, size, gzip, - }); + }; }, }), ].filter(Boolean);