Uh oh!
There was an error while loading. Please reload this page.
refactor: prefix built-in node module imports - #6236
Merged
Conversation
slagiewkaforce-pushed
the
module_prefixes
branch
2 times, most recently
from
December 21, 2024 22:29
3394d38 to
21d1bb9CompareUlisesGascon
approved these changes
Dec 21, 2024
UlisesGascon
left a comment
Member
There was a problem hiding this comment.
Great work @slagiewka! I like the idea, let's see what other @expressjs/express-tc members things about it :)
IamLizu
reviewed
Dec 26, 2024
IamLizu
left a comment
Member
There was a problem hiding this comment.
While I appreciate the effort, this isn't necessary. It's only required for newly added built-in modules that conflict with existing ones.
Node.js already prioritizes built-in modules (like http, path, and fs) over user-land modules or files with the same name.
bjohansebas
approved these changes
Dec 26, 2024
wesleytodd
approved these changes
Jan 8, 2025
wesleytodd
left a comment
Member
There was a problem hiding this comment.
While @IamLizu is technically correct, IMO this is a good change. Being clear is usually better and I personally consider this way border-line best practice at this point. 👍 from me.
wesleytoddforce-pushed
the
module_prefixes
branch
from
January 10, 2025 17:47
f9fb12c to
ad7e7bbCompareSince 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 compatibility[^4], albeit only during development. Once imported from npm, built-ins are assumed. [^1]:https://nodejs.org/docs/latest-v22.x/api/modules.html#built-in-modules [^2]: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
wesleytoddforce-pushed
the
module_prefixes
branch
from
January 10, 2025 17:51
ad7e7bb to
6ccc881ComparePhillip9587 added a commit
to Phillip9587/body-parser
that referenced
this pull request
Jan 14, 2025
Align with changes introduced in expressjs/express#6236 by prefixing all built-in Node.js module imports with 'node:'. Reference: expressjs/express#6236
Phillip9587 added a commit
to Phillip9587/body-parser
that referenced
this pull request
Jan 17, 2025
Align with changes introduced in expressjs/express#6236 by prefixing all built-in Node.js module imports with 'node:'. Reference: expressjs/express#6236
wesleytodd pushed a commit
to expressjs/body-parser
that referenced
this pull request
Jan 23, 2025
Align with changes introduced in expressjs/express#6236 by prefixing all built-in Node.js module imports with 'node:'. Reference: expressjs/express#6236
Closed
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since v5 relies on node >= 18, this is now possible (since v16, v14.18.0 12).
It's functionally irrelevant:
However, there are upsides to this approach:
Footnotes
https://nodejs.org/docs/latest-v22.x/api/modules.html#built-in-modules↩
https://github.com/nodejs/node/pull/37246↩
https://nodejs.org/api/modules.html#built-in-modules-with-mandatory-node-prefix↩
https://docs.deno.com/runtime/fundamentals/node/#using-node's-built-in-modules↩