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

esm: use "node:" internal namespace for builtins #35387

Closed
wants to merge 5 commits into from

Conversation

guybedford
Copy link
Contributor

This has been discussed a couple of times in the past few meetings that the internal representation for builtins should align with policies using the node: scheme as well as to allow this to be the scheme to make public for users in future if we ever want to expose it more explicitly in any modules APIs or interfaces.

This is strictly a minor breaking change, but should have relatively low usage in the wild and is entirely limited to the experimental modules and loader cases.

@nodejs/modules-active-members

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/modules

@nodejs-github-bot nodejs-github-bot added the esm Issues and PRs related to the ECMAScript Modules implementation. label Sep 28, 2020
@guybedford guybedford changed the title esm: use "node:" namespace for builtins esm: use "node:" internal namespace for builtins Sep 28, 2020
@devsnek
Copy link
Member

devsnek commented Sep 28, 2020

To be very explicit, this breaks any code which imports nodejs:xyz.

@ljharb
Copy link
Member

ljharb commented Sep 28, 2020

The likelihood that there's lots of code that uses a protocol whatsoever is vanishingly small; it seems like a good idea to get this change into v15.

Copy link
Member

@bmeck bmeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

@aduh95 aduh95 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could use primordials here?

lib/internal/modules/esm/translators.js Outdated Show resolved Hide resolved
lib/internal/modules/esm/translators.js Outdated Show resolved Hide resolved
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@nodejs-github-bot
Copy link
Collaborator

@guybedford guybedford added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Sep 29, 2020
guybedford added a commit that referenced this pull request Sep 30, 2020
PR-URL: #35387
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: Jan Krems <jan.krems@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
@guybedford
Copy link
Contributor Author

Landed in ee9e3e7.

@guybedford guybedford closed this Sep 30, 2020
danielleadams pushed a commit that referenced this pull request Oct 6, 2020
PR-URL: #35387
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: Jan Krems <jan.krems@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
@danielleadams danielleadams mentioned this pull request Oct 6, 2020
aduh95 pushed a commit to aduh95/node that referenced this pull request Oct 27, 2020
PR-URL: nodejs#35387
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: Jan Krems <jan.krems@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
MylesBorins pushed a commit that referenced this pull request Nov 3, 2020
Backport-PR-URL: #35757
PR-URL: #35387
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: Jan Krems <jan.krems@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
@MylesBorins MylesBorins mentioned this pull request Nov 3, 2020
MylesBorins pushed a commit that referenced this pull request Nov 16, 2020
Backport-PR-URL: #35757
PR-URL: #35387
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: Jan Krems <jan.krems@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
joesepi pushed a commit to joesepi/node that referenced this pull request Jan 8, 2021
PR-URL: nodejs#35387
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: Jan Krems <jan.krems@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
kevinoid added a commit to kevinoid/node-project-template that referenced this pull request May 6, 2021
Which added support for named exports for CJS via static analysis:
nodejs/node#35249
nodejs/node@1e8cb08edc for v15
nodejs/node@f551f52f83 for v14.13
nodejs/node@9eb1fa1924 for v12.20

This is also necessary for `node:` scheme support, checked by the
`unicorn/prefer-node-protocol` ESLint rule (currently disabled pending
support in eslint-plugin-node):
nodejs/node#35387
nodejs/node@ee9e3e75aa for v15
nodejs/node@91b820e939 for v14.13.1
nodejs/node@0f757bc2df for v12.20

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
kevinoid added a commit to kevinoid/hub-ci-status that referenced this pull request Aug 5, 2021
Which added support for named exports for CJS via static analysis:
nodejs/node#35249
nodejs/node@1e8cb08edc for v15
nodejs/node@f551f52f83 for v14.13
nodejs/node@9eb1fa1924 for v12.20

This is also necessary for `node:` scheme support, checked by the
`unicorn/prefer-node-protocol` ESLint rule (currently disabled pending
support in eslint-plugin-node):
nodejs/node#35387
nodejs/node@ee9e3e75aa for v15
nodejs/node@91b820e939 for v14.13.1
nodejs/node@0f757bc2df for v12.20

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
DeeDeeG added a commit to DeeDeeG/node that referenced this pull request Jul 11, 2022
Support for the 'node:' prefixed builtin module namespace was introduced
for `require()` expressions in Node v16.0.0, and backported to v14.18.0.
This was never supported in Node v15.x or chronologically older.

All of the current API history notes in the docs using 'node:' prefixed
module `require()`s happen to be documenting changes in Node versions
from before the time when support was first introduced.

This commit reverts those `require()`s in the history notes to be
un-prefixed. (They were incorrect as written; The prefixed `require()`s
would not work for those older Node versions.)

This change prevents the API history notes from inaccurately implying
'node:' prefixed builtin modules were introduced many Node versions ago,
or were `require()`-able with the 'node:' prefix in those Node versions.

Refs: nodejs#35387
Refs: nodejs#37246
Refs: nodejs#42752
nodejs-github-bot pushed a commit that referenced this pull request Jul 14, 2022
Support for the 'node:' prefixed builtin module namespace was introduced
for `require()` expressions in Node v16.0.0, and backported to v14.18.0.
This was never supported in Node v15.x or chronologically older.

All of the current API history notes in the docs using 'node:' prefixed
module `require()`s happen to be documenting changes in Node versions
from before the time when support was first introduced.

This commit reverts those `require()`s in the history notes to be
un-prefixed. (They were incorrect as written; The prefixed `require()`s
would not work for those older Node versions.)

This change prevents the API history notes from inaccurately implying
'node:' prefixed builtin modules were introduced many Node versions ago,
or were `require()`-able with the 'node:' prefix in those Node versions.

Refs: #35387
Refs: #37246
Refs: #42752

PR-URL: #43768
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
danielleadams pushed a commit that referenced this pull request Jul 26, 2022
Support for the 'node:' prefixed builtin module namespace was introduced
for `require()` expressions in Node v16.0.0, and backported to v14.18.0.
This was never supported in Node v15.x or chronologically older.

All of the current API history notes in the docs using 'node:' prefixed
module `require()`s happen to be documenting changes in Node versions
from before the time when support was first introduced.

This commit reverts those `require()`s in the history notes to be
un-prefixed. (They were incorrect as written; The prefixed `require()`s
would not work for those older Node versions.)

This change prevents the API history notes from inaccurately implying
'node:' prefixed builtin modules were introduced many Node versions ago,
or were `require()`-able with the 'node:' prefix in those Node versions.

Refs: #35387
Refs: #37246
Refs: #42752

PR-URL: #43768
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
targos pushed a commit that referenced this pull request Jul 31, 2022
Support for the 'node:' prefixed builtin module namespace was introduced
for `require()` expressions in Node v16.0.0, and backported to v14.18.0.
This was never supported in Node v15.x or chronologically older.

All of the current API history notes in the docs using 'node:' prefixed
module `require()`s happen to be documenting changes in Node versions
from before the time when support was first introduced.

This commit reverts those `require()`s in the history notes to be
un-prefixed. (They were incorrect as written; The prefixed `require()`s
would not work for those older Node versions.)

This change prevents the API history notes from inaccurately implying
'node:' prefixed builtin modules were introduced many Node versions ago,
or were `require()`-able with the 'node:' prefix in those Node versions.

Refs: #35387
Refs: #37246
Refs: #42752

PR-URL: #43768
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
guangwong pushed a commit to noslate-project/node that referenced this pull request Oct 10, 2022
Support for the 'node:' prefixed builtin module namespace was introduced
for `require()` expressions in Node v16.0.0, and backported to v14.18.0.
This was never supported in Node v15.x or chronologically older.

All of the current API history notes in the docs using 'node:' prefixed
module `require()`s happen to be documenting changes in Node versions
from before the time when support was first introduced.

This commit reverts those `require()`s in the history notes to be
un-prefixed. (They were incorrect as written; The prefixed `require()`s
would not work for those older Node versions.)

This change prevents the API history notes from inaccurately implying
'node:' prefixed builtin modules were introduced many Node versions ago,
or were `require()`-able with the 'node:' prefix in those Node versions.

Refs: nodejs/node#35387
Refs: nodejs/node#37246
Refs: nodejs/node#42752

PR-URL: nodejs/node#43768
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. esm Issues and PRs related to the ECMAScript Modules implementation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants