Skip to content

Commit f6b641d

Browse files
committed
doc: correct esm spec package scope lookup definition
1 parent f0dcac8 commit f6b641d

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
@@ -1138,7 +1138,7 @@ The resolver can throw the following errors:
11381138

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

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

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

1309-
**READ\_PACKAGE\_SCOPE**(_url_)
1310+
**LOOKUP\_PACKAGE\_SCOPE**(_url_)
13101311

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

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

0 commit comments

Comments
 (0)