Rollup/Vite plugin that attaches a detailed import trace chain to build errors, helping developers quickly identify which import path led to a problematic file. Version 1.0.1 is the current stable release. It works with Rollup 3/4 and Vite 5/6/7. Unlike Rollup's built-in `watchFiles` (which lists all watched files), this plugin records only the specific chain of imports causing the error. Ships TypeScript types and supports both ESM and CommonJS environments. Minimal configuration required: just add `importTrace()` first in the plugins array.
npm install rollup-plugin-import-traceVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage of importTrace plugin with Rollup, catching an error and inspecting the importTrace property.
Place `importTrace()` before any other plugins in the Rollup or Vite configuration.
Use `patchErrorWithTrace(error)` before logging the error message for CLI tools or custom error handling.
Check `error.importTrace` existence before using it, or rely on `patchErrorWithTrace()` which handles absence gracefully.
Use `const { importTrace } = require('rollup-plugin-import-trace')` or switch to ESM import.Ensure `importTrace()` is the first plugin in the plugins array.
No dependency data recorded yet.