{"id":14053,"library":"stats-webpack-plugin","title":"Stats Webpack Plugin","description":"The `stats-webpack-plugin` is a Webpack plugin designed to write the build statistics to a file, typically `stats.json`. This enables developers and tools to analyze various aspects of the build, such as module sizes, dependencies, and timing information, by exposing Webpack's internal `stats.toJson` output. The package's current stable version is 0.7.0, last published in 2018, making it effectively abandoned and primarily compatible with older Webpack versions (likely Webpack 1.x, as its peer dependency states `>=1.0.0`). It differentiates itself by offering a straightforward, no-frills method to obtain raw build statistics for custom processing, unlike more feature-rich alternatives that provide integrated analysis and visualization tools. Its lack of recent updates means it does not support modern Webpack features or syntax.","status":"abandoned","version":"0.7.0","language":"javascript","source_language":"en","source_url":"git://github.com/unindented/stats-webpack-plugin","tags":["javascript","stats","webpack"],"install":[{"cmd":"npm install stats-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add stats-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add stats-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Runtime peer dependency for webpack plugin API; requires Webpack >=1.0.0 but is not compatible with modern versions like 4 or 5.","package":"webpack","optional":false}],"imports":[{"note":"This package is CommonJS-only and does not support ES module `import` syntax.","wrong":"import StatsPlugin from 'stats-webpack-plugin';","symbol":"StatsPlugin","correct":"const StatsPlugin = require('stats-webpack-plugin');"},{"note":"The plugin is exported as a default CommonJS module, not as a named export.","wrong":"import { StatsPlugin } from 'stats-webpack-plugin';","symbol":"StatsPlugin","correct":"const StatsPlugin = require('stats-webpack-plugin');"},{"note":"The plugin is instantiated directly in the `plugins` array of the Webpack configuration.","symbol":"Webpack config usage","correct":"plugins: [new StatsPlugin('stats.json', options)]"}],"quickstart":{"code":"const StatsPlugin = require('stats-webpack-plugin');\nconst path = require('path');\n\nmodule.exports = {\n  mode: 'development', // Or 'production'\n  entry: './src/index.js',\n  output: {\n    path: path.resolve(__dirname, 'dist'),\n    filename: 'bundle.js',\n  },\n  plugins: [\n    new StatsPlugin('stats.json', {\n      // Options passed directly to webpack's stats.toJson()\n      // Note: Options like 'chunkModules' might be deprecated or behave\n      // differently in newer webpack versions (if you try to use it).\n      // This plugin is designed for webpack 1.x compatibility.\n      chunkModules: true,\n      exclude: [/node_modules[\\\\\\/]react/]\n    })\n  ]\n};","lang":"javascript","description":"This quickstart demonstrates how to integrate `stats-webpack-plugin` into a basic Webpack configuration to generate a `stats.json` file in the output directory, applying basic filtering."},"warnings":[{"fix":"For modern Webpack versions, use Webpack's native `stats` configuration option (e.g., `stats: 'minimal'` or `stats: { preset: 'minimal', ... }`) directly in `webpack.config.js` or consider more actively maintained plugins like `webpack-bundle-analyzer`.","message":"This plugin is largely incompatible with Webpack versions 4 and 5+. It was designed for Webpack 1.x and has not been updated.","severity":"breaking","affected_versions":">=0.7.0"},{"fix":"Always use `const StatsPlugin = require('stats-webpack-plugin');` to import the plugin.","message":"The package is CommonJS-only and does not support ES Modules (`import ... from '...'`) syntax. Attempting to use `import` will result in runtime errors.","severity":"gotcha","affected_versions":">=0.7.0"},{"fix":"If attempting to use this plugin with a newer Webpack version, consult the Webpack documentation for the `stats` option corresponding to your Webpack version. However, it's strongly recommended to use native Webpack features or alternative tools for modern setups.","message":"Options passed to the `StatsPlugin` constructor (which are forwarded to Webpack's `stats.toJson()` method) may be deprecated or behave unexpectedly in newer Webpack versions due to changes in Webpack's API.","severity":"gotcha","affected_versions":">=0.7.0"}],"env_vars":null,"search_vec":"'0.7.0':58 '1':76 '1.0.0':83 '2018':62 'abandon':66 'altern':108 'analysi':112 'analyz':30 'aspect':32 'build':17,35,98 'compat':69 'current':54 'custom':101 'depend':40,81 'design':13 'develop':26 'differenti':85 'effect':65 'enabl':25 'expos':45 'featur':106,128 'feature-rich':105 'file':21 'frill':93 'inform':43 'integr':111 'intern':48 'javascript':131 'lack':117 'last':59 'like':74 'make':63 'mean':121 'method':94 'modern':126 'modul':38 'no-fril':91 'obtain':96 'offer':88 'older':71 'output':50 'packag':52 'peer':80 'plugin':3,8,12 'primarili':68 'process':102 'provid':110 'publish':60 'raw':97 'recent':119 'rich':107 'size':39 'stabl':55 'stat':1,6,132 'state':82 'statist':18,99 'stats-webpack-plugin':5 'stats.json':23 'stats.tojson':49 'straightforward':90 'support':125 'syntax':130 'time':42 'tool':28,115 'typic':22 'unlik':103 'updat':120 'various':31 'version':56,73 'visual':114 'webpack':2,7,11,46,72,75,127,133 'write':15 'x':77","created_at":"2026-04-20T01:57:41.447816+00:00","updated_at":"2026-04-20T01:57:41.447816+00:00","problems":[{"fix":"Change your import statement to `const StatsPlugin = require('stats-webpack-plugin');`.","cause":"Attempting to use ES module `import StatsPlugin from 'stats-webpack-plugin'` or a named import instead of CommonJS `require()`.","error":"TypeError: StatsPlugin is not a constructor"},{"fix":"Verify that `stats-webpack-plugin` is correctly installed in your `node_modules` directory and that your Node.js environment is compatible with CommonJS modules.","cause":"The `require('stats-webpack-plugin')` call failed or returned an undefined/null value, preventing proper plugin instantiation.","error":"Plugin \"StatsPlugin\" must be an instance of a Plugin"},{"fix":"This plugin is not compatible with Webpack 4 or 5+. Migrate to using Webpack's native `stats` configuration directly in your `webpack.config.js` or use a modern bundle analysis tool.","cause":"This error typically indicates that the internal Webpack `stats` object, which the plugin expects to call `.toJson()` on, is `undefined` or structured differently, likely due to fundamental incompatibility with a newer Webpack version.","error":"TypeError: Cannot read properties of undefined (reading 'toJson')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/unindented/stats-webpack-plugin","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/stats-webpack-plugin","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}