@@ -45,7 +45,7 @@ Expect major changes in the implementation including interoperability support,
45
45
specifier resolution, and default behavior.
46
46
47
47
<!-- Anchors to make sure old links find a target -->
48
- <i id =" #esm_package_json_type_field " ></i >
48
+ <i id =" #esm_packages_type_field " ></i >
49
49
<i id =" #esm_package_scope_and_file_extensions " ></i >
50
50
<i id =" #esm_input_type_flag " ></i >
51
51
@@ -55,7 +55,7 @@ specifier resolution, and default behavior.
55
55
56
56
Node.js treats JavaScript code as CommonJS modules by default.
57
57
Authors can tell Node.js to treat JavaScript code as ECMAScript modules
58
- via the ` .mjs ` file extension, the ` package.json ` ` "type" ` field, or the
58
+ via the ` .mjs ` file extension, the ` package.json ` [ ` "type" ` ] [ ] field, or the
59
59
` --input-type ` flag. See
60
60
[ Modules: Packages] ( packages.html#packages_determining_module_system ) for more
61
61
details.
@@ -253,9 +253,9 @@ can either be an URL-style relative path like `'./file.mjs'` or a package name
253
253
like ` ' fs' ` .
254
254
255
255
Like in CommonJS, files within packages can be accessed by appending a path to
256
- the package name; unless the package’s ` package.json` contains an ` " exports " `
257
- field, in which case files within packages need to be accessed via the path
258
- defined in ` " exports" ` .
256
+ the package name; unless the package’s [ ` package.json` ][] contains an
257
+ [ ` " exports " ` ][] field, in which case files within packages need to be accessed
258
+ via the path defined in [ ` " exports" ` ][] .
259
259
260
260
` ` ` js
261
261
import { sin , cos } from ' geometry/trigonometry-functions.mjs' ;
@@ -933,7 +933,7 @@ The resolver can throw the following errors:
933
933
> 1. If the folder at _packageURL_ does not exist, then
934
934
> 1. Set _parentURL_ to the parent URL path of _parentURL_.
935
935
> 1. Continue the next loop iteration.
936
- > 1. Let _pjson_ be the result of ** READ_PACKAGE_JSON ** (_packageURL_).
936
+ > 1. Let _pjson_ be the result of ** READ_packages ** (_packageURL_).
937
937
> 1. If _pjson_ is not ** null ** and _pjson_ ._exports_ is not ** null ** or
938
938
> ** undefined ** , then
939
939
> 1. Let _exports_ be _pjson .exports_ .
@@ -953,7 +953,7 @@ The resolver can throw the following errors:
953
953
> 1. Let _packageURL_ be the result of ** READ_PACKAGE_SCOPE ** (_parentURL_).
954
954
> 1. If _packageURL_ is ** null ** , then
955
955
> 1. Return ** undefined ** .
956
- > 1. Let _pjson_ be the result of ** READ_PACKAGE_JSON ** (_packageURL_).
956
+ > 1. Let _pjson_ be the result of ** READ_packages ** (_packageURL_).
957
957
> 1. If _pjson_ is ** null ** or if _pjson_ ._exports_ is ** null ** or
958
958
> ** undefined ** , then
959
959
> 1. Return ** undefined ** .
@@ -995,7 +995,7 @@ The resolver can throw the following errors:
995
995
> 1. Throw an _Invalid Module Specifier_ error.
996
996
> 1. Let _packageURL_ be the result of ** READ_PACKAGE_SCOPE ** (_parentURL_).
997
997
> 1. If _packageURL_ is not ** null ** , then
998
- > 1. Let _pjson_ be the result of ** READ_PACKAGE_JSON ** (_packageURL_).
998
+ > 1. Let _pjson_ be the result of ** READ_packages ** (_packageURL_).
999
999
> 1. If _pjson .imports_ is a non- null Object , then
1000
1000
> 1. Let _resolvedMatch_ be the result of
1001
1001
> ** PACKAGE_IMPORTS_EXPORTS_RESOLVE ** (_specifier_, _pjson .imports_ ,
@@ -1091,12 +1091,12 @@ _conditions_)
1091
1091
> 1. While _scopeURL_ is not the file system root,
1092
1092
> 1. Set _scopeURL_ to the parent URL of _scopeURL_.
1093
1093
> 1. If _scopeURL_ ends in a _" node_modules" _ path segment, return ** null ** .
1094
- > 1. Let _pjson_ be the result of ** READ_PACKAGE_JSON ** (_scopeURL_).
1094
+ > 1. Let _pjson_ be the result of ** READ_packages ** (_scopeURL_).
1095
1095
> 1. If _pjson_ is not ** null ** , then
1096
1096
> 1. Return _pjson_.
1097
1097
> 1. Return ** null ** .
1098
1098
1099
- ** READ_PACKAGE_JSON ** (_packageURL_)
1099
+ ** READ_packages ** (_packageURL_)
1100
1100
1101
1101
> 1. Let _pjsonURL_ be the resolution of _" package.json" _ within _packageURL_.
1102
1102
> 1. If the file at _pjsonURL_ does not exist, then
@@ -1159,3 +1159,6 @@ success!
1159
1159
[6.1 .7 Array Index ]: https: // tc39.es/ecma262/#integer-index
1160
1160
[Top- Level Await]: https: // github.com/tc39/proposal-top-level-await
1161
1161
[Core modules]: modules .html #modules_core_modules
1162
+ [` package.json` ]: packages .html #packages_package_json_supported_fields
1163
+ [` "exports"` ]: packages .html #packages_exports
1164
+ [` "type"` ]: packages .html #packages_type
0 commit comments