{"id":20554,"library":"size-plugin","title":"size-plugin","description":"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.","status":"active","version":"3.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/googlechromelabs/size-plugin","tags":["javascript","webpack plugin","file size","gzip size","bundle size","typescript"],"install":[{"cmd":"npm install size-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add size-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add size-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; plugin runs as a webpack plugin","package":"webpack","optional":false}],"imports":[{"note":"CommonJS default export; the package does not ship an ESM build, so named imports or ES import syntax may fail.","wrong":"import SizePlugin from 'size-plugin';","symbol":"SizePlugin","correct":"const SizePlugin = require('size-plugin');"},{"note":"Options are passed as an object, not an array.","wrong":"new SizePlugin([options])","symbol":"SizePlugin","correct":"new SizePlugin({ compression: 'gzip' })"},{"note":"TypeScript types are provided but only as a namespace export; named import will not find 'SizePlugin'.","wrong":"import { SizePlugin } from 'size-plugin';","symbol":"SizePlugin (TypeScript)","correct":"import SizePlugin = require('size-plugin'); // or import * as SizePlugin from 'size-plugin'"}],"quickstart":{"code":"// webpack.config.js\nconst SizePlugin = require('size-plugin');\n\nmodule.exports = {\n  // your webpack config\n  plugins: [\n    new SizePlugin({\n      compression: 'gzip', // default; also 'brotli' or 'none'\n      pattern: '*.js',\n      exclude: '*.map',\n    })\n  ]\n};","lang":"javascript","description":"Adds the size-plugin to measure and display gzipped sizes of JS assets in webpack output."},"warnings":[{"fix":"Update Node.js to 10+ and webpack to 4+.","message":"v3.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.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Rename option to 'publishSizes'.","message":"The 'publish' option was deprecated in v3.0.0. Use 'publishSizes' instead.","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"Keep the file in your project root or configure a custom filename via 'options.filename'.","message":"The 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'.","severity":"gotcha","affected_versions":"*"},{"fix":"Review the output and adjust any parsing logic.","message":"v2.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.","severity":"breaking","affected_versions":">=2.0.0 <3.0.0"},{"fix":"Set 'writeFile: true' (default) or provide a custom 'filename'.","message":"If you set 'writeFile: false', the file size history is not saved, so each build will show all assets as 'new' (no delta).","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run 'npm install -D size-plugin' or 'yarn add --dev size-plugin'.","cause":"SizePlugin is not installed or is in devDependencies but not in node_modules.","error":"Error: Cannot find module 'size-plugin'"},{"fix":"Use 'const SizePlugin = require('size-plugin');'.","cause":"Using ES import syntax (import SizePlugin from 'size-plugin') which does not work because the package exports a CommonJS default.","error":"TypeError: SizePlugin is not a constructor"},{"fix":"Ensure 'new SizePlugin(options)' is added to the plugins array and webpack version is >=4.","cause":"The plugin's beforeRun hook may not run if the webpack config is malformed or the plugin is not instantiated correctly.","error":"TypeError: Cannot read property 'sizes' of undefined"},{"fix":"Set compression to either 'gzip', 'brotli', or 'none'.","cause":"Invalid compression value passed to options.compression.","error":"Error: size-plugin: 'compression' option must be one of 'gzip', 'brotli', or 'none'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}