Repository: pinojs/pino
Pull request #1988 (2024-06-10 15:36:24)

build(deps-dev): bump @yao-pkg/pkg from 5.11.5 to 5.12.0
Bumps [@yao-pkg/pkg](https://github.com/yao-pkg/pkg) from 5.11.5 to 5.12.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/yao-pkg/pkg/releases"><code>@​yao-pkg/pkg</code>'s releases</a>.</em></p>
<blockquote>
<h2>Release 5.12.0</h2>
<h2><a href="https://github.com/yao-pkg/pkg/compare/v5.11.5...v5.12.0">5.12.0</a> (2024-06-10)</h2>
<h3>Features</h3>
<ul>
<li>add <code>ignore</code> option to ignore files from build (<a href="https://redirect.github.com/yao-pkg/pkg/issues/68">#68</a>) (<a href="https://github.com/yao-pkg/pkg/commit/54ae1eea4a7f227d7a7246c5c3d43cf4b025c921">54ae1ee</a>)</li>
</ul>
<h3>Bug Fixes</h3>
<ul>
<li>use cache directory in users home instead of system-wide tmp dir (<a href="https://redirect.github.com/yao-pkg/pkg/issues/55">#55</a>) (<a href="https://github.com/yao-pkg/pkg/commit/a217727d71ba2490c0988077011595fe54d26711">a217727</a>)</li>
</ul>
<h3>Chores</h3>
<ul>
<li>fix build (<a href="https://github.com/yao-pkg/pkg/commit/276651aaa38451c4ba67ea2e46c9bdea6547ee2d">276651a</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/yao-pkg/pkg/blob/main/CHANGELOG.md"><code>@​yao-pkg/pkg</code>'s changelog</a>.</em></p>
<blockquote>
<h2><a href="https://github.com/yao-pkg/pkg/compare/v5.11.5...v5.12.0">5.12.0</a> (2024-06-10)</h2>
<h3>Features</h3>
<ul>
<li>add <code>ignore</code> option to ignore files from build (<a href="https://redirect.github.com/yao-pkg/pkg/issues/68">#68</a>) (<a href="https://github.com/yao-pkg/pkg/commit/54ae1eea4a7f227d7a7246c5c3d43cf4b025c921">54ae1ee</a>)</li>
</ul>
<h3>Bug Fixes</h3>
<ul>
<li>use cache directory in users home instead of system-wide tmp dir (<a href="https://redirect.github.com/yao-pkg/pkg/issues/55">#55</a>) (<a href="https://github.com/yao-pkg/pkg/commit/a217727d71ba2490c0988077011595fe54d26711">a217727</a>)</li>
</ul>
<h3>Chores</h3>
<ul>
<li>fix build (<a href="https://github.com/yao-pkg/pkg/commit/276651aaa38451c4ba67ea2e46c9bdea6547ee2d">276651a</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/yao-pkg/pkg/commit/66f676cedfba4b5fd49f15d07d3c996fcfbedd5a"><code>66f676c</code></a> Release 5.12.0</li>
<li><a href="https://github.com/yao-pkg/pkg/commit/276651aaa38451c4ba67ea2e46c9bdea6547ee2d"><code>276651a</code></a> chore: fix build</li>
<li><a href="https://github.com/yao-pkg/pkg/commit/54ae1eea4a7f227d7a7246c5c3d43cf4b025c921"><code>54ae1ee</code></a> feat: add <code>ignore</code> option to ignore files from build (<a href="https://redirect.github.com/yao-pkg/pkg/issues/68">#68</a>)</li>
<li><a href="https://github.com/yao-pkg/pkg/commit/a217727d71ba2490c0988077011595fe54d26711"><code>a217727</code></a> fix: use cache directory in users home instead of system-wide tmp dir (<a href="https://redirect.github.com/yao-pkg/pkg/issues/55">#55</a>)</li>
<li>See full diff in <a href="https://github.com/yao-pkg/pkg/compare/v5.11.5...v5.12.0">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=@yao-pkg/pkg&package-manager=npm_and_yarn&previous-version=5.11.5&new-version=5.12.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

You can trigger a rebase of this PR by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>

> **Note**
> Automatic rebases have been disabled on this pull request as it has been open for over 30 days.



Patch:
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 274931b..37d989c 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -43,9 +43,9 @@ jobs:
       matrix:
         os: [macOS-latest, windows-latest, ubuntu-latest]
         node-version: [18, 20, 22]
-      exclude:
-        - os: windows-latest
-          node-version: 22
+        exclude:
+          - os: windows-latest
+            node-version: 22
 
     steps:
       - name: Check out repo
diff --git a/.github/workflows/package-manager-ci.yml b/.github/workflows/package-manager-ci.yml
index b768065..a3fe776 100644
--- a/.github/workflows/package-manager-ci.yml
+++ b/.github/workflows/package-manager-ci.yml
@@ -26,7 +26,7 @@ jobs:
         with:
           node-version: ${{ matrix.node-version }}
       - name: Use pnpm
-        uses: pnpm/action-setup@v3.0.0
+        uses: pnpm/action-setup@v4.0.0
         with:
           version: ^9.0.0
       - name: Install dependancies
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 7dab821..a6c44ff 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -6,6 +6,10 @@ Individuals making significant and valuable contributions are given commit-acces
 
 ## Rules
 
+Before you start coding, please read [Contributing to projects with git](https://jrfom.com/posts/2017/03/08/a-primer-on-contributing-to-projects-with-git/). 
+
+Notice that as long as you don't have commit-access to the project, you have to fork the project and open PRs from the feature branches of the forked project.
+
 There are a few basic ground-rules for contributors:
 
 1. **No `--force` pushes** on `master` or modifying the Git history in any way after a PR has been merged.
diff --git a/benchmarks/basic.bench.js b/benchmarks/basic.bench.js
index 9fd597f..a1e27d4 100644
--- a/benchmarks/basic.bench.js
+++ b/benchmarks/basic.bench.js
@@ -5,7 +5,7 @@ const pino = require('../')
 const bunyan = require('bunyan')
 const bole = require('bole')('bench')
 const winston = require('winston')
-const fs = require('fs')
+const fs = require('node:fs')
 const dest = fs.createWriteStream('/dev/null')
 const loglevel = require('./utils/wrap-log-level')(dest)
 const plogNodeStream = pino(dest)
diff --git a/benchmarks/child-child.bench.js b/benchmarks/child-child.bench.js
index 1d737bf..05da997 100644
--- a/benchmarks/child-child.bench.js
+++ b/benchmarks/child-child.bench.js
@@ -3,7 +3,7 @@
 const bench = require('fastbench')
 const pino = require('../')
 const bunyan = require('bunyan')
-const fs = require('fs')
+const fs = require('node:fs')
 const dest = fs.createWriteStream('/dev/null')
 const plogNodeStream = pino(dest).child({ a: 'property' }).child({ sub: 'child' })
 delete require.cache[require.resolve('../')]
diff --git a/benchmarks/child-creation.bench.js b/benchmarks/child-creation.bench.js
index 97d2c00..fe6825e 100644
--- a/benchmarks/child-creation.bench.js
+++ b/benchmarks/child-creation.bench.js
@@ -4,7 +4,7 @@ const bench = require('fastbench')
 const pino = require('../')
 const bunyan = require('bunyan')
 const bole = require('bole')('bench')
-const fs = require('fs')
+const fs = require('node:fs')
 const dest = fs.createWriteStream('/dev/null')
 const plogNodeStream = pino(dest)
 const plogDest = pino(pino.destination(('/dev/null')))
diff --git a/benchmarks/child.bench.js b/benchmarks/child.bench.js
index 0d50bc9..efe2d66 100644
--- a/benchmarks/child.bench.js
+++ b/benchmarks/child.bench.js
@@ -4,7 +4,7 @@ const bench = require('fastbench')
 const pino = require('../')
 const bunyan = require('bunyan')
 const bole = require('bole')('bench')('child')
-const fs = require('fs')
+const fs = require('node:fs')
 const dest = fs.createWriteStream('/dev/null')
 const plogNodeStream = pino(dest).child({ a: 'property' })
 delete require.cache[require.resolve('../')]
diff --git a/benchmarks/deep-object.bench.js b/benchmarks/deep-object.bench.js
index a313475..44f6c34 100644
--- a/benchmarks/deep-object.bench.js
+++ b/benchmarks/deep-object.bench.js
@@ -5,7 +5,7 @@ const pino = require('../')
 const bunyan = require('bunyan')
 const bole = require('bole')('bench')
 const winston = require('winston')
-const fs = require('fs')
+const fs = require('node:fs')
 const dest = fs.createWriteStream('/dev/null')
 const plogNodeStream = pino(dest)
 delete require.cache[require.resolve('../')]
diff --git a/benchmarks/internal/just-pino-heavy.bench.js b/benchmarks/internal/just-pino-heavy.bench.js
index 12cde81..55efc85 100644
--- a/benchmarks/internal/just-pino-heavy.bench.js
+++ b/benchmarks/internal/just-pino-heavy.bench.js
@@ -2,7 +2,7 @@
 
 const bench = require('fastbench')
 const pino = require('../../')
-const fs = require('fs')
+const fs = require('node:fs')
 const dest = fs.createWriteStream('/dev/null')
 const plog = pino(dest)
 delete require.cache[require.resolve('../../')]
diff --git a/benchmarks/internal/just-pino.bench.js b/benchmarks/internal/just-pino.bench.js
index aef06a3..04bbe23 100644
--- a/benchmarks/internal/just-pino.bench.js
+++ b/benchmarks/internal/just-pino.bench.js
@@ -2,7 +2,7 @@
 
 const bench = require('fastbench')
 const pino = require('../../')
-const fs = require('fs')
+const fs = require('node:fs')
 const dest = fs.createWriteStream('/dev/null')
 const plog = pino(dest)
 delete require.cache[require.resolve('../../')]
diff --git a/benchmarks/internal/redact.bench.js b/benchmarks/internal/redact.bench.js
index 7ba32fe..852dd75 100644
--- a/benchmarks/internal/redact.bench.js
+++ b/benchmarks/internal/redact.bench.js
@@ -2,7 +2,7 @@
 
 const bench = require('fastbench')
 const pino = require('../../')
-const fs = require('fs')
+const fs = require('node:fs')
 const dest = fs.createWriteStream('/dev/null')
 const plog = pino(dest)
 delete require.cache[require.resolve('../../')]
diff --git a/benchmarks/long-string.bench.js b/benchmarks/long-string.bench.js
index 6747b72..7f37a32 100644
--- a/benchmarks/long-string.bench.js
+++ b/benchmarks/long-string.bench.js
@@ -5,7 +5,7 @@ const pino = require('../')
 const bunyan = require('bunyan')
 const bole = require('bole')('bench')
 const winston = require('winston')
-const fs = require('fs')
+const fs = require('node:fs')
 const dest = fs.createWriteStream('/dev/null')
 const plogNodeStream = pino(dest)
 delete require.cache[require.resolve('../')]
diff --git a/benchmarks/multi-arg.bench.js b/benchmarks/multi-arg.bench.js
index 0c7af66..8cbc4dc 100644
--- a/benchmarks/multi-arg.bench.js
+++ b/benchmarks/multi-arg.bench.js
@@ -5,7 +5,7 @@ const pino = require('../')
 const bunyan = require('bunyan')
 const bole = require('bole')('bench')
 const winston = require('winston')
-const fs = require('fs')
+const fs = require('node:fs')
 const dest = fs.createWriteStream('/dev/null')
 const plogNodeStream = pino(dest)
 delete require.cache[require.resolve('../')]
diff --git a/benchmarks/multistream.js b/benchmarks/multistream.js
index d67b7e2..18b9661 100644
--- a/benchmarks/multistream.js
+++ b/benchmarks/multistream.js
@@ -3,7 +3,7 @@
 const bench = require('fastbench')
 const bunyan = require('bunyan')
 const pino = require('../')
-const fs = require('fs')
+const fs = require('node:fs')
 const dest = fs.createWriteStream('/dev/null')
 
 const tenStreams = [
diff --git a/benchmarks/object.bench.js b/benchmarks/object.bench.js
index 3d75582..6207dec 100644
--- a/benchmarks/object.bench.js
+++ b/benchmarks/object.bench.js
@@ -5,7 +5,7 @@ const pino = require('../')
 const bunyan = require('bunyan')
 const bole = require('bole')('bench')
 const winston = require('winston')
-const fs = require('fs')
+const fs = require('node:fs')
 const dest = fs.createWriteStream('/dev/null')
 const loglevel = require('./utils/wrap-log-level')(dest)
 const plogNodeStream = pino(dest)
diff --git a/benchmarks/utils/generate-benchmark-doc.js b/benchmarks/utils/generate-benchmark-doc.js
index 44bd5d8..edf8a03 100644
--- a/benchmarks/utils/generate-benchmark-doc.js
+++ b/benchmarks/utils/generate-benchmark-doc.js
@@ -1,6 +1,6 @@
 'use strict'
-const { join } = require('path')
-const { execSync } = require('child_process')
+const { join } = require('node:path')
+const { execSync } = require('node:child_process')
 
 const run = (type) => {
   process.stderr.write(`benchmarking ${type}\n`)
diff --git a/benchmarks/utils/runbench.js b/benchmarks/utils/runbench.js
index 5ae9111..7bb5585 100644
--- a/benchmarks/utils/runbench.js
+++ b/benchmarks/utils/runbench.js
@@ -1,8 +1,8 @@
 'use strict'
 
-const { type, platform, arch, release, cpus } = require('os')
-const { resolve, join } = require('path')
-const spawn = require('child_process').spawn
+const { type, platform, arch, release, cpus } = require('node:os')
+const { resolve, join } = require('node:path')
+const spawn = require('node:child_process').spawn
 const pump = require('pump')
 const split = require('split2')
 const through = require('through2')
diff --git a/benchmarks/utils/wrap-log-level.js b/benchmarks/utils/wrap-log-level.js
index f144b68..77d0691 100644
--- a/benchmarks/utils/wrap-log-level.js
+++ b/benchmarks/utils/wrap-log-level.js
@@ -1,8 +1,8 @@
 'use strict'
 
-const { readFileSync } = require('fs')
+const { readFileSync } = require('node:fs')
 const vm = require('vm')
-const { join } = require('path')
+const { join } = require('node:path')
 const code = readFileSync(
   join(__dirname, '..', '..', 'node_modules', 'loglevel', 'lib', 'loglevel.js')
 )
diff --git a/browser.js b/browser.js
index 8560f1f..522de1a 100644
--- a/browser.js
+++ b/browser.js
@@ -112,7 +112,8 @@ function pino (opts) {
     formatters: opts.browser.formatters,
     levels,
     timestamp: getTimeFunction(opts),
-    messageKey: opts.messageKey || 'msg'
+    messageKey: opts.messageKey || 'msg',
+    onChild: opts.onChild || noop
   }
   logger.levels = getLevels(opts)
   logger.level = level
@@ -127,7 +128,7 @@ function pino (opts) {
   logger.serializers = serializers
   logger._serialize = serialize
   logger._stdErrSerialize = stdErrSerialize
-  logger.child = child
+  logger.child = function (...args) { return child.call(this, setOpts, ...args) }
 
   if (transmit) logger._logEvent = createLogEventShape()
 
@@ -156,7 +157,7 @@ function pino (opts) {
     })
   }
 
-  function child (bindings, childOptions) {
+  function child (setOpts, bindings, childOptions) {
     if (!bindings) {
       throw new Error('missing bindings for child Pino')
     }
@@ -194,8 +195,10 @@ function pino (opts) {
 
     // must happen before the level is assigned
     appendChildLogger(this, newLogger)
+    newLogger.child = function (...args) { return child.call(this, setOpts, ...args) }
     // required to actually initialize the logger functions for any given child
-    newLogger.level = this.level
+    newLogger.level = childOptions.level || this.level // allow level to be set by childOptions
+    setOpts.onChild(newLogger)
 
     return newLogger
   }
@@ -273,8 +276,13 @@ function set (self, opts, rootLogger, level) {
     configurable: true
   })
 
-  if (!opts.transmit && self[level] === noop) {
-    return
+  if (self[level] === noop) {
+    if (!opts.transmit) return
+
+    const transmitLevel = opts.transmit.level || self.level
+    const transmitValue = rootLogger.levels.values[transmitLevel]
+    const methodValue = rootLogger.levels.values[level]
+    if (methodValue < transmitValue) return
   }
 
   // make sure the log format is correct
diff --git a/build/sync-version.js b/build/sync-version.js
index dc7b75a..1164cc4 100644
--- a/build/sync-version.js
+++ b/build/sync-version.js
@@ -1,5 +1,5 @@
-const fs = require('fs')
-const path = require('path')
+const fs = require('node:fs')
+const path = require('node:path')
 const { version } = require('../package.json')
 
 const metaContent = `'use strict'
diff --git a/docs/api.md b/docs/api.md
index 80fa249..b3d5a0b 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -1312,7 +1312,7 @@ Create a stream composed by multiple destination streams and returns an
 object implementing the [MultiStreamRes](#multistreamres) interface.
 
 ```js
-var fs = require('fs')
+var fs = require('node:fs')
 var pino = require('pino')
 var pretty = require('pino-pretty')
 var streams = [
diff --git a/docs/help.md b/docs/help.md
index fb111fa..383f888 100644
--- a/docs/help.md
+++ b/docs/help.md
@@ -60,7 +60,7 @@ somewhere so the log rotation tool knows where to send the signal.
 
 ```js
 // write the process pid to a well known location for later
-const fs = require('fs')
+const fs = require('node:fs')
 fs.writeFileSync('/var/run/myapp.pid', process.pid)
 
 const dest = pino.destination('/log/file')
diff --git a/docs/transports.md b/docs/transports.md
index 859d7c3..597047c 100644
--- a/docs/transports.md
+++ b/docs/transports.md
@@ -25,7 +25,7 @@ flushed as quickly as possible (there is nothing to do).
 A transport is a module that exports a default function that returns a writable stream:
 
 ```js
-import { createWriteStream } from 'fs'
+import { createWriteStream } from 'node:fs'
 
 export default (options) => {
   return createWriteStream(options.destination)
@@ -54,7 +54,7 @@ The exported function can also be async. If we use an async function we can thro
 if the transform could not be opened. As an example:
 
 ```js
-import fs from 'fs'
+import fs from 'node:fs'
 import { once } from 'events'
 export default async (options) => {
   const stream = fs.createWriteStream(options.destination)
@@ -218,7 +218,7 @@ As an example, the following transport returns a `Transform` stream:
 
 ```js
 import build from 'pino-abstract-transport'
-import { pipeline, Transform } from 'stream'
+import { pipeline, Transform } from 'node:stream'
 export default async function (options) {
   return build(function (source) {
     const myTransportStream = new Transform({
@@ -378,7 +378,7 @@ A legacy Pino "transport" is a supplementary tool that consumes Pino logs.
 Consider the following example for creating a transport:
 
 ```js
-const { pipeline, Writable } = require('stream')
+const { pipeline, Writable } = require('node:stream')
 const split = require('split2')
 
 const myTransportStream = new Writable({
@@ -424,6 +424,7 @@ PRs to this document are welcome for any new transports!
 + [@axiomhq/pino](#@axiomhq/pino)
 + [pino-discord-webhook](#pino-discord-webhook)
 + [pino-logfmt](#pino-logfmt)
++ [pino-telegram-webhook](#pino-telegram-webhook)
 
 ### Legacy
 
@@ -1063,6 +1064,33 @@ const logger = pino({
 })
 ```
 
+<a id="pino-telegram-webhook"></a>
+### pino-telegram-webhook
+
+[pino-telegram-webhook](https://github.com/Jhon-Mosk/pino-telegram-webhook) is a Pino v7+ transport for sending messages to [Telegram](https://telegram.org/). 
+
+```js
+const pino = require('pino');
+
+const logger = pino({
+  transport: {
+    target: 'pino-telegram-webhook',
+    level: 'error',
+    options: {
+      chatId: -1234567890,
+      botToken: "123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11",
+      extra: {
+              parse_mode: "HTML",
+            },
+    },
+  },
+})
+
+logger.error('<b>test log!</b>');
+```
+
+The `extra` parameter is optional. Parameters that the method [`sendMessage`](https://core.telegram.org/bots/api#sendmessage) supports can be passed to it.
+
 <a id="communication-between-pino-and-transport"></a>
 ## Communication between Pino and Transports
 Here we discuss some technical details of how Pino communicates with its [worker threads](https://nodejs.org/api/worker_threads.html).
diff --git a/examples/transport.js b/examples/transport.js
index 7fe71d4..7ffab98 100644
--- a/examples/transport.js
+++ b/examples/transport.js
@@ -1,8 +1,8 @@
 'use strict'
 
 const pino = require('..')
-const { tmpdir } = require('os')
-const { join } = require('path')
+const { tmpdir } = require('node:os')
+const { join } = require('node:path')
 
 const file = join(tmpdir(), `pino-${process.pid}-example`)
 
diff --git a/file.js b/file.js
index ed9d86f..7e1192b 100644
--- a/file.js
+++ b/file.js
@@ -1,7 +1,7 @@
 'use strict'
 
 const pino = require('./pino')
-const { once } = require('events')
+const { once } = require('node:events')
 
 module.exports = async function (opts = {}) {
   const destOpts = Object.assign({}, opts, { dest: opts.destination || 1, sync: false })
diff --git a/lib/meta.js b/lib/meta.js
index c4f56f3..d44e304 100644
--- a/lib/meta.js
+++ b/lib/meta.js
@@ -1,3 +1,3 @@
 'use strict'
 
-module.exports = { version: '9.1.0' }
+module.exports = { version: '9.3.1' }
diff --git a/lib/proto.js b/lib/proto.js
index b82fd0c..ef49a71 100644
--- a/lib/proto.js
+++ b/lib/proto.js
@@ -2,7 +2,7 @@
 
 /* eslint no-prototype-builtins: 0 */
 
-const { EventEmitter } = require('events')
+const { EventEmitter } = require('node:events')
 const {
   lsCacheSym,
   levelValSym,
diff --git a/lib/transport-stream.js b/lib/transport-stream.js
index da864a9..22cb37e 100644
--- a/lib/transport-stream.js
+++ b/lib/transport-stream.js
@@ -7,7 +7,7 @@ module.exports = loadTransportStreamBuilder
 /**
  * Loads & returns a function to build transport streams
  * @param {string} target
- * @returns {function(object): Promise<import('stream').Writable>}
+ * @returns {Promise<function(object): Promise<import('node:stream').Writable>>}
  * @throws {Error} In case the target module does not export a function
  */
 async function loadTransportStreamBuilder (target) {
@@ -35,7 +35,11 @@ async function loadTransportStreamBuilder (target) {
       // When bundled with pkg, an undefined error is thrown when called with realImport
       // When bundled with pkg and using node v20, an ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING error is thrown when called with realImport
       // More info at: https://github.com/pinojs/thread-stream/issues/143
-      fn = realRequire(decodeURIComponent(target))
+      try {
+        fn = realRequire(decodeURIComponent(target))
+      } catch {
+        throw error
+      }
     } else {
       throw error
     }
diff --git a/lib/transport.js b/lib/transport.js
index 8ecd219..e768d35 100644
--- a/lib/transport.js
+++ b/lib/transport.js
@@ -2,7 +2,7 @@
 
 const { createRequire } = require('module')
 const getCallers = require('./caller')
-const { join, isAbsolute, sep } = require('path')
+const { join, isAbsolute, sep } = require('node:path')
 const sleep = require('atomic-sleep')
 const onExit = require('on-exit-leak-free')
 const ThreadStream = require('thread-stream')
diff --git a/lib/worker.js b/lib/worker.js
index dcbd5d3..0bc035a 100644
--- a/lib/worker.js
+++ b/lib/worker.js
@@ -1,7 +1,7 @@
 'use strict'
 
-const EE = require('events')
-const { pipeline, PassThrough } = require('stream')
+const EE = require('node:events')
+const { pipeline, PassThrough } = require('node:stream')
 const pino = require('../pino.js')
 const build = require('pino-abstract-transport')
 const loadTransportStreamBuilder = require('./transport-stream')
diff --git a/package.json b/package.json
index accaa83..0820a2f 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "pino",
-  "version": "9.1.0",
+  "version": "9.3.1",
   "description": "super fast, all natural json logger",
   "main": "pino.js",
   "type": "commonjs",
@@ -63,7 +63,7 @@
     "@types/flush-write-stream": "^1.0.0",
     "@types/node": "^20.2.3",
     "@types/tap": "^15.0.6",
-    "@yao-pkg/pkg": "5.11.5",
+    "@yao-pkg/pkg": "5.12.0",
     "airtap": "4.0.4",
     "benchmark": "^2.1.4",
     "bole": "^5.0.5",
@@ -88,7 +88,7 @@
     "pre-commit": "^1.2.2",
     "proxyquire": "^2.1.3",
     "pump": "^3.0.0",
-    "rimraf": "^5.0.1",
+    "rimraf": "^6.0.1",
     "semver": "^7.3.7",
     "split2": "^4.0.0",
     "steed": "^1.1.3",
@@ -107,7 +107,7 @@
     "on-exit-leak-free": "^2.1.0",
     "pino-abstract-transport": "^1.2.0",
     "pino-std-serializers": "^7.0.0",
-    "process-warning": "^3.0.0",
+    "process-warning": "^4.0.0",
     "quick-format-unescaped": "^4.0.3",
     "real-require": "^0.2.0",
     "safe-stable-stringify": "^2.3.1",
diff --git a/pino.js b/pino.js
index b2ec4dd..740b97d 100644
--- a/pino.js
+++ b/pino.js
@@ -1,6 +1,6 @@
 'use strict'
-/* eslint no-prototype-builtins: 0 */
-const os = require('os')
+
+const os = require('node:os')
 const stdSerializers = require('pino-std-serializers')
 const caller = require('./lib/caller')
 const redaction = require('./lib/redaction')


Test patch:
diff --git a/test/basic.test.js b/test/basic.test.js
index cbe0aa3..6689343 100644
--- a/test/basic.test.js
+++ b/test/basic.test.js
@@ -1,6 +1,6 @@
 'use strict'
-const os = require('os')
-const { readFileSync } = require('fs')
+const os = require('node:os')
+const { readFileSync } = require('node:fs')
 const { test } = require('tap')
 const { sink, check, once, watchFileCreated, file } = require('./helper')
 const pino = require('../')
diff --git a/test/broken-pipe.test.js b/test/broken-pipe.test.js
index a5d8611..4ec2594 100644
--- a/test/broken-pipe.test.js
+++ b/test/broken-pipe.test.js
@@ -1,8 +1,8 @@
 'use strict'
 
 const t = require('tap')
-const { join } = require('path')
-const { fork } = require('child_process')
+const { join } = require('node:path')
+const { fork } = require('node:child_process')
 const { once } = require('./helper')
 const pino = require('..')
 
diff --git a/test/browser-child.test.js b/test/browser-child.test.js
index 0ed1dd5..679261a 100644
--- a/test/browser-child.test.js
+++ b/test/browser-child.test.js
@@ -14,6 +14,18 @@ test('child has parent level', ({ end, same, is }) => {
   end()
 })
 
+test('child can set level at creation time', ({ end, same, is }) => {
+  const instance = pino({
+    level: 'error',
+    browser: {}
+  })
+
+  const child = instance.child({}, { level: 'info' }) // first bindings, then options
+
+  same(child.level, 'info')
+  end()
+})
+
 test('changing child level does not affect parent', ({ end, same, is }) => {
   const instance = pino({
     level: 'error',
@@ -94,6 +106,20 @@ test('changing child log level should not affect parent log behavior', ({ end, s
   end()
 })
 
+test('onChild callback should be called when new child is created', ({ end, pass, plan }) => {
+  plan(1)
+  const instance = pino({
+    level: 'error',
+    browser: {},
+    onChild: (_child) => {
+      pass('onChild callback was called')
+      end()
+    }
+  })
+
+  instance.child({})
+})
+
 function checkLogObjects (is, same, actual, expected) {
   is(actual.time <= Date.now(), true, 'time is greater than Date.now()')
 
diff --git a/test/browser-transmit.test.js b/test/browser-transmit.test.js
index fb090c2..860524b 100644
--- a/test/browser-transmit.test.js
+++ b/test/browser-transmit.test.js
@@ -347,3 +347,23 @@ test('extracts correct bindings and raw messages over multiple transmits', ({ en
 
   end()
 })
+
+test('does not log below configured level', ({ end, is }) => {
+  let message = null
+  const logger = pino({
+    level: 'info',
+    browser: {
+      write (o) {
+        message = o.msg
+      },
+      transmit: {
+        send () { }
+      }
+    }
+  })
+
+  logger.debug('this message is silent')
+  is(message, null)
+
+  end()
+})
diff --git a/test/complex-objects.test.js b/test/complex-objects.test.js
index e647ffe..c0940f6 100644
--- a/test/complex-objects.test.js
+++ b/test/complex-objects.test.js
@@ -2,7 +2,7 @@
 
 const { test } = require('tap')
 const { sink, once } = require('./helper')
-const { PassThrough } = require('stream')
+const { PassThrough } = require('node:stream')
 const pino = require('../')
 
 test('Proxy and stream objects', async ({ equal }) => {
diff --git a/test/error.test.js b/test/error.test.js
index 01be0f4..e4570fa 100644
--- a/test/error.test.js
+++ b/test/error.test.js
@@ -2,7 +2,7 @@
 
 /* eslint no-prototype-builtins: 0 */
 
-const os = require('os')
+const os = require('node:os')
 const { test } = require('tap')
 const { sink, once } = require('./helper')
 const pino = require('../')
diff --git a/test/escaping.test.js b/test/escaping.test.js
index 1c80d83..de5b34e 100644
--- a/test/escaping.test.js
+++ b/test/escaping.test.js
@@ -1,6 +1,6 @@
 'use strict'
 
-const os = require('os')
+const os = require('node:os')
 const { test } = require('tap')
 const { sink, once } = require('./helper')
 const pino = require('../')
diff --git a/test/esm/named-exports.mjs b/test/esm/named-exports.mjs
index 326d34f..ee9f257 100644
--- a/test/esm/named-exports.mjs
+++ b/test/esm/named-exports.mjs
@@ -1,9 +1,8 @@
-import { tmpdir, hostname } from 'os'
+import { hostname } from 'node:os'
 import t from 'tap'
 import { sink, check, once, watchFileCreated, file } from '../helper.js'
 import { pino, destination } from '../../pino.js'
-import { join } from 'path'
-import { readFileSync } from 'fs'
+import { readFileSync } from 'node:fs'
 
 t.test('named exports support', async ({ equal }) => {
   const stream = sink()
diff --git a/test/exit.test.js b/test/exit.test.js
index b373ddb..a2dcf05 100644
--- a/test/exit.test.js
+++ b/test/exit.test.js
@@ -1,7 +1,7 @@
 'use strict'
 
 const { test } = require('tap')
-const { join } = require('path')
+const { join } = require('node:path')
 const execa = require('execa')
 const writer = require('flush-write-stream')
 const { once } = require('./helper')
diff --git a/test/fixtures/broken-pipe/basic.js b/test/fixtures/broken-pipe/basic.js
index def7cd0..cc33c9b 100644
--- a/test/fixtures/broken-pipe/basic.js
+++ b/test/fixtures/broken-pipe/basic.js
@@ -2,7 +2,7 @@
 
 global.process = { __proto__: process, pid: 123456 }
 Date.now = function () { return 1459875739796 }
-require('os').hostname = function () { return 'abcdefghijklmnopqr' }
+require('node:os').hostname = function () { return 'abcdefghijklmnopqr' }
 
 const pino = require('../../..')()
 
diff --git a/test/fixtures/broken-pipe/destination.js b/test/fixtures/broken-pipe/destination.js
index 15a8102..701f686 100644
--- a/test/fixtures/broken-pipe/destination.js
+++ b/test/fixtures/broken-pipe/destination.js
@@ -2,7 +2,7 @@
 
 global.process = { __proto__: process, pid: 123456 }
 Date.now = function () { return 1459875739796 }
-require('os').hostname = function () { return 'abcdefghijklmnopqr' }
+require('node:os').hostname = function () { return 'abcdefghijklmnopqr' }
 
 const pino = require('../../..')
 const logger = pino(pino.destination())
diff --git a/test/fixtures/broken-pipe/syncfalse.js b/test/fixtures/broken-pipe/syncfalse.js
index 428f4ae..de71431 100644
--- a/test/fixtures/broken-pipe/syncfalse.js
+++ b/test/fixtures/broken-pipe/syncfalse.js
@@ -2,7 +2,7 @@
 
 global.process = { __proto__: process, pid: 123456 }
 Date.now = function () { return 1459875739796 }
-require('os').hostname = function () { return 'abcdefghijklmnopqr' }
+require('node:os').hostname = function () { return 'abcdefghijklmnopqr' }
 
 const pino = require('../../..')
 const logger = pino(pino.destination({ sync: false }))
diff --git a/test/fixtures/console-transport.js b/test/fixtures/console-transport.js
index d2c95b7..9974ebc 100644
--- a/test/fixtures/console-transport.js
+++ b/test/fixtures/console-transport.js
@@ -1,4 +1,4 @@
-const { Writable } = require('stream')
+const { Writable } = require('node:stream')
 
 module.exports = (options) => {
   const myTransportStream = new Writable({
diff --git a/test/fixtures/default-exit.js b/test/fixtures/default-exit.js
index a8a5aec..3fd2a0e 100644
--- a/test/fixtures/default-exit.js
+++ b/test/fixtures/default-exit.js
@@ -1,6 +1,6 @@
 global.process = { __proto__: process, pid: 123456 }
 Date.now = function () { return 1459875739796 }
-require('os').hostname = function () { return 'abcdefghijklmnopqr' }
+require('node:os').hostname = function () { return 'abcdefghijklmnopqr' }
 const pino = require(require.resolve('./../../'))
 const logger = pino()
 logger.info('hello')
diff --git a/test/fixtures/destination-exit.js b/test/fixtures/destination-exit.js
index 5cfea74..63c6d69 100644
--- a/test/fixtures/destination-exit.js
+++ b/test/fixtures/destination-exit.js
@@ -1,6 +1,6 @@
 global.process = { __proto__: process, pid: 123456 }
 Date.now = function () { return 1459875739796 }
-require('os').hostname = function () { return 'abcdefghijklmnopqr' }
+require('node:os').hostname = function () { return 'abcdefghijklmnopqr' }
 const pino = require(require.resolve('./../../'))
 const logger = pino({}, pino.destination(1))
 logger.info('hello')
diff --git a/test/fixtures/noop-transport.js b/test/fixtures/noop-transport.js
index 5e36c44..745504a 100644
--- a/test/fixtures/noop-transport.js
+++ b/test/fixtures/noop-transport.js
@@ -1,4 +1,4 @@
-const { Writable } = require('stream')
+const { Writable } = require('node:stream')
 
 module.exports = () => {
   return new Writable({
diff --git a/test/fixtures/pretty/null-prototype.js b/test/fixtures/pretty/null-prototype.js
index a74ca2c..c88e686 100644
--- a/test/fixtures/pretty/null-prototype.js
+++ b/test/fixtures/pretty/null-prototype.js
@@ -1,6 +1,6 @@
 global.process = { __proto__: process, pid: 123456 }
 Date.now = function () { return 1459875739796 }
-require('os').hostname = function () { return 'abcdefghijklmnopqr' }
+require('node:os').hostname = function () { return 'abcdefghijklmnopqr' }
 const pino = require(require.resolve('./../../../'))
 const log = pino({ prettyPrint: true })
 const obj = Object.create(null)
diff --git a/test/fixtures/stdout-hack-protection.js b/test/fixtures/stdout-hack-protection.js
index edf45df..525ef62 100644
--- a/test/fixtures/stdout-hack-protection.js
+++ b/test/fixtures/stdout-hack-protection.js
@@ -6,6 +6,6 @@ process.stdout.write = function (chunk) {
 }
 
 Date.now = function () { return 1459875739796 }
-require('os').hostname = function () { return 'abcdefghijklmnopqr' }
+require('node:os').hostname = function () { return 'abcdefghijklmnopqr' }
 const pino = require(require.resolve('../../'))()
 pino.info('me')
diff --git a/test/fixtures/syncfalse-child.js b/test/fixtures/syncfalse-child.js
index 269ebfd..f858b3d 100644
--- a/test/fixtures/syncfalse-child.js
+++ b/test/fixtures/syncfalse-child.js
@@ -1,6 +1,6 @@
 global.process = { __proto__: process, pid: 123456 }
 Date.now = function () { return 1459875739796 }
-require('os').hostname = function () { return 'abcdefghijklmnopqr' }
+require('node:os').hostname = function () { return 'abcdefghijklmnopqr' }
 const pino = require(require.resolve('./../../'))
 const asyncLogger = pino(pino.destination({ sync: false })).child({ hello: 'world' })
 asyncLogger.info('h')
diff --git a/test/fixtures/syncfalse-exit.js b/test/fixtures/syncfalse-exit.js
index d93f9f2..fb09eab 100644
--- a/test/fixtures/syncfalse-exit.js
+++ b/test/fixtures/syncfalse-exit.js
@@ -1,6 +1,6 @@
 global.process = { __proto__: process, pid: 123456 }
 Date.now = function () { return 1459875739796 }
-require('os').hostname = function () { return 'abcdefghijklmnopqr' }
+require('node:os').hostname = function () { return 'abcdefghijklmnopqr' }
 const pino = require(require.resolve('./../../'))
 const dest = pino.destination({ dest: 1, minLength: 4096, sync: false })
 const logger = pino({}, dest)
diff --git a/test/fixtures/syncfalse-flush-exit.js b/test/fixtures/syncfalse-flush-exit.js
index 70a2f6d..bf9cb4f 100644
--- a/test/fixtures/syncfalse-flush-exit.js
+++ b/test/fixtures/syncfalse-flush-exit.js
@@ -1,6 +1,6 @@
 global.process = { __proto__: process, pid: 123456 }
 Date.now = function () { return 1459875739796 }
-require('os').hostname = function () { return 'abcdefghijklmnopqr' }
+require('node:os').hostname = function () { return 'abcdefghijklmnopqr' }
 const pino = require(require.resolve('./../../'))
 const dest = pino.destination({ dest: 1, minLength: 4096, sync: false })
 const logger = pino({}, dest)
diff --git a/test/fixtures/syncfalse.js b/test/fixtures/syncfalse.js
index a111bd9..4d36752 100644
--- a/test/fixtures/syncfalse.js
+++ b/test/fixtures/syncfalse.js
@@ -1,6 +1,6 @@
 global.process = { __proto__: process, pid: 123456 }
 Date.now = function () { return 1459875739796 }
-require('os').hostname = function () { return 'abcdefghijklmnopqr' }
+require('node:os').hostname = function () { return 'abcdefghijklmnopqr' }
 const pino = require(require.resolve('./../../'))
 const asyncLogger = pino(pino.destination({ minLength: 4096, sync: false }))
 asyncLogger.info('h')
diff --git a/test/fixtures/syntax-error-esm.mjs b/test/fixtures/syntax-error-esm.mjs
new file mode 100644
index 0000000..021d53b
--- /dev/null
+++ b/test/fixtures/syntax-error-esm.mjs
@@ -0,0 +1,2 @@
+// This is a syntax error
+import
diff --git a/test/fixtures/to-file-transport-with-transform.js b/test/fixtures/to-file-transport-with-transform.js
index 1a07eef..89cf465 100644
--- a/test/fixtures/to-file-transport-with-transform.js
+++ b/test/fixtures/to-file-transport-with-transform.js
@@ -1,8 +1,8 @@
 'use strict'
 
-const fs = require('fs')
-const { once } = require('events')
-const { Transform } = require('stream')
+const fs = require('node:fs')
+const { once } = require('node:events')
+const { Transform } = require('node:stream')
 
 async function run (opts) {
   if (!opts.destination) throw new Error('kaboom')
diff --git a/test/fixtures/to-file-transport.js b/test/fixtures/to-file-transport.js
index 33de462..09f1274 100644
--- a/test/fixtures/to-file-transport.js
+++ b/test/fixtures/to-file-transport.js
@@ -1,7 +1,7 @@
 'use strict'
 
-const fs = require('fs')
-const { once } = require('events')
+const fs = require('node:fs')
+const { once } = require('node:events')
 
 async function run (opts) {
   if (!opts.destination) throw new Error('kaboom')
diff --git a/test/fixtures/to-file-transport.mjs b/test/fixtures/to-file-transport.mjs
index e0cbeec..4925d3b 100644
--- a/test/fixtures/to-file-transport.mjs
+++ b/test/fixtures/to-file-transport.mjs
@@ -1,5 +1,5 @@
-import { createWriteStream } from 'fs'
-import { once } from 'events'
+import { createWriteStream } from 'node:fs'
+import { once } from 'node:events'
 
 export default async function run (opts) {
   const stream = createWriteStream(opts.destination)
diff --git a/test/fixtures/transport-main.js b/test/fixtures/transport-main.js
index 858cf56..cb02005 100644
--- a/test/fixtures/transport-main.js
+++ b/test/fixtures/transport-main.js
@@ -1,6 +1,6 @@
 'use strict'
 
-const { join } = require('path')
+const { join } = require('node:path')
 const pino = require('../..')
 const transport = pino.transport({
   target: join(__dirname, 'transport-worker.js')
diff --git a/test/fixtures/transport-transform.js b/test/fixtures/transport-transform.js
index 2ba524b..4950236 100644
--- a/test/fixtures/transport-transform.js
+++ b/test/fixtures/transport-transform.js
@@ -1,7 +1,7 @@
 'use strict'
 
 const build = require('pino-abstract-transport')
-const { pipeline, Transform } = require('stream')
+const { pipeline, Transform } = require('node:stream')
 module.exports = (options) => {
   return build(function (source) {
     const myTransportStream = new Transform({
diff --git a/test/fixtures/transport-uses-pino-config.js b/test/fixtures/transport-uses-pino-config.js
index 0490b63..0c87c94 100644
--- a/test/fixtures/transport-uses-pino-config.js
+++ b/test/fixtures/transport-uses-pino-config.js
@@ -1,7 +1,7 @@
 'use strict'
 
 const build = require('pino-abstract-transport')
-const { pipeline, Transform } = require('stream')
+const { pipeline, Transform } = require('node:stream')
 module.exports = () => {
   return build(function (source) {
     const myTransportStream = new Transform({
diff --git a/test/fixtures/transport-worker-data.js b/test/fixtures/transport-worker-data.js
index 24e3ee0..1e0e7a8 100644
--- a/test/fixtures/transport-worker-data.js
+++ b/test/fixtures/transport-worker-data.js
@@ -1,7 +1,7 @@
 'use strict'
 
 const { parentPort, workerData } = require('worker_threads')
-const { Writable } = require('stream')
+const { Writable } = require('node:stream')
 
 module.exports = (options) => {
   const myTransportStream = new Writable({
diff --git a/test/fixtures/transport-worker.js b/test/fixtures/transport-worker.js
index 16bbefc..8964b26 100644
--- a/test/fixtures/transport-worker.js
+++ b/test/fixtures/transport-worker.js
@@ -1,7 +1,7 @@
 'use strict'
 
-const { Writable } = require('stream')
-const fs = require('fs')
+const { Writable } = require('node:stream')
+const fs = require('node:fs')
 module.exports = (options) => {
   const myTransportStream = new Writable({
     autoDestroy: true,
diff --git a/test/fixtures/transport/index.js b/test/fixtures/transport/index.js
index c576a7b..f255858 100644
--- a/test/fixtures/transport/index.js
+++ b/test/fixtures/transport/index.js
@@ -1,7 +1,7 @@
 'use strict'
 
-const fs = require('fs')
-const { once } = require('events')
+const fs = require('node:fs')
+const { once } = require('node:events')
 
 async function run (opts) {
   const stream = fs.createWriteStream(opts.destination)
diff --git a/test/fixtures/ts/to-file-transport-with-transform.ts b/test/fixtures/ts/to-file-transport-with-transform.ts
index e3586a0..aa56b3d 100644
--- a/test/fixtures/ts/to-file-transport-with-transform.ts
+++ b/test/fixtures/ts/to-file-transport-with-transform.ts
@@ -1,6 +1,6 @@
-import * as fs from 'fs'
-import { once } from 'events'
-import { Transform } from 'stream'
+import * as fs from 'node:fs'
+import { once } from 'node:events'
+import { Transform } from 'node:stream'
 
 async function run (opts: {  destination?: fs.PathLike }): Promise<Transform> {
   if (!opts.destination) throw new Error('kaboom')
diff --git a/test/fixtures/ts/to-file-transport.ts b/test/fixtures/ts/to-file-transport.ts
index 6ebf09c..1860606 100644
--- a/test/fixtures/ts/to-file-transport.ts
+++ b/test/fixtures/ts/to-file-transport.ts
@@ -1,5 +1,5 @@
-import * as fs from 'fs'
-import { once } from 'events'
+import * as fs from 'node:fs'
+import { once } from 'node:events'
 
 async function run (opts: { destination?: fs.PathLike }): Promise<fs.WriteStream> {
   if (!opts.destination) throw new Error('kaboom')
diff --git a/test/fixtures/ts/transpile.cjs b/test/fixtures/ts/transpile.cjs
index 1ad61b4..6c2af67 100755
--- a/test/fixtures/ts/transpile.cjs
+++ b/test/fixtures/ts/transpile.cjs
@@ -1,7 +1,7 @@
 #!/usr/bin/env node
 
 const execa = require('execa')
-const fs = require('fs')
+const fs = require('node:fs')
 
 const existsSync = fs.existsSync
 const stat = fs.promises.stat
diff --git a/test/fixtures/ts/transport-exit-immediately-with-async-dest.ts b/test/fixtures/ts/transport-exit-immediately-with-async-dest.ts
index 288f0bf..f3e6f2e 100644
--- a/test/fixtures/ts/transport-exit-immediately-with-async-dest.ts
+++ b/test/fixtures/ts/transport-exit-immediately-with-async-dest.ts
@@ -1,5 +1,5 @@
 import pino from '../../..'
-import { join } from 'path'
+import { join } from 'node:path'
 
 const transport = pino.transport({
   target: join(__dirname, 'to-file-transport-with-transform.ts'),
diff --git a/test/fixtures/ts/transport-main.ts b/test/fixtures/ts/transport-main.ts
index fdf9914..f31f88c 100644
--- a/test/fixtures/ts/transport-main.ts
+++ b/test/fixtures/ts/transport-main.ts
@@ -1,4 +1,4 @@
-import { join } from 'path'
+import { join } from 'node:path'
 import pino from '../../..'
 
 const transport = pino.transport({
diff --git a/test/fixtures/ts/transport-worker.ts b/test/fixtures/ts/transport-worker.ts
index 7af63da..8061291 100644
--- a/test/fixtures/ts/transport-worker.ts
+++ b/test/fixtures/ts/transport-worker.ts
@@ -1,4 +1,4 @@
-import { Writable } from 'stream'
+import { Writable } from 'node:stream'
 
 export default (): Writable => {
   const myTransportStream = new Writable({
diff --git a/test/formatters.test.js b/test/formatters.test.js
index 39a0013..77ae0ef 100644
--- a/test/formatters.test.js
+++ b/test/formatters.test.js
@@ -1,9 +1,9 @@
 'use strict'
 /* eslint no-prototype-builtins: 0 */
 
-const { hostname } = require('os')
-const { join } = require('path')
-const { readFile } = require('fs').promises
+const { hostname } = require('node:os')
+const { join } = require('node:path')
+const { readFile } = require('node:fs').promises
 const { test } = require('tap')
 const { sink, once, watchFileCreated, file } = require('./helper')
 const pino = require('../')
diff --git a/test/helper.d.ts b/test/helper.d.ts
index cc10db1..5798d04 100644
--- a/test/helper.d.ts
+++ b/test/helper.d.ts
@@ -1,4 +1,4 @@
-import { PathLike } from 'fs'
+import { PathLike } from 'node:fs'
 
 export declare function watchFileCreated(filename: PathLike): Promise<void>
 export declare function watchForWrite(filename: PathLike, testString: string): Promise<void>
diff --git a/test/helper.js b/test/helper.js
index 2aca1aa..0080396 100644
--- a/test/helper.js
+++ b/test/helper.js
@@ -1,14 +1,14 @@
 'use strict'
 
 const crypto = require('crypto')
-const os = require('os')
+const os = require('node:os')
 const writer = require('flush-write-stream')
 const split = require('split2')
-const { existsSync, readFileSync, statSync, unlinkSync } = require('fs')
+const { existsSync, readFileSync, statSync, unlinkSync } = require('node:fs')
 const pid = process.pid
 const hostname = os.hostname()
 const t = require('tap')
-const { join } = require('path')
+const { join } = require('node:path')
 const { tmpdir } = os
 
 const isWin = process.platform === 'win32'
diff --git a/test/http.test.js b/test/http.test.js
index d5e01b4..650868f 100644
--- a/test/http.test.js
+++ b/test/http.test.js
@@ -1,7 +1,7 @@
 'use strict'
 
 const http = require('http')
-const os = require('os')
+const os = require('node:os')
 const semver = require('semver')
 const { test, skip } = require('tap')
 const { sink, once } = require('./helper')
diff --git a/test/internals/version.test.js b/test/internals/version.test.js
index eeeaf9d..8528891 100644
--- a/test/internals/version.test.js
+++ b/test/internals/version.test.js
@@ -1,7 +1,7 @@
 'use strict'
 
-const fs = require('fs')
-const path = require('path')
+const fs = require('node:fs')
+const path = require('node:path')
 const t = require('tap')
 const test = t.test
 const pino = require('../..')()
diff --git a/test/metadata.test.js b/test/metadata.test.js
index 1330973..5ecb984 100644
--- a/test/metadata.test.js
+++ b/test/metadata.test.js
@@ -1,6 +1,6 @@
 'use strict'
 
-const os = require('os')
+const os = require('node:os')
 const { test } = require('tap')
 const pino = require('../')
 
diff --git a/test/mixin.test.js b/test/mixin.test.js
index 18f0736..b40b3cd 100644
--- a/test/mixin.test.js
+++ b/test/mixin.test.js
@@ -1,6 +1,6 @@
 'use strict'
 
-const os = require('os')
+const os = require('node:os')
 const { test } = require('tap')
 const { sink, once } = require('./helper')
 const pino = require('../')
diff --git a/test/multistream.test.js b/test/multistream.test.js
index b38f24b..3d505ce 100644
--- a/test/multistream.test.js
+++ b/test/multistream.test.js
@@ -1,8 +1,8 @@
 'use strict'
 
 const writeStream = require('flush-write-stream')
-const { readFileSync } = require('fs')
-const { join } = require('path')
+const { readFileSync } = require('node:fs')
+const { join } = require('node:path')
 const test = require('tap').test
 const pino = require('../')
 const multistream = pino.multistream
diff --git a/test/pkg/index.js b/test/pkg/index.js
index 762a62f..7c247f4 100644
--- a/test/pkg/index.js
+++ b/test/pkg/index.js
@@ -1,8 +1,8 @@
 'use strict'
 
-const os = require('os')
-const { join } = require('path')
-const { readFile } = require('fs').promises
+const os = require('node:os')
+const { join } = require('node:path')
+const { readFile } = require('node:fs').promises
 const { watchFileCreated, file } = require('../helper')
 const { test } = require('tap')
 const pino = require('../../pino')
diff --git a/test/pkg/pkg.test.js b/test/pkg/pkg.test.js
index c8abcb6..bf2643a 100644
--- a/test/pkg/pkg.test.js
+++ b/test/pkg/pkg.test.js
@@ -2,11 +2,11 @@
 
 const { test } = require('tap')
 const config = require('./pkg.config.json')
-const { promisify } = require('util')
-const { unlink } = require('fs/promises')
-const { join } = require('path')
-const { platform } = require('process')
-const exec = promisify(require('child_process').exec)
+const { promisify } = require('node:util')
+const { unlink } = require('node:fs/promises')
+const { join } = require('node:path')
+const { platform } = require('node:process')
+const exec = promisify(require('node:child_process').exec)
 
 /**
  * The following regex is for tesintg the deprecation warning that is thrown by the `punycode` module.
diff --git a/test/stdout-protection.test.js b/test/stdout-protection.test.js
index c10f45c..fb42621 100644
--- a/test/stdout-protection.test.js
+++ b/test/stdout-protection.test.js
@@ -1,8 +1,8 @@
 'use strict'
 
 const { test } = require('tap')
-const { join } = require('path')
-const { fork } = require('child_process')
+const { join } = require('node:path')
+const { fork } = require('node:child_process')
 const { once } = require('./helper')
 const writer = require('flush-write-stream')
 const pino = require('..')
diff --git a/test/syncfalse.test.js b/test/syncfalse.test.js
index 9243f2f..29a4fc1 100644
--- a/test/syncfalse.test.js
+++ b/test/syncfalse.test.js
@@ -1,13 +1,10 @@
 'use strict'
 
-const os = require('os')
-const {
-  createWriteStream
-} = require('fs')
-const { readFile } = require('fs').promises
-const { join } = require('path')
+const os = require('node:os')
+const { promises: { readFile }, createWriteStream } = require('node:fs')
+const { join } = require('node:path')
 const { test } = require('tap')
-const { fork } = require('child_process')
+const { fork } = require('node:child_process')
 const writer = require('flush-write-stream')
 const {
   once,
@@ -15,7 +12,7 @@ const {
   file,
   watchFileCreated
 } = require('./helper')
-const { promisify } = require('util')
+const { promisify } = require('node:util')
 
 const sleep = promisify(setTimeout)
 
diff --git a/test/transport-stream.test.js b/test/transport-stream.test.js
new file mode 100644
index 0000000..488aceb
--- /dev/null
+++ b/test/transport-stream.test.js
@@ -0,0 +1,26 @@
+'use strict'
+
+const { test } = require('tap')
+
+test('should import', async (t) => {
+  t.plan(2)
+  const mockRealRequire = (target) => {
+    return {
+      default: {
+        default: () => {
+          t.equal(target, 'pino-pretty')
+          return Promise.resolve()
+        }
+      }
+    }
+  }
+  const mockRealImport = async () => { await Promise.resolve(); throw Object.assign(new Error(), { code: 'ERR_MODULE_NOT_FOUND' }) }
+
+  /** @type {typeof import('../lib/transport-stream.js')} */
+  const loadTransportStreamBuilder = t.mock('../lib/transport-stream.js', { 'real-require': { realRequire: mockRealRequire, realImport: mockRealImport } })
+
+  const fn = await loadTransportStreamBuilder('pino-pretty')
+
+  t.resolves(fn())
+  t.end()
+})
diff --git a/test/transport/big.test.js b/test/transport/big.test.js
index b732cab..d818b97 100644
--- a/test/transport/big.test.js
+++ b/test/transport/big.test.js
@@ -1,12 +1,12 @@
 'use strict'
 
 const { test } = require('tap')
-const { join } = require('path')
-const { createReadStream } = require('fs')
-const { promisify } = require('util')
+const { join } = require('node:path')
+const { createReadStream } = require('node:fs')
+const { promisify } = require('node:util')
 const execa = require('execa')
 const split = require('split2')
-const stream = require('stream')
+const stream = require('node:stream')
 const { file } = require('../helper')
 
 const pipeline = promisify(stream.pipeline)
diff --git a/test/transport/bundlers-support.test.js b/test/transport/bundlers-support.test.js
index cb10221..f651a97 100644
--- a/test/transport/bundlers-support.test.js
+++ b/test/transport/bundlers-support.test.js
@@ -1,8 +1,8 @@
 'use strict'
 
-const os = require('os')
-const { join } = require('path')
-const { readFile } = require('fs').promises
+const os = require('node:os')
+const { join } = require('node:path')
+const { readFile } = require('node:fs').promises
 const { watchFileCreated, file } = require('../helper')
 const { test } = require('tap')
 const pino = require('../../pino')
diff --git a/test/transport/caller.test.js b/test/transport/caller.test.js
index 5c55a8a..e54a786 100644
--- a/test/transport/caller.test.js
+++ b/test/transport/caller.test.js
@@ -1,6 +1,6 @@
 'use strict'
 
-const { join } = require('path')
+const { join } = require('node:path')
 const { test } = require('tap')
 const execa = require('execa')
 
diff --git a/test/transport/core.test.js b/test/transport/core.test.js
index a61b085..44449db 100644
--- a/test/transport/core.test.js
+++ b/test/transport/core.test.js
@@ -1,9 +1,9 @@
 'use strict'
 
-const os = require('os')
-const { join } = require('path')
-const { once } = require('events')
-const { readFile, writeFile } = require('fs').promises
+const os = require('node:os')
+const { join } = require('node:path')
+const { once } = require('node:events')
+const { readFile, writeFile } = require('node:fs').promises
 const { watchFileCreated, watchForWrite, file } = require('../helper')
 const { test } = require('tap')
 const pino = require('../../')
@@ -12,7 +12,7 @@ const strip = require('strip-ansi')
 const execa = require('execa')
 const writer = require('flush-write-stream')
 const rimraf = require('rimraf')
-const { promisify } = require('util')
+const { promisify } = require('node:util')
 const { tmpdir } = os
 
 const immediate = promisify(setImmediate)
diff --git a/test/transport/core.test.ts b/test/transport/core.test.ts
index a1c80d8..deca48a 100644
--- a/test/transport/core.test.ts
+++ b/test/transport/core.test.ts
@@ -1,11 +1,11 @@
-import * as os from 'os'
-import { join } from 'path'
-import { once } from 'events'
-import fs from 'fs'
+import * as os from 'node:os'
+import { join } from 'node:path'
+import { once } from 'node:events'
+import fs from 'node:fs'
 import { watchFileCreated } from '../helper'
 import { test } from 'tap'
 import pino from '../../'
-import * as url from 'url'
+import * as url from 'node:url'
 import { default as strip } from 'strip-ansi'
 import execa from 'execa'
 import writer from 'flush-write-stream'
diff --git a/test/transport/core.transpiled.test.ts b/test/transport/core.transpiled.test.ts
index 614c258..a53b346 100644
--- a/test/transport/core.transpiled.test.ts
+++ b/test/transport/core.transpiled.test.ts
@@ -1,14 +1,10 @@
-import * as os from 'os'
-import { join } from 'path'
-import { once } from 'events'
-import fs from 'fs'
+import * as os from 'node:os'
+import { join } from 'node:path'
+import fs from 'node:fs'
 import { watchFileCreated } from '../helper'
 import { test } from 'tap'
 import pino from '../../'
-import * as url from 'url'
-import { default as strip } from 'strip-ansi'
-import execa from 'execa'
-import writer from 'flush-write-stream'
+import * as url from 'node:url'
 
 const readFile = fs.promises.readFile
 
diff --git a/test/transport/module-link.test.js b/test/transport/module-link.test.js
index 16a17fc..2210b87 100644
--- a/test/transport/module-link.test.js
+++ b/test/transport/module-link.test.js
@@ -1,11 +1,11 @@
 'use strict'
 
-const os = require('os')
-const { join } = require('path')
-const { readFile, symlink, unlink, mkdir, writeFile } = require('fs').promises
+const os = require('node:os')
+const { join } = require('node:path')
+const { readFile, symlink, unlink, mkdir, writeFile } = require('node:fs').promises
 const { test } = require('tap')
 const { isWin, isYarnPnp, watchFileCreated, file } = require('../helper')
-const { once } = require('events')
+const { once } = require('node:events')
 const execa = require('execa')
 const pino = require('../../')
 const rimraf = require('rimraf')
diff --git a/test/transport/pipeline.test.js b/test/transport/pipeline.test.js
index a845d44..c682b76 100644
--- a/test/transport/pipeline.test.js
+++ b/test/transport/pipeline.test.js
@@ -1,8 +1,8 @@
 'use strict'
 
-const os = require('os')
-const { join } = require('path')
-const { readFile } = require('fs').promises
+const os = require('node:os')
+const { join } = require('node:path')
+const { readFile } = require('node:fs').promises
 const { watchFileCreated, file } = require('../helper')
 const { test } = require('tap')
 const pino = require('../../')
diff --git a/test/transport/syncfalse.test.js b/test/transport/syncfalse.test.js
index 4b9f682..c5f7692 100644
--- a/test/transport/syncfalse.test.js
+++ b/test/transport/syncfalse.test.js
@@ -1,12 +1,12 @@
 'use strict'
 
-const os = require('os')
+const os = require('node:os')
 const pino = require('../..')
-const { join } = require('path')
+const { join } = require('node:path')
 const { test } = require('tap')
-const { readFile } = require('fs').promises
+const { readFile } = require('node:fs').promises
 const { watchFileCreated, file } = require('../helper')
-const { promisify } = require('util')
+const { promisify } = require('node:util')
 
 const { pid } = process
 const hostname = os.hostname()
diff --git a/test/transport/targets.test.js b/test/transport/targets.test.js
index f368fc7..14faa91 100644
--- a/test/transport/targets.test.js
+++ b/test/transport/targets.test.js
@@ -1,8 +1,10 @@
 'use strict'
 
 const { test } = require('tap')
+const { join } = require('node:path')
 const proxyquire = require('proxyquire')
-const Writable = require('stream').Writable
+const Writable = require('node:stream').Writable
+const pino = require('../../pino')
 
 test('file-target mocked', async function ({ equal, same, plan, pass }) {
   plan(1)
@@ -26,3 +28,17 @@ test('file-target mocked', async function ({ equal, same, plan, pass }) {
 
   await fileTarget()
 })
+
+test('pino.transport with syntax error', ({ same, teardown, plan }) => {
+  plan(1)
+  const transport = pino.transport({
+    targets: [{
+      target: join(__dirname, '..', 'fixtures', 'syntax-error-esm.mjs')
+    }]
+  })
+  teardown(transport.end.bind(transport))
+
+  transport.on('error', (err) => {
+    same(err, new SyntaxError('Unexpected end of input'))
+  })
+})
diff --git a/test/transport/uses-pino-config.test.js b/test/transport/uses-pino-config.test.js
index dc4e0f5..46f2ab3 100644
--- a/test/transport/uses-pino-config.test.js
+++ b/test/transport/uses-pino-config.test.js
@@ -1,8 +1,8 @@
 'use strict'
 
-const os = require('os')
-const { join } = require('path')
-const { readFile } = require('fs').promises
+const os = require('node:os')
+const { join } = require('node:path')
+const { readFile } = require('node:fs').promises
 const writeStream = require('flush-write-stream')
 const { watchFileCreated, file } = require('../helper')
 const { test } = require('tap')
diff --git a/test/types/pino-multistream.test-d.ts b/test/types/pino-multistream.test-d.ts
index 29f09d7..6206eca 100644
--- a/test/types/pino-multistream.test-d.ts
+++ b/test/types/pino-multistream.test-d.ts
@@ -1,6 +1,6 @@
 import { expectType } from 'tsd'
 
-import { createWriteStream } from 'fs'
+import { createWriteStream } from 'node:fs'
 
 import pino, { multistream } from '../../pino'
 
diff --git a/test/types/pino.ts b/test/types/pino.ts
index c1cf8c0..a167309 100644
--- a/test/types/pino.ts
+++ b/test/types/pino.ts
@@ -1,6 +1,6 @@
 import { StreamEntry, pino } from '../../pino'
-import { join } from 'path'
-import { tmpdir } from 'os'
+import { join } from 'node:path'
+import { tmpdir } from 'node:os'
 import pinoPretty from 'pino-pretty'
 
 const destination = join(