Speed Measure Webpack Plugin (v5 fork)

raw JSON →
1.5.2 verified Sat Apr 25 auth: no javascript

A Webpack plugin that measures the execution time of loaders and plugins during builds, helping developers identify performance bottlenecks. Current stable version is 1.5.2, compatible with Webpack versions 1 through 5. This is a community fork of stephencookdev/speed-measure-webpack-plugin, specifically updated for Webpack v5. The primary differentiator is its ability to exclude certain plugins from measurement to avoid build failures (e.g., with ReactRefreshPlugin or MiniCssExtractPlugin). It supports multiple output formats (human, JSON, custom) and can write results to a file. Release cadence is low; last update was around 2021.

error Error: Cannot find module 'speed-measure-webpack-v5-plugin'
cause Package not installed or incorrectly spelled.
fix
Run 'npm install --save-dev speed-measure-webpack-v5-plugin'
error TypeError: smp.wrap is not a function
cause Importing incorrectly (e.g., named import instead of default).
fix
Use: const SpeedMeasurePlugin = require('speed-measure-webpack-v5-plugin'); const smp = new SpeedMeasurePlugin();
error Module build failed: TypeError: The 'compilation' argument must be an instance of Compilation
cause SMP is incompatible with webpack v5's new Compilation instance. This may occur when using certain plugins.
fix
Exclude problematic plugins via smp.wrap(config, ['PluginName']). If issue persists, use older webpack version.
gotcha When using certain plugins (e.g., ReactRefreshPlugin, MiniCssExtractPlugin), SMP may cause build failures or break HMR. Must exclude these plugins via the second argument to wrap().
fix smp.wrap(config, ['ReactRefreshPlugin', 'MiniCssExtractPlugin'])
deprecated The original package 'speed-measure-webpack-plugin' is not maintained for webpack v5. Users should migrate to this fork.
fix Replace require('speed-measure-webpack-plugin') with require('speed-measure-webpack-v5-plugin').
gotcha SMP does not support webpack v5's persistent caching; measurements may be inaccurate if persistent caching is enabled.
fix Disable persistent caching when measuring: set cache: false in webpack config.
npm install speed-measure-webpack-v5-plugin
yarn add speed-measure-webpack-v5-plugin
pnpm add speed-measure-webpack-v5-plugin

Demonstrates basic usage: wrap your webpack config with smp.wrap() to measure build times.

const SpeedMeasurePlugin = require('speed-measure-webpack-v5-plugin');
const smp = new SpeedMeasurePlugin();

const webpackConfig = smp.wrap({
  entry: './src/index.js',
  output: {
    path: __dirname + '/dist',
    filename: 'bundle.js'
  },
  plugins: [
    // your plugins
  ],
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: 'babel-loader'
      }
    ]
  }
});

module.exports = webpackConfig;