Registry / devops / build-statistics-webpack-plugin

build-statistics-webpack-plugin

JSON →
library1.0.3jsnpmunverified

The `build-statistics-webpack-plugin` is a webpack plugin designed to capture and report detailed timing information for various stages of the webpack build process. It records data such as the build hash and the `startTime`, `endTime`, and `elapse` for distinct phases like `start`, `load`, `assets`, `uglify`, and `emit`. This data is then written to a specified JSON file. Primarily intended for performance monitoring, it supports regular `webpack build`, `webpack watch`, and `webpack-dev-server` scenarios. However, it explicitly notes that it does not write new statistics files during incremental rebuilds in watch mode. The current stable version is 1.0.3, suggesting it is an early-stage project. It differentiates itself by offering a straightforward, file-based output for build metrics, which is highly beneficial for CI/CD pipelines or local optimization efforts. Debugging output can be enabled via the `debug` package by setting the `DEBUG` environment variable.

npm install build-statistics-webpack-plugin
INSTALL
IMPORT
SIG · BUILD-STATISTICS-W
B
build-statistics-webpack-plugin
devopsjavascriptv1.0.3
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.

BuildStatisticsPlugin
const BuildStatisticsPlugin = require('build-statistics-webpack-plugin');
import BuildStatisticsPlugin from 'build-statistics-webpack-plugin';
The package currently uses CommonJS module exports as shown in its documentation. ESM `import` might not work without specific Babel/TypeScript configuration or if the package doesn't provide an `exports` field for ESM.
BuildStatisticsPlugin (ESM)
import BuildStatisticsPlugin from 'build-statistics-webpack-plugin';
import { BuildStatisticsPlugin } from 'build-statistics-webpack-plugin';
If using an ESM-aware environment (e.g., Node.js with 'type': 'module' or a bundler configured for ESM), the plugin is likely exposed as a default export. Named imports like `{ BuildStatisticsPlugin }` are incorrect.

This quickstart demonstrates how to integrate `BuildStatisticsPlugin` into a `webpack.config.js` file to capture build performance metrics and save them to a specified JSON file.

const path = require('path'); const BuildStatisticsPlugin = require('build-statistics-webpack-plugin'); module.exports = { mode: 'development', entry: './src/index.js', // Ensure this entry point exists output: { filename: 'bundle.js', path: path.resolve(__dirname, 'dist'), }, plugins: [ new BuildStatisticsPlugin({ // The 'path' option must be an absolute, writable file path. // It's recommended to use path.resolve() to ensure absoluteness. path: path.resolve(__dirname, 'build-statistics.json'), }), ], };
Debug
Known issues
gotchaThe plugin does not write statistics files when changes are detected in webpack's watch mode or during incremental rebuilds. It only writes on initial full builds or complete recompilations, which can lead to incomplete data if continuous logging for every recompile is expected.
fix
Be aware of this limitation when analyzing build performance in development workflows. For full rebuilds, stop and restart the watch process or trigger a fresh build.
affects: >=1.0.0
gotchaThe 'path' option, which specifies the absolute file path for the statistics output, is mandatory. Omitting it or providing an invalid/relative path can cause the plugin to fail during compilation or write to an unexpected location, potentially without clear error messages.
fix
Always provide an absolute, writable path in the plugin configuration, using Node.js's `path.resolve()` for robustness, e.g., `path: path.resolve(__dirname, 'build-stats.json')`.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: BuildStatisticsPlugin is not a constructor
Attempting to import the plugin using an incorrect syntax, such as a named import when it's a default export, or mixing CommonJS `require` with ES module `import` patterns incorrectly.
fix
For CommonJS, use `const BuildStatisticsPlugin = require('build-statistics-webpack-plugin');`. For ES Modules (if configured), use `import BuildStatisticsPlugin from 'build-statistics-webpack-plugin';`.
Error: ENOENT: no such file or directory, open '/nonexistent/path/build-stats.json'
The specified 'path' option in the plugin configuration points to a directory that does not exist or is not writable by the build process, preventing the plugin from writing the statistics file.
fix
Ensure the directory for the output file exists and is writable before webpack runs. You might need to programmatically create the directory using Node.js's `fs.mkdirSync(path.dirname(filePath), { recursive: true })` within your `webpack.config.js` if it's dynamic.
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies
webpackrequiredThis is a webpack plugin and requires webpack as a peer dependency.
debugrequiredUsed internally for logging trace and error messages.
Agent activity
27 hits · last 30 days
node
22
OpenAI (training)
1
Resources
build-statistics-webpack-plugin — npm install build-statistics-webpack-plugin · libregistry