bun-plugin-print-imports
raw JSON → 2.0.0 verified Fri May 01 auth: no javascript
Bun and esbuild plugin that prints resolved import paths during bundling. Current version 2.0.0, released occasionally. Useful for debugging dependency resolution or auditing bundle contents. Differs from other logging plugins by supporting both Bun and esbuild with same API. Minimal configuration: just register and log. Works with both ESM and CJS outputs.
Common errors
error Cannot find module 'bun-plugin-print-imports' ↓
cause Package not installed or using wrong import path.
fix
Run
bun add bun-plugin-print-imports or npm install bun-plugin-print-imports. error Plugin must be a function or object ↓
cause Using import incorrectly (e.g., using default import when expecting named).
fix
Use
import { plugin } from 'bun-plugin-print-imports' or import defaultPlugin from 'bun-plugin-print-imports'. error TypeError: plugin is not a function ↓
cause Using plugin() without instantiation or incorrect import.
fix
Ensure you call plugin() and pass options if needed; check import syntax.
error Uncaught Error: Cannot find module '.' ↓
cause Bundler cannot resolve the plugin; often due to missing peer dependencies or misconfigured paths.
fix
Install esbuild if using esbuild, ensure Bun is up to date.
Warnings
breaking Version 2.x requires ESM; CJS require no longer works without bundler. ↓
fix Switch to ESM import syntax; if using CJS, stick with 1.x or use a bundler that can handle ESM.
gotcha Plugin logs to stdout; may interfere with tools that parse stdout. ↓
fix Use plugin({ quiet: true }) to suppress logs, or redirect stdout.
deprecated The 'filter' option was removed in 2.0.0; use 'include' and 'exclude' instead. ↓
fix Replace filter with include/exclude arrays of glob patterns.
gotcha Only prints imports that Bun resolves; dynamic imports with variables may not appear. ↓
fix Ensure dynamic imports use string literals for Bun to resolve.
breaking Plugin no longer supports Node <18 or Bun <1.0.0. ↓
fix Update to Node 18+ or Bun 1.0+.
Install
npm install bun-plugin-print-imports yarn add bun-plugin-print-imports pnpm add bun-plugin-print-imports Imports
- plugin wrong
const plugin = require('bun-plugin-print-imports')correctimport { plugin } from 'bun-plugin-print-imports' - defaultPlugin wrong
import { defaultPlugin } from 'bun-plugin-print-imports'correctimport defaultPlugin from 'bun-plugin-print-imports' - type Options wrong
import { Options } from 'bun-plugin-print-imports'correctimport type { Options } from 'bun-plugin-print-imports' - plugin (CommonJS)
const { plugin } = require('bun-plugin-print-imports')
Quickstart
import { plugin } from 'bun-plugin-print-imports';
await Bun.build({
entrypoints: ['./src/index.ts'],
outdir: './dist',
plugins: [plugin()],
});
// Or with esbuild:
// import * as esbuild from 'esbuild';
// await esbuild.build({
// entryPoints: ['./src/index.ts'],
// outdir: './dist',
// plugins: [plugin()],
// });