rollup-plugin-pino-bundle

raw JSON →
1.0.2 verified Mon Apr 27 auth: no javascript

A Rollup and Vite plugin that bundles Pino logger and its transports (e.g., pino-pretty, pino-loki) into the application output. Current stable version is 1.0.2. This plugin addresses the unique challenges of bundling Pino's worker threads and file transports, ensuring they function correctly in bundled applications. It integrates seamlessly with both Rollup and Vite, supporting custom directories for pino files and transports. The plugin includes caching for improved build performance and ships with TypeScript type definitions. It is actively maintained on GitHub.

error Error: Cannot find module 'pino-pretty'
cause Transport module not specified in the 'transports' option.
fix
Add 'pino-pretty' to the transports array: { transports: ['pino-pretty'] }
error TypeError: pinoBundle is not a function
cause Using named import instead of default import, or CommonJS require incorrectly.
fix
Use default import: import pinoBundle from 'rollup-plugin-pino-bundle'
gotcha Transports not working in production build if not listed in options
fix Add all required transport module names to the 'transports' array in the plugin configuration.
gotcha Limited Vite dev server support: hot reload may not work correctly
fix For development, consider using Pino's default configuration without the plugin, or test in production builds.
gotcha The plugin modifies the output directory structure, creating a 'pino' folder
fix Ensure your output directory is clean and that you don't have conflicting files with the same names.
npm install rollup-plugin-pino-bundle
yarn add rollup-plugin-pino-bundle
pnpm add rollup-plugin-pino-bundle

Shows how to configure pinoBundle with Vite, including a transport (pino-pretty).

import { defineConfig } from 'vite';
import pinoBundle from 'rollup-plugin-pino-bundle';

export default defineConfig({
  plugins: [
    pinoBundle({
      transports: ['pino-pretty'],
    }),
  ],
});