rollup-plugin-webpack-stats

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

A Rollup/Vite/Rolldown plugin (v3.1.1, released April 2026) that generates a stats JSON file with a webpack-compatible structure, enabling use of webpack ecosystem tools like bundle-stats and analyze tools with non-webpack builds. It supports Rollup 3/4, Vite 5-8, and Rolldown 1.0 beta, ships TypeScript types, and offers options like custom filename, asset/module filtering, and transform callback. Unlike direct webpack stats generation, it converts Rollup's output format to the webpack stats schema, making it a bridge tool.

error Error [ERR_REQUIRE_ESM]: require() of ES Module
cause Using require() to import the plugin, but it is ESM-only since v3
fix
Change to import syntax: import webpackStatsPlugin from 'rollup-plugin-webpack-stats'
error TypeError: webpackStatsPlugin is not a function
cause Using named import instead of default import
fix
Use default import: import webpackStatsPlugin from 'rollup-plugin-webpack-stats'
error Error: The requested module 'rollup-plugin-webpack-stats' does not provide an export named 'webpackStatsPlugin'
cause Named import attempted, but only default export exists
fix
Use default import: import webpackStatsPlugin from 'rollup-plugin-webpack-stats'
breaking CommonJS require() not supported in v3.0.0+
fix Use ESM import syntax: import webpackStatsPlugin from 'rollup-plugin-webpack-stats'
breaking Node <18 no longer supported in v3.0.0+
fix Upgrade to Node 18 or later
breaking Plugin must be the last plugin in plugins array
fix Place webpackStatsPlugin() at the end of the plugins array
deprecated v2.x line is deprecated; upgrade to v3.x for TypeScript fixes and ESM support
fix npm install rollup-plugin-webpack-stats@latest
gotcha Rolldown 1.0.0-beta.x is a peer dependency, not included automatically
fix Install rolldown separately: npm install rolldown@^1.0.0-beta.0
npm install rollup-plugin-webpack-stats
yarn add rollup-plugin-webpack-stats
pnpm add rollup-plugin-webpack-stats

Shows basic setup for Rollup and Vite config files. Plugin must be the last in the plugins array to capture final bundle stats.

// rollup.config.js
import webpackStatsPlugin from 'rollup-plugin-webpack-stats';

export default {
  input: 'src/index.js',
  output: {
    dir: 'dist',
    format: 'esm'
  },
  plugins: [
    // Must be last plugin
    webpackStatsPlugin()
  ]
};

// vite.config.js
import { defineConfig } from 'vite';
import webpackStatsPlugin from 'rollup-plugin-webpack-stats';

export default defineConfig(() => ({
  plugins: [
    webpackStatsPlugin()
  ]
}));