strong-tie/inbound-calls
0
1# Bundling2 3Due to its internal architecture based on Worker Threads, it is not possible to bundle Pino *without* generating additional files.4 5In particular, a bundler must ensure that the following files are also bundled separately:6 7* `lib/worker.js` from the `thread-stream` dependency8* `file.js`9* `lib/worker.js`10* Any transport used by the user (like `pino-pretty`)11 12Once the files above have been generated, the bundler must also add information about the files above by injecting a code that sets `__bundlerPathsOverrides` in the `globalThis` object.13 14The variable is an object whose keys are an identifier for the files and the values are the paths of files relative to the currently bundle files.15 16Example:17 18```javascript19// Inject this using your bundle plugin20globalThis.__bundlerPathsOverrides = {21 'thread-stream-worker': pinoWebpackAbsolutePath('./thread-stream-worker.js')22 'pino/file': pinoWebpackAbsolutePath('./pino-file.js'),23 'pino-worker': pinoWebpackAbsolutePath('./pino-worker.js'),24 'pino-pretty': pinoWebpackAbsolutePath('./pino-pretty.js'),25};26```27 28Note that `pino/file`, `pino-worker` and `thread-stream-worker` are required identifiers. Other identifiers are possible based on the user configuration.29 30## Webpack Plugin31 32If you are a Webpack user, you can achieve this with [pino-webpack-plugin](https://github.com/pinojs/pino-webpack-plugin) without manual configuration of `__bundlerPathsOverrides`; however, you still need to configure it manually if you are using other bundlers.33 34## Esbuild Plugin35 36[esbuild-plugin-pino](https://github.com/davipon/esbuild-plugin-pino) is the esbuild plugin to generate extra pino files for bundling.37 38## Bun Plugin39 40[bun-plugin-pino](https://github.com/vktrl/bun-plugin-pino) is the Bun plugin to generate extra pino files for bundling.