FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

doc: fix some errors in esm resolution algorithms by chjj · Pull Request #50898 · nodejs/node · GitHub

/ node Public

doc: fix some errors in esm resolution algorithms - #50898

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
chjj:fix-esm-docs
Nov 29, 2023
Merged

doc: fix some errors in esm resolution algorithms#50898
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
chjj:fix-esm-docs

Conversation

chjj commented Nov 24, 2023

Copy link
Copy Markdown
Contributor

Two errors I discovered when implementing the ESM resolution algorithm from scratch.

  1. PACKAGE_EXPORTS_RESOLVE - subpath is already prefixed with ./ due to the calling functions ensuring this.
  2. PACKAGE_TARGET_RESOLVE - A simple typo here. Order should be reversed.

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/loaders

nodejs-github-bot added doc Issues and PRs related to the documentations. esm Issues and PRs related to the ECMAScript Modules implementation. labels Nov 24, 2023

Copy link
Copy Markdown
Member

implementing the ESM resolution algorithm from scratch.

We've been meaning to expose this logic in a helper function. Is that something you'd be interested in implementing?

aduh95 added author ready PRs that have at least one approval, no outstanding review comments, and a CI started. commit-queue Add this label to land a pull request using GitHub Actions. labels Nov 24, 2023

chjj commented Nov 24, 2023

Copy link
Copy Markdown
Contributor Author

@GeoffreyBooth, I don't know if I'd have the time to maintain a pure reference implementation, but my implementation here might be a good starting point for someone. Aside from using paths instead of URLs, it follows the documented algorithms as closely as possible.

chjj commented Nov 24, 2023

Copy link
Copy Markdown
Contributor Author

Force pushed another typo I forgot about. PACKAGE_TARGET_RESOLVE 2.1 should say target instead of exports.

Section 3.3 of the same function also has confusing wording (I had to check the node.js code to implement it properly). I need to consider how to reword it though.

Copy link
Copy Markdown
Member

I just meant exposing ours, like import { defaultResolve } from 'node:module'.

nodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Nov 26, 2023

Copy link
Copy Markdown
Collaborator
Commit Queue failed
- Loading data for nodejs/node/pull/50898
✔  Done loading data for nodejs/node/pull/50898
----------------------------------- PR info ------------------------------------
Title      doc: fix some errors in esm resolution algorithms (#50898)
Author     Christopher Jeffrey (JJ)  (@chjj)
Branch     chjj:fix-esm-docs -> nodejs:main
Labels     doc, esm, author ready
Commits    1
 - doc: fix some errors in esm resolution algorithms
Committers 1
 - Christopher Jeffrey 
PR-URL: https://github.com/nodejs/node/pull/50898
Reviewed-By: Guy Bedford 
Reviewed-By: Geoffrey Booth 
Reviewed-By: Luigi Pinca 
Reviewed-By: Antoine du Hamel 
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/50898
Reviewed-By: Guy Bedford 
Reviewed-By: Geoffrey Booth 
Reviewed-By: Luigi Pinca 
Reviewed-By: Antoine du Hamel 
--------------------------------------------------------------------------------
   ⚠  Commits were pushed since the last approving review:
   ⚠  - doc: fix some errors in esm resolution algorithms
   ℹ  This PR was created on Fri, 24 Nov 2023 17:13:06 GMT
   ✔  Approvals: 4
   ✔  - Guy Bedford (@guybedford): https://github.com/nodejs/node/pull/50898#pullrequestreview-1748266109
   ✔  - Geoffrey Booth (@GeoffreyBooth) (TSC): https://github.com/nodejs/node/pull/50898#pullrequestreview-1748269208
   ✔  - Luigi Pinca (@lpinca): https://github.com/nodejs/node/pull/50898#pullrequestreview-1748269330
   ✔  - Antoine du Hamel (@aduh95) (TSC): https://github.com/nodejs/node/pull/50898#pullrequestreview-1748269950
   ✔  Last GitHub CI successful
   ℹ  Green GitHub CI is sufficient
--------------------------------------------------------------------------------
   ✔  Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/6996996694

chjj commented Nov 29, 2023

Copy link
Copy Markdown
Contributor Author

@GeoffreyBooth, isn't this already going to be more-or-less exposed once import.meta.resolve accepts a parentURL?

I suppose CJS modules could access it if it were part of node:module?

aduh95 added commit-queue Add this label to land a pull request using GitHub Actions. and removed commit-queue-failed An error occurred while landing this pull request using GitHub Actions. labels Nov 29, 2023
nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Nov 29, 2023
nodejs-github-bot merged commit 59f57d2 into nodejs:main Nov 29, 2023

Copy link
Copy Markdown
Collaborator

Landed in 59f57d2

targos pushed a commit that referenced this pull request Dec 4, 2023
PR-URL: #50898
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
targos mentioned this pull request Dec 4, 2023
richardlau pushed a commit that referenced this pull request Mar 25, 2024
PR-URL: #50898
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
richardlau mentioned this pull request Mar 25, 2024
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 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 outstanding review comments, and a CI started. doc Issues and PRs related to the documentations. esm Issues and PRs related to the ECMAScript Modules implementation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants


Back | FazBrowse Home | New Git URL