New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

vite-plugin-performance

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-performance

vite-plugin-performance

latest
Source
npmnpm
Version
2.0.1
Version published
Weekly downloads
370
-9.76%
Maintainers
1
Weekly downloads
 
Created
Source

vite-plugin-performance

中文文档

vite-plugin-performance wraps one or more Vite plugins and measures how long each lifecycle hook takes. It keeps the original behaviour intact while giving you actionable performance insights.

✨ Features

  • Wrap a single plugin or an array of plugins with one call
  • Ship with a sensible default hook list, or use hooks: 'all' to cover every function hook
  • Threshold-based reporting so you only see the hooks that really hurt
  • Pluggable logger, formatter, and lifecycle callback for easy monitoring integration
  • Works with asynchronous hooks and still handles errors gracefully

📦 Installation

pnpm add -D vite-plugin-performance
# or npm / yarn / bun

🚀 Quick Start

import { defineConfig } from 'vite'
import Inspect from 'vite-plugin-inspect'
import { wrapPlugin } from 'vite-plugin-performance'

export default defineConfig({
  plugins: [
    wrapPlugin(Inspect(), {
      threshold: 50,
      onHookExecution({ pluginName, hookName, duration }) {
        reportToAPM({ pluginName, hookName, duration })
      },
    }),
  ],
})

Whenever a hook crosses the threshold (default 0 ms) you will see output similar to:

[inspect] transform            ⏱   78.42 ms

⚙️ Options

OptionTypeDefaultDescription
hooksPluginHookName[] | 'all'DEFAULT_PLUGIN_HOOKSChoose which hooks to wrap; pass 'all' to wrap every function hook
thresholdnumber0Only hooks with a duration greater or equal to the threshold are reported
silentbooleanfalseDisable the built-in logger
logger(message, context) => voidconsole.logCustom log writer
formatter(context) => string[plugin] transform ⏱ 12.34 msCustom message formatter
onHookExecution(context) => voidundefinedCallback invoked after a hook finishes
clock() => numberperformance.now or Date.nowHigh-resolution timer, handy for tests

The legacy misspelled option slient is still recognised and mapped to silent.

Default Hook List

import { DEFAULT_PLUGIN_HOOKS } from 'vite-plugin-performance'
// [
//   'options',
//   'config',
//   'configResolved',
//   'configureServer',
//   'buildStart',
//   'resolveId',
//   'load',
//   'transform',
//   'buildEnd',
//   'generateBundle',
//   'renderChunk',
//   'writeBundle',
// ]

🧠 Advanced Usage

Wrap Multiple Plugins

const pluginA = ...
const pluginB = ...

export default defineConfig({
  plugins: wrapPlugin([pluginA, pluginB], { threshold: 20 }),
})

Custom Log Format

wrapPlugin(plugin, {
  formatter({ pluginName, hookName, duration }) {
    return `${pluginName}:${hookName} took ${duration}ms`
  },
  logger(message) {
    myLogger.info(message)
  },
})

Limit to Specific Hooks

wrapPlugin(plugin, {
  hooks: ['resolveId', 'load', 'transform'],
})

🧪 Testing

pnpm --filter vite-plugin-performance test

📄 License

MIT

FAQs

Package last updated on 04 Feb 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts