{"id":20264,"library":"pino-webpack-plugin","title":"pino-webpack-plugin","description":"A Webpack plugin that enables bundling pino v7+ logger with webpack-generated bundles. Version 2.0.0 supports webpack 5 and requires Node >=12.13.0. It works by extracting pino's worker threads (thread-stream, pino-worker, pino-pipeline-worker, pino-file) into separate bundle files, which must be deployed alongside the main bundle. The plugin allows specifying extra transports like pino-pretty. Key differentiator: it's the official way to use pino in webpack projects, addressing the incompatibility between pino's Node.js Worker Threads architecture and webpack's bundling. Ships TypeScript types.","status":"active","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/pinojs/pino-webpack-plugin","tags":["javascript","typescript"],"install":[{"cmd":"npm install pino-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add pino-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add pino-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: requires webpack ^5.61.0.","package":"webpack","optional":false}],"imports":[{"note":"Default export is not available; must use named import. If using CommonJS, use `const { PinoWebpackPlugin } = require('pino-webpack-plugin')`.","wrong":"import PinoWebpackPlugin from 'pino-webpack-plugin'","symbol":"PinoWebpackPlugin","correct":"import { PinoWebpackPlugin } from 'pino-webpack-plugin'"},{"note":"CommonJS require must destructure the named export. Using the default require will return an object, not the constructor.","wrong":"const PinoWebpackPlugin = require('pino-webpack-plugin')","symbol":"PinoWebpackPlugin (CJS)","correct":"const { PinoWebpackPlugin } = require('pino-webpack-plugin')"},{"note":"TypeScript type export for the options object. Only useful for type checking; not a runtime import.","wrong":"","symbol":"PinoWebpackPluginOptions","correct":"import type { PinoWebpackPluginOptions } from 'pino-webpack-plugin'"}],"quickstart":{"code":"const { PinoWebpackPlugin } = require('pino-webpack-plugin');\nconst path = require('path');\n\nmodule.exports = {\n  mode: 'production',\n  entry: './src/index.js',\n  output: {\n    path: path.resolve(__dirname, 'dist'),\n    filename: 'bundle.js'\n  },\n  plugins: [\n    new PinoWebpackPlugin({\n      transports: ['pino-pretty']\n    })\n  ]\n};","lang":"javascript","description":"Basic webpack configuration that includes pino-webpack-plugin with a pino-pretty transport."},"warnings":[{"fix":"Ensure all generated files are included in deployment. Do not assume only the main bundle file is needed.","message":"The plugin generates extra bundle files (thread-stream.js, pino-worker.js, pino-pipeline-worker.js, pino-file.js, and any custom transports). These must be deployed alongside the main webpack bundle.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always specify every pino transport used in your code. For example: `transports: ['pino-pretty', 'pino/file']`. Note: `pino/file` is always included automatically.","message":"The `transports` option is required and must include all used pino transports. Missing a transport will cause runtime errors.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Upgrade Node to >=12.13.0 and webpack to >=5.61.0.","message":"v2.0.0 dropped support for Node <12.13.0 and webpack <5.61.0. Check your environment compatibility.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Ensure pino version is v7 or higher. Check with `npm list pino`.","message":"The plugin does not support pino v6 or earlier. It is designed for pino v7+ which uses Worker Threads.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Accept the multi-file output. Do not attempt to inline or ignore these files.","message":"Due to pino's architecture, the plugin cannot bundle everything into a single file. The extra worker files are necessary.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Ensure that the webpack output directory contains all generated files: thread-stream.js, pino-worker.js, pino-pipeline-worker.js, pino-file.js. Include them in deployment.","cause":"The worker file thread-stream.js is missing from the output directory or not deployed correctly.","error":"Error: Cannot find module 'thread-stream'"},{"fix":"Use `import { PinoWebpackPlugin } from 'pino-webpack-plugin'` (ESM) or `const { PinoWebpackPlugin } = require('pino-webpack-plugin')` (CommonJS).","cause":"Importing the module incorrectly, e.g., using default import instead of named import.","error":"TypeError: PinoWebpackPlugin is not a constructor"},{"fix":"Add `transports` option array to the constructor, e.g., `new PinoWebpackPlugin({ transports: ['pino-pretty'] })`.","cause":"The `transports` option is missing in the plugin constructor.","error":"Error: The plugin requires a list of transports. Please provide via options.transports"},{"fix":"Do not import the generated worker files manually. The plugin handles them automatically.","cause":"Webpack is trying to parse the extra worker files as entry points. This can happen if they are incorrectly included in the build.","error":"Module parse failed: Unexpected token (1:0)"},{"fix":"Upgrade webpack to version 5.61.0 or higher.","cause":"Using an older webpack version (4.x or lower).","error":"Error: webpack <5 is not supported"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}