Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
esbuild-plugin-pino
Advanced tools
An esbuild plugin to generate extra pino files for bundling
npm install esbuild-plugin-pino
This plugin allows to use of pino v7 with esbuild generated bundle files.
Note that, due to pino architecture (based on Node.js' Worker Threads), it is not possible to make it work without generating extra files.
This means that when using this plugin the following list of files will be generated at the root of your dist folder:
thread-stream.js
pino-worker.js
pino-pipeline-worker.js
pino-file.js
A file for each transport you specify in the plugin constructor's transports
option. (see below)
Each of the additional file is a bundle and therefore does not contain any external dependency, but it is needed to use pino and it must be included in the deployment.
Simply include the plugin in your esbuild build script. Make sure you provide the plugin a list of all the pino transports you use via the transports
option (pino/file
is always included so no need to specify it).
// General usage
const { build } = require('esbuild')
const esbuildPluginPino = require('esbuild-plugin-pino')
build({
entryPoints: ['src/index.ts'],
outdir: 'dist',
plugins: [esbuildPluginPino({ transports: ['pino-pretty'] })],
}).catch(() => process.exit(1))
// Multiple entryPoints & pino transports
const { build } = require('esbuild')
const esbuildPluginPino = require('esbuild-plugin-pino')
build({
entryPoints: {
first: './first.js',
'abc/cde/second': './second.js'
},
outdir: 'dist',
plugins: [esbuildPluginPino({ transports: ['pino-pretty', 'pino-loki'] })],
}).catch(() => process.exit(1))
// Start from esbuild@^0.17.1
// Multiple entryPoints in an array of object & pino transports
const { build } = require('esbuild')
const esbuildPluginPino = require('esbuild-plugin-pino')
build({
entryPoints: [
{
in: './test/fixtures/first.js',
out: 'first'
},
{
in: './test/fixtures/second.js',
out: 'abc/cde/second'
}
],
outdir: 'dist',
plugins: [esbuildPluginPino({ transports: ['pino-pretty', 'pino-loki'] })],
}).catch(() => process.exit(1))
If you use docker
or severless function like AWS Lambda, make sure to use the same outdir
in your production.
Ex: If your outdir
is set to dist
in esbuild
, you need to copy the whole dist
but not extracting files into the docker image root folder.
2.2.0 (2024-06-10)
FAQs
An esbuild plugin to generate extra pino files for bundling
The npm package esbuild-plugin-pino receives a total of 22,457 weekly downloads. As such, esbuild-plugin-pino popularity was classified as popular.
We found that esbuild-plugin-pino demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.