{"id":15489,"library":"unplugin-time-stat","title":"Unplugin Build Time Statistics","description":"unplugin-time-stat is a utility that provides unified build time stat reporting across various JavaScript bundlers, including Vite, Webpack, Rspack, Rollup, and esbuild, by leveraging the `unplugin` ecosystem. It addresses the common challenge of inconsistent build performance reporting mechanisms across different build tools, offering a single interface to monitor and report build durations. The current stable version is `0.3.0`. The project has seen regular, feature-driven releases, indicating active development. A key differentiator is its ability to integrate custom hooks, allowing developers to programmatically capture build metrics and integrate them with external services or custom reporting tools, beyond just console output. This makes it a versatile tool for performance monitoring in diverse build environments.","status":"active","version":"0.3.0","language":"javascript","source_language":"en","source_url":"https://github.com/kazupon/unplugin-time-stat","tags":["javascript","unplugin","vite","webpack","rspack","rollup","esbuild","performance","stats","typescript"],"install":[{"cmd":"npm install unplugin-time-stat","lang":"bash","label":"npm"},{"cmd":"yarn add unplugin-time-stat","lang":"bash","label":"yarn"},{"cmd":"pnpm add unplugin-time-stat","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for Nuxt integration.","package":"@nuxt/kit","optional":true},{"reason":"Peer dependency for Nuxt integration.","package":"@nuxt/schema","optional":true},{"reason":"Peer dependency for esbuild integration.","package":"esbuild","optional":true},{"reason":"Peer dependency for Rollup integration.","package":"rollup","optional":true},{"reason":"Peer dependency for Vite integration.","package":"vite","optional":true},{"reason":"Peer dependency for Webpack, Rspack, and Vue CLI integrations.","package":"webpack","optional":true}],"imports":[{"note":"Use this specific import for Vite projects. ESM syntax is preferred.","wrong":"const TimeStat = require('unplugin-time-stat/vite')","symbol":"TimeStat (Vite)","correct":"import TimeStat from 'unplugin-time-stat/vite'"},{"note":"Webpack and Rspack configurations often use CommonJS `require` for plugins. Also applicable for Vue CLI.","wrong":"import TimeStat from 'unplugin-time-stat/webpack'","symbol":"TimeStat (Webpack)","correct":"const TimeStat = require('unplugin-time-stat/webpack')"},{"note":"Nuxt integration is typically added as a string path in the `modules` array within `defineNuxtConfig`.","wrong":"import TimeStat from 'unplugin-time-stat/nuxt'","symbol":"TimeStat (Nuxt module)","correct":"export default defineNuxtConfig({ modules: [['unplugin-time-stat/nuxt', {}]] })"},{"note":"Imports the TypeScript type definition for custom build hooks, available since v0.3.0.","symbol":"TimeStatHook","correct":"import type { TimeStatHook } from 'unplugin-time-stat'"}],"quickstart":{"code":"import { defineConfig } from 'vite'\nimport TimeStat from 'unplugin-time-stat/vite'\n\nfunction metrics(buildTime, raw) {\n  // raw contains { start: Date, end: Date, buildTime: string }\n  const duration = raw.end.getTime() - raw.start.getTime();\n  console.log(`[Custom Metrics] Build finished in ${duration}ms`);\n  // Example: send data to an external monitoring service\n  // sendToDatadog('build_time', duration);\n  \n  // Optionally return a string to be displayed in the console\n  return `Custom Report: ${duration}ms`;\n}\n\nexport default defineConfig({\n  plugins: [\n    TimeStat({\n      hook: metrics,\n      // Optional: disable default console output if you only want custom handling\n      // outputConsole: false \n    })\n  ]\n})","lang":"typescript","description":"This quickstart demonstrates how to integrate unplugin-time-stat into a Vite project with a custom hook to process build time metrics."},"warnings":[{"fix":"Ensure you are importing `unplugin-time-stat/<your-bundler>` (e.g., `/vite`, `/rollup`, `/esbuild`, `/webpack`, `/nuxt`) as per your project's build tool.","message":"This package acts as an `unplugin` wrapper, requiring you to import the specific bundler integration (e.g., `/vite`, `/webpack`). Importing the wrong path for your bundler will lead to runtime errors or the plugin not functioning.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Install the appropriate peer dependency for your bundler, e.g., `npm install vite` or `npm install webpack`.","message":"Using `unplugin-time-stat` requires the corresponding bundler package (e.g., `vite`, `webpack`, `rollup`, `esbuild`, `@nuxt/kit`) as a peer dependency. If the peer dependency is not installed, the plugin might fail to initialize or cause resolution errors.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Refer to the official GitHub repository's release notes for each new version to understand any API changes or new features.","message":"As a `0.x.x` version package, the API of `unplugin-time-stat` might undergo minor changes in future releases. While recent updates have been additive, always review release notes for potential adjustments.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Verify the package is installed (`npm install unplugin-time-stat`) and that the import path matches your bundler (e.g., `unplugin-time-stat/vite`, `unplugin-time-stat/webpack`).","cause":"The specific bundler integration module could not be found, often due to a typo in the import path or a missing `unplugin-time-stat` package installation.","error":"Cannot find module 'unplugin-time-stat/vite'"},{"fix":"Ensure you are using the correct import syntax for your environment: `import TimeStat from '...'` for ESM, and `const TimeStat = require('...')` for CommonJS, especially for Webpack/Rspack integrations.","cause":"This error occurs when trying to invoke `TimeStat` as a function, but the imported value is not a function. This can happen with incorrect CommonJS `require` usage for an ESM default export, or vice-versa.","error":"TypeError: TimeStat is not a function"}],"ecosystem":"npm"}