main
js 25 lines 677 Bytes
Raw
1 /**
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7 'use strict';
8
9 const gzip = require('gzip-size');
10
11 module.exports = function sizes(options) {
12 return {
13 name: 'scripts/rollup/plugins/sizes-plugin',
14 generateBundle(outputOptions, bundle, isWrite) {
15 Object.keys(bundle).forEach(id => {
16 const chunk = bundle[id];
17 if (chunk) {
18 const size = Buffer.byteLength(chunk.code);
19 const gzipSize = gzip.sync(chunk.code);
20 options.getSize(size, gzipSize);
21 }
22 });
23 },
24 };
25 };