Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: prefix built-in node module imports #573

Merged
merged 1 commit into from
Jan 23, 2025

Conversation

Phillip9587
Copy link
Contributor

Align with changes introduced in expressjs/express#6236 by prefixing all built-in Node.js module imports with 'node:'.

Reference: expressjs/express#6236

Taken from that PR:

Since v5 relies on node >= 18, this is now possible (since v16, v14.18.0 1 2).

It's functionally irrelevant:

  1. It's not required for CJS nor ESM (with a few exceptions 3)
  2. It has no performance promises

However, there are upsides to this approach:

  1. It brings clear boundaries to what's a built-in and what's an external dependency
  2. It reduces the risk of importing unwanted deps where a built-in is expected
  3. It's slightly more interoperable with other JS runtimes that provide node compatibility4, albeit only during development. Once imported from npm, built-ins are assumed.

Footnotes

  1. https://nodejs.org/docs/latest-v22.x/api/modules.html#built-in-modules
  2. module: add support for node:‑prefixed require(…) calls nodejs/node#37246
  3. https://nodejs.org/api/modules.html#built-in-modules-with-mandatory-node-prefix
  4. https://docs.deno.com/runtime/fundamentals/node/#using-node's-built-in-modules

Align with changes introduced in expressjs/express#6236 by prefixing all built-in Node.js module imports with 'node:'.

Reference: expressjs/express#6236
@wesleytodd wesleytodd merged commit 91c9199 into expressjs:master Jan 23, 2025
9 checks passed
@UlisesGascon UlisesGascon mentioned this pull request Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants