Skip to content

Commit 5c90975

Browse files
guybedforddanielleadams
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 e7391ea commit 5c90975

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

doc/api/esm.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,7 @@ The resolver can throw the following errors:
11291129

11301130
**PACKAGE\_SELF\_RESOLVE**(_packageName_, _packageSubpath_, _parentURL_)
11311131

1132-
> 1. Let _packageURL_ be the result of **READ\_PACKAGE\_SCOPE**(_parentURL_).
1132+
> 1. Let _packageURL_ be the result of **LOOKUP\_PACKAGE\_SCOPE**(_parentURL_).
11331133
> 2. If _packageURL_ is **null**, then
11341134
> 1. Return **undefined**.
11351135
> 3. Let _pjson_ be the result of **READ\_PACKAGE\_JSON**(_packageURL_).
@@ -1173,7 +1173,7 @@ The resolver can throw the following errors:
11731173
> 1. Assert: _specifier_ begins with _"#"_.
11741174
> 2. If _specifier_ is exactly equal to _"#"_ or starts with _"#/"_, then
11751175
> 1. Throw an _Invalid Module Specifier_ error.
1176-
> 3. Let _packageURL_ be the result of **READ\_PACKAGE\_SCOPE**(_parentURL_).
1176+
> 3. Let _packageURL_ be the result of **LOOKUP\_PACKAGE\_SCOPE**(_parentURL_).
11771177
> 4. If _packageURL_ is not **null**, then
11781178
> 1. Let _pjson_ be the result of **READ\_PACKAGE\_JSON**(_packageURL_).
11791179
> 2. If _pjson.imports_ is a non-null Object, then
@@ -1304,29 +1304,31 @@ _internal_, _conditions_)
13041304
**ESM\_FILE\_FORMAT**(_url_)
13051305

13061306
> 1. Assert: _url_ corresponds to an existing file.
1307-
> 2. Let _pjson_ be the result of **READ\_PACKAGE\_SCOPE**(_url_).
1308-
> 3. If _url_ ends in _".mjs"_, then
1307+
> 2. If _url_ ends in _".mjs"_, then
13091308
> 1. Return _"module"_.
1310-
> 4. If _url_ ends in _".cjs"_, then
1309+
> 3. If _url_ ends in _".cjs"_, then
13111310
> 1. Return _"commonjs"_.
1312-
> 5. If _url_ ends in _".json"_, then
1311+
> 4. If _url_ ends in _".json"_, then
13131312
> 1. Return _"json"_.
1314-
> 6. If _pjson?.type_ exists and is _"module"_, then
1313+
> 5. Let _packageURL_ be the result of **LOOKUP\_PACKAGE\_SCOPE**(_url_).
1314+
> 6. Let _pjson_ be the result of **READ\_PACKAGE\_JSON**(_packageURL_).
1315+
> 7. If _pjson?.type_ exists and is _"module"_, then
13151316
> 1. If _url_ ends in _".js"_, then
13161317
> 1. Return _"module"_.
13171318
> 2. Throw an _Unsupported File Extension_ error.
1318-
> 7. Otherwise,
1319+
> 8. Otherwise,
13191320
> 1. Throw an _Unsupported File Extension_ error.
13201321

1321-
**READ\_PACKAGE\_SCOPE**(_url_)
1322+
**LOOKUP\_PACKAGE\_SCOPE**(_url_)
13221323

13231324
> 1. Let _scopeURL_ be _url_.
13241325
> 2. While _scopeURL_ is not the file system root,
13251326
> 1. Set _scopeURL_ to the parent URL of _scopeURL_.
13261327
> 2. If _scopeURL_ ends in a _"node\_modules"_ path segment, return **null**.
1327-
> 3. Let _pjson_ be the result of **READ\_PACKAGE\_JSON**(_scopeURL_).
1328-
> 4. If _pjson_ is not **null**, then
1329-
> 1. Return _pjson_.
1328+
> 3. Let _pjsonURL_ be the resolution of _"package.json"_ within
1329+
> _packageURL_.
1330+
> 4. if the file at _pjsonURL_ exists, then
1331+
> 1. Return _scopeURL_.
13301332
> 3. Return **null**.
13311333

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

0 commit comments

Comments
 (0)