Speed Measure Vite Plugin
raw JSON → 2.0.1 verified Mon Apr 27 auth: no javascript
A Vite plugin that measures the transform speed of other Vite plugins, currently at version 2.0.1. It wraps plugins and records execution time for hooks like transform, resolveId, and load. Compatible with Vite >= 3.0.0. Differentiators: simple API, supports both build and dev mode (with gap detection), and allows custom hook selection and sort order. Ships TypeScript types. Low bundle size.
Common errors
error ERR_REQUIRE_ESM: require() of ES Module speed-measure-vite-plugin not supported ↓
cause Package is ESM-only, cannot be used with require() in CommonJS context.
fix
Use import() syntax or ensure your project is configured for ESM.
error TypeError: smvp is not a function ↓
cause Using named import { smvp } instead of default import.
fix
Change to import smvp from 'speed-measure-vite-plugin'.
error Invalid plugin order: smvp should wrap all plugins ↓
cause Passing smvp as a plugin itself, not wrapping others.
fix
Wrap your plugins array with smvp: smvp([vue(), ...])
Warnings
deprecated Option 'maxTransformTimeOnce' is deprecated. Use 'maxGapTimeOnce' instead. ↓
fix Replace maxTransformTimeOnce with maxGapTimeOnce in the options object.
gotcha The plugin wraps your plugins; ensure you pass them as an array to smvp, not as separate arguments. ↓
fix Use smvp([plugin1, plugin2]) instead of smvp(plugin1, plugin2).
breaking Default export changed from named export to default export in v2.0.0. ↓
fix Use import smvp from 'speed-measure-vite-plugin' instead of import { smvp } from 'speed-measure-vite-plugin'.
Install
npm install speed-measure-vite-plugin yarn add speed-measure-vite-plugin pnpm add speed-measure-vite-plugin Imports
- smvp wrong
const smvp = require('speed-measure-vite-plugin')correctimport smvp from 'speed-measure-vite-plugin' - SpeedMeasurePlugin wrong
import { SpeedMeasurePlugin } from 'speed-measure-vite-plugin'correctimport smvp from 'speed-measure-vite-plugin' - Options
import type { Options } from 'speed-measure-vite-plugin'
Quickstart
// vite.config.js
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import smvp from 'speed-measure-vite-plugin'
export default defineConfig({
plugins: smvp([vue()], {
hooks: ['transform', 'resolveId', 'load'],
sort: (a, b) => b - a,
maxGapTimeOnce: 1000
})
})