Registry / devops / size-plugin

size-plugin

JSON →
library3.0.0jsnpmunverified

A webpack plugin that tracks and displays the gzipped sizes of your assets over time, showing deltas from the previous build. Current stable version is 3.0.0 (2021). Released as needed; maintained by Google Chrome Labs. Key differentiators: simple setup, built-in compression options (gzip, brotli, none), TypeScript types, and automatic file size persistence. Compare to webpack-bundle-analyzer which visualizes composition, or bundlesize which enforces thresholds.

npm install size-plugin
INSTALL
IMPORT
SIG · SIZE-PLUGIN
S
size-plugin
devopsjavascriptv3.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SizePlugin
const SizePlugin = require('size-plugin');
import SizePlugin from 'size-plugin';
CommonJS default export; the package does not ship an ESM build, so named imports or ES import syntax may fail.
SizePlugin
new SizePlugin({ compression: 'gzip' })
new SizePlugin([options])
Options are passed as an object, not an array.
SizePlugin (TypeScript)
import SizePlugin = require('size-plugin'); // or import * as SizePlugin from 'size-plugin'
import { SizePlugin } from 'size-plugin';
TypeScript types are provided but only as a namespace export; named import will not find 'SizePlugin'.

Adds the size-plugin to measure and display gzipped sizes of JS assets in webpack output.

// webpack.config.js const SizePlugin = require('size-plugin'); module.exports = { // your webpack config plugins: [ new SizePlugin({ compression: 'gzip', // default; also 'brotli' or 'none' pattern: '*.js', exclude: '*.map', }) ] };
Debug
Known issues
breakingv3.0.0 drops support for Node.js < 10 and webpack < 4. If you are on older versions, you must upgrade Node.js to >=10 and webpack to >=4.
fix
Update Node.js to 10+ and webpack to 4+.
affects: >=3.0.0
deprecatedThe 'publish' option was deprecated in v3.0.0. Use 'publishSizes' instead.
fix
Rename option to 'publishSizes'.
affects: >=3.0.0
gotchaThe plugin uses a JSON file (default 'size-plugin.json') to persist previous sizes. If you delete this file, all previous size history is lost and deltas will show as 'new'.
fix
Keep the file in your project root or configure a custom filename via 'options.filename'.
affects: *
breakingv2.0.0 introduced a breaking change: the default output format changed and the 'publishSizes' option was added. Existing setups relying on the output format may break.
fix
Review the output and adjust any parsing logic.
affects: >=2.0.0 <3.0.0
gotchaIf you set 'writeFile: false', the file size history is not saved, so each build will show all assets as 'new' (no delta).
fix
Set 'writeFile: true' (default) or provide a custom 'filename'.
affects: *
Errors
Common errors & fixes
Error: Cannot find module 'size-plugin'
SizePlugin is not installed or is in devDependencies but not in node_modules.
fix
Run 'npm install -D size-plugin' or 'yarn add --dev size-plugin'.
TypeError: SizePlugin is not a constructor
Using ES import syntax (import SizePlugin from 'size-plugin') which does not work because the package exports a CommonJS default.
fix
Use 'const SizePlugin = require('size-plugin');'.
TypeError: Cannot read property 'sizes' of undefined
The plugin's beforeRun hook may not run if the webpack config is malformed or the plugin is not instantiated correctly.
fix
Ensure 'new SizePlugin(options)' is added to the plugins array and webpack version is >=4.
Error: size-plugin: 'compression' option must be one of 'gzip', 'brotli', or 'none'
Invalid compression value passed to options.compression.
fix
Set compression to either 'gzip', 'brotli', or 'none'.
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies
webpackrequiredPeer dependency; plugin runs as a webpack plugin
Agent activity
18 hits · last 30 days
node
14
OpenAI (training)
2
Amazon
1
Resources
size-plugin — npm install size-plugin · libregistry