Vite Plugin Inspect

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

A Vite plugin for inspecting the intermediate state of Vite plugins, useful for debugging and authoring plugins. Current stable version is v11.3.3, supporting Vite ^6.0.0 || ^7.0.0-0. v12.0.0-beta.1 is available, requiring Vite v8.0.0+ and @vitejs/devtools. Key differentiators: provides a GUI to view transformed module code, plugin hooks, and module dependency graphs during dev and build. ESM-only since v11.0.0. Ships TypeScript types.

error Error: Cannot find module 'vite-plugin-inspect'
cause Package not installed or CJS/ESM mismatch (v11+ is ESM-only).
fix
Run npm install -D vite-plugin-inspect and ensure your project is ESM (set type: 'module' in package.json).
error TypeError: (0 , vite_plugin_inspect_1.default) is not a function
cause Using named import `{ Inspect }` instead of default import with CJS interop in v10.x.
fix
Use import Inspect from 'vite-plugin-inspect' (ESM) or const Inspect = require('vite-plugin-inspect').default (CJS, v10.x only).
error TypeError: Inspect is not a function
cause Calling `Inspect()` before the default import resolves; often due to circular dependencies or incorrect import path.
fix
Verify import is import Inspect from 'vite-plugin-inspect' and the package is installed correctly.
error Error: Cannot find module '@vitejs/devtools'
cause v12.x requires @vitejs/devtools as a separate dependency.
fix
Run npm install -D @vitejs/devtools and add devtools: true to Vite config.
error Warning: The 'build' option is not enabled. Build transformations will not be captured.
cause Inspect() called without `build: true` when running `vite build`.
fix
Add build: true to the plugin options: Inspect({ build: true }).
breaking v11.0.0 drops CJS support; package is now ESM-only.
fix Ensure your project uses ESM (type: 'module' in package.json or .mjs file extensions). If using CJS, stay on v10.x.
breaking v12.x (beta) migrates to @vitejs/devtools and requires Vite v8.0.0+.
fix Install @vitejs/devtools as a dependency and add 'devtools: true' to Vite config. Upgrade Vite to v8+.
deprecated v11.0.0 deprecated the CJS build; v10.x had incorrect default exports in CJS.
fix If using CJS with v10.3.0, use `const Inspect = require('vite-plugin-inspect').default` to work around the export issue.
gotcha The 'build' option must be explicitly set to true to inspect transformations during build mode.
fix Add `build: true` to the options object: `Inspect({ build: true })`
gotcha For v12.x, the plugin configuration changed: you need to set `devtools: true` or `devtools: { build: { withApp: true } }` in Vite config, not just in the plugin options.
fix Add the `devtools` key to your Vite config object (not the plugin).
deprecated v10.x and earlier used 'vite-plugin-inspect' with CJS; default export was not compatible with CJS require.
fix Upgrade to v10.3.0+ if you need CJS, or migrate to ESM and use v11.x.
npm install vite-plugin-inspect
yarn add vite-plugin-inspect
pnpm add vite-plugin-inspect

Sets up vite-plugin-inspect with devtools enabled for debugging plugin transformations in dev mode.

// vite.config.ts
import { defineConfig } from 'vite'
import Inspect from 'vite-plugin-inspect'

export default defineConfig({
  devtools: true,
  plugins: [
    Inspect()
  ],
})