Registry / devops / stats-webpack-plugin

stats-webpack-plugin

JSON →
library0.7.0jsnpmunverified

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.

npm install stats-webpack-plugin
INSTALL
IMPORT
SIG · STATS-WEBPACK-PLUG
S
stats-webpack-plugin
devopsjavascriptv0.7.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.

StatsPlugin
const StatsPlugin = require('stats-webpack-plugin');
import StatsPlugin from 'stats-webpack-plugin';
This package is CommonJS-only and does not support ES module `import` syntax.
StatsPlugin
const StatsPlugin = require('stats-webpack-plugin');
import { StatsPlugin } from 'stats-webpack-plugin';
The plugin is exported as a default CommonJS module, not as a named export.
Webpack config usage
plugins: [new StatsPlugin('stats.json', options)]
The plugin is instantiated directly in the `plugins` array of the Webpack configuration.

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.

const StatsPlugin = require('stats-webpack-plugin'); const path = require('path'); module.exports = { mode: 'development', // Or 'production' entry: './src/index.js', output: { path: path.resolve(__dirname, 'dist'), filename: 'bundle.js', }, plugins: [ new StatsPlugin('stats.json', { // Options passed directly to webpack's stats.toJson() // Note: Options like 'chunkModules' might be deprecated or behave // differently in newer webpack versions (if you try to use it). // This plugin is designed for webpack 1.x compatibility. chunkModules: true, exclude: [/node_modules[\\\/]react/] }) ] };
Debug
Known issues
breakingThis plugin is largely incompatible with Webpack versions 4 and 5+. It was designed for Webpack 1.x and has not been updated.
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`.
affects: >=0.7.0
gotchaThe package is CommonJS-only and does not support ES Modules (`import ... from '...'`) syntax. Attempting to use `import` will result in runtime errors.
fix
Always use `const StatsPlugin = require('stats-webpack-plugin');` to import the plugin.
affects: >=0.7.0
gotchaOptions 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.
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.
affects: >=0.7.0
Errors
Common errors & fixes
TypeError: StatsPlugin is not a constructor
Attempting to use ES module `import StatsPlugin from 'stats-webpack-plugin'` or a named import instead of CommonJS `require()`.
fix
Change your import statement to `const StatsPlugin = require('stats-webpack-plugin');`.
Plugin "StatsPlugin" must be an instance of a Plugin
The `require('stats-webpack-plugin')` call failed or returned an undefined/null value, preventing proper plugin instantiation.
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.
TypeError: Cannot read properties of undefined (reading 'toJson')
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.
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.
Upgrade
Version history
0.7.0latest on npm
Audit
Dependencies
webpackrequiredRuntime peer dependency for webpack plugin API; requires Webpack >=1.0.0 but is not compatible with modern versions like 4 or 5.
Agent activity
5 hits · last 30 days
node
4
Resources
stats-webpack-plugin — npm install stats-webpack-plugin · libregistry