Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6ae134e

Browse filesBrowse files
guybedfordtargos
authored andcommitted
doc: correct esm spec scope lookup definition
PR-URL: #40592 Fixes: #40578 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
1 parent 0923921 commit 6ae134e
Copy full SHA for 6ae134e

File tree

Expand file treeCollapse file tree

1 file changed

+14
-12
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+14
-12
lines changed
Open diff view settings
Collapse file

‎doc/api/esm.md‎

Copy file name to clipboardExpand all lines: doc/api/esm.md
+14-12Lines changed: 14 additions & 12 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1137,7 +1137,7 @@ The resolver can throw the following errors:
11371137

11381138
**PACKAGE\_SELF\_RESOLVE**(_packageName_, _packageSubpath_, _parentURL_)
11391139

1140-
> 1. Let _packageURL_ be the result of **READ\_PACKAGE\_SCOPE**(_parentURL_).
1140+
> 1. Let _packageURL_ be the result of **LOOKUP\_PACKAGE\_SCOPE**(_parentURL_).
11411141
> 2. If _packageURL_ is **null**, then
11421142
> 1. Return **undefined**.
11431143
> 3. Let _pjson_ be the result of **READ\_PACKAGE\_JSON**(_packageURL_).
@@ -1178,7 +1178,7 @@ The resolver can throw the following errors:
11781178
> 1. Assert: _specifier_ begins with _"#"_.
11791179
> 2. If _specifier_ is exactly equal to _"#"_ or starts with _"#/"_, then
11801180
> 1. Throw an _Invalid Module Specifier_ error.
1181-
> 3. Let _packageURL_ be the result of **READ\_PACKAGE\_SCOPE**(_parentURL_).
1181+
> 3. Let _packageURL_ be the result of **LOOKUP\_PACKAGE\_SCOPE**(_parentURL_).
11821182
> 4. If _packageURL_ is not **null**, then
11831183
> 1. Let _pjson_ be the result of **READ\_PACKAGE\_JSON**(_packageURL_).
11841184
> 2. If _pjson.imports_ is a non-null Object, then
@@ -1291,29 +1291,31 @@ _internal_, _conditions_)
12911291
**ESM\_FILE\_FORMAT**(_url_)
12921292

12931293
> 1. Assert: _url_ corresponds to an existing file.
1294-
> 2. Let _pjson_ be the result of **READ\_PACKAGE\_SCOPE**(_url_).
1295-
> 3. If _url_ ends in _".mjs"_, then
1294+
> 2. If _url_ ends in _".mjs"_, then
12961295
> 1. Return _"module"_.
1297-
> 4. If _url_ ends in _".cjs"_, then
1296+
> 3. If _url_ ends in _".cjs"_, then
12981297
> 1. Return _"commonjs"_.
1299-
> 5. If _url_ ends in _".json"_, then
1298+
> 4. If _url_ ends in _".json"_, then
13001299
> 1. Return _"json"_.
1301-
> 6. If _pjson?.type_ exists and is _"module"_, then
1300+
> 5. Let _packageURL_ be the result of **LOOKUP\_PACKAGE\_SCOPE**(_url_).
1301+
> 6. Let _pjson_ be the result of **READ\_PACKAGE\_JSON**(_packageURL_).
1302+
> 7. If _pjson?.type_ exists and is _"module"_, then
13021303
> 1. If _url_ ends in _".js"_, then
13031304
> 1. Return _"module"_.
13041305
> 2. Throw an _Unsupported File Extension_ error.
1305-
> 7. Otherwise,
1306+
> 8. Otherwise,
13061307
> 1. Throw an _Unsupported File Extension_ error.
13071308

1308-
**READ\_PACKAGE\_SCOPE**(_url_)
1309+
**LOOKUP\_PACKAGE\_SCOPE**(_url_)
13091310

13101311
> 1. Let _scopeURL_ be _url_.
13111312
> 2. While _scopeURL_ is not the file system root,
13121313
> 1. Set _scopeURL_ to the parent URL of _scopeURL_.
13131314
> 2. If _scopeURL_ ends in a _"node\_modules"_ path segment, return **null**.
1314-
> 3. Let _pjson_ be the result of **READ\_PACKAGE\_JSON**(_scopeURL_).
1315-
> 4. If _pjson_ is not **null**, then
1316-
> 1. Return _pjson_.
1315+
> 3. Let _pjsonURL_ be the resolution of _"package.json"_ within
1316+
> _packageURL_.
1317+
> 4. if the file at _pjsonURL_ exists, then
1318+
> 1. Return _scopeURL_.
13171319
> 3. Return **null**.
13181320

13191321
**READ\_PACKAGE\_JSON**(_packageURL_)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.