Registry / devops / pino-webpack-plugin

pino-webpack-plugin

JSON →
library2.0.0jsnpmunverified

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.

npm install pino-webpack-plugin
INSTALL
IMPORT
SIG · PINO-WEBPACK-PLUGI
P
pino-webpack-plugin
devopsjavascriptv2.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PinoWebpackPlugin
import { PinoWebpackPlugin } from 'pino-webpack-plugin'
import PinoWebpackPlugin from 'pino-webpack-plugin'
Default export is not available; must use named import. If using CommonJS, use `const { PinoWebpackPlugin } = require('pino-webpack-plugin')`.
PinoWebpackPlugin (CJS)
const { PinoWebpackPlugin } = require('pino-webpack-plugin')
const PinoWebpackPlugin = require('pino-webpack-plugin')
CommonJS require must destructure the named export. Using the default require will return an object, not the constructor.
PinoWebpackPluginOptions
import type { PinoWebpackPluginOptions } from 'pino-webpack-plugin'
TypeScript type export for the options object. Only useful for type checking; not a runtime import.

Basic webpack configuration that includes pino-webpack-plugin with a pino-pretty transport.

const { PinoWebpackPlugin } = require('pino-webpack-plugin'); const path = require('path'); module.exports = { mode: 'production', entry: './src/index.js', output: { path: path.resolve(__dirname, 'dist'), filename: 'bundle.js' }, plugins: [ new PinoWebpackPlugin({ transports: ['pino-pretty'] }) ] };
Debug
Known issues
gotchaThe 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.
fix
Ensure all generated files are included in deployment. Do not assume only the main bundle file is needed.
affects: >=1.0.0
deprecatedThe `transports` option is required and must include all used pino transports. Missing a transport will cause runtime errors.
fix
Always specify every pino transport used in your code. For example: `transports: ['pino-pretty', 'pino/file']`. Note: `pino/file` is always included automatically.
affects: >=1.0.0
breakingv2.0.0 dropped support for Node <12.13.0 and webpack <5.61.0. Check your environment compatibility.
fix
Upgrade Node to >=12.13.0 and webpack to >=5.61.0.
affects: >=2.0.0
gotchaThe plugin does not support pino v6 or earlier. It is designed for pino v7+ which uses Worker Threads.
fix
Ensure pino version is v7 or higher. Check with `npm list pino`.
affects: >=1.0.0
gotchaDue to pino's architecture, the plugin cannot bundle everything into a single file. The extra worker files are necessary.
fix
Accept the multi-file output. Do not attempt to inline or ignore these files.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'thread-stream'
The worker file thread-stream.js is missing from the output directory or not deployed correctly.
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.
TypeError: PinoWebpackPlugin is not a constructor
Importing the module incorrectly, e.g., using default import instead of named import.
fix
Use `import { PinoWebpackPlugin } from 'pino-webpack-plugin'` (ESM) or `const { PinoWebpackPlugin } = require('pino-webpack-plugin')` (CommonJS).
Error: The plugin requires a list of transports. Please provide via options.transports
The `transports` option is missing in the plugin constructor.
fix
Add `transports` option array to the constructor, e.g., `new PinoWebpackPlugin({ transports: ['pino-pretty'] })`.
Module parse failed: Unexpected token (1:0)
Webpack is trying to parse the extra worker files as entry points. This can happen if they are incorrectly included in the build.
fix
Do not import the generated worker files manually. The plugin handles them automatically.
Error: webpack <5 is not supported
Using an older webpack version (4.x or lower).
fix
Upgrade webpack to version 5.61.0 or higher.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
webpackrequiredPeer dependency: requires webpack ^5.61.0.
Agent activity
13 hits · last 30 days
node
12
OpenAI (training)
1
Resources
pino-webpack-plugin — npm install pino-webpack-plugin · libregistry