{"id":22775,"library":"vite-plugin-performance","title":"vite-plugin-performance","description":"A utility to wrap Vite plugins and measure lifecycle hook execution time, helping identify build performance bottlenecks. Current stable version is 2.0.1, released as part of the weapp-vite monorepo. It supports wrapping single or array of plugins, allows filtering by hook name or threshold, and provides custom logging, formatting, and callback for integration with monitoring systems. Compatible with async hooks. The default hook list covers common Vite plugin hooks like `transform`, `load`, `resolveId`. Differentiators: lightweight, zero-config start, but also flexible for advanced use; includes a built-in default hook list and supports `'all'` to wrap every function hook.","status":"active","version":"2.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/weapp-vite/weapp-vite","tags":["javascript","typescript"],"install":[{"cmd":"npm install vite-plugin-performance","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-performance","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-performance","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package is ESM-only; CJS require will fail. Node >=20.19.0 or >=22.12.0 required.","wrong":"const wrapPlugin = require('vite-plugin-performance')","symbol":"wrapPlugin","correct":"import { wrapPlugin } from 'vite-plugin-performance'"},{"note":"Named export is all-uppercase with underscores.","wrong":"import { defaultPluginHooks } from 'vite-plugin-performance'","symbol":"DEFAULT_PLUGIN_HOOKS","correct":"import { DEFAULT_PLUGIN_HOOKS } from 'vite-plugin-performance'"},{"note":"PluginHookName is a type only; importing it as a value causes runtime error.","wrong":"import { PluginHookName } from 'vite-plugin-performance'","symbol":"PluginHookName","correct":"import type { PluginHookName } from 'vite-plugin-performance'"}],"quickstart":{"code":"import { defineConfig } from 'vite'\nimport Inspect from 'vite-plugin-inspect'\nimport { wrapPlugin } from 'vite-plugin-performance'\n\nexport default defineConfig({\n  plugins: [\n    wrapPlugin(Inspect(), {\n      threshold: 50,\n      onHookExecution({ pluginName, hookName, duration }) {\n        console.log(`[${pluginName}] ${hookName} took ${duration}ms`)\n      },\n    }),\n  ],\n})","lang":"typescript","description":"Wraps vite-plugin-inspect with performance tracking, logging hooks longer than 50ms."},"warnings":[{"fix":"Use ESM imports and set type: module in package.json or use .mjs extension.","message":"vite-plugin-performance is ESM-only starting from v2.0.0. Using require() will throw a Module not found error.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Upgrade Node to ^20.19.0 or >=22.12.0.","message":"Node.js version requirement: ^20.19.0 || >=22.12.0. Older versions (e.g., Node 18) are not supported and may cause runtime errors.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Use `silent` instead of `slient` in options.","message":"The `silent` option was previously misspelled as `slient`. In v2.0.0+, `slient` is still supported but deprecated. If both `silent` and `slient` are provided, `silent` takes precedence.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Replace `slient` with `silent`.","message":"The `slient` option (misspelling) will be removed in a future major version.","severity":"deprecated","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Ensure you pass either a single plugin object or an array of plugin objects. If passing an array, validate all elements are valid plugins.","cause":"wrapPlugin() may be called on a plugin object that does not have the expected hook methods (e.g., array input not flattened correctly).","error":"TypeError: plugin.watchChange is not a function"},{"fix":"Use import syntax instead of require(). Set type: module in package.json or rename file to .mjs.","cause":"Using CommonJS require() to import an ESM-only package.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module ... not supported"},{"fix":"Run pnpm add -D vite-plugin-performance (or npm/yarn) and ensure the import path matches.","cause":"Package not installed or path incorrect.","error":"Module not found: Can't resolve 'vite-plugin-performance'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}