Skip to content

Commit e2a2bab

Browse files
ugultopudanielleadams
authored andcommitted
doc: link PACKAGE_EXPORTS_RESOLVE to ESM section
Linked PACKAGE_EXPORTS_RESOLVE to "Resolver Algorithm Specification" in "ECMAScript modules" page, so that the `require` pseudocode is easier to understand. PR-URL: #37135 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 3db1b30 commit e2a2bab

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

doc/api/modules.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ the `require.resolve()` function.
148148
Putting together all of the above, here is the high-level algorithm
149149
in pseudocode of what `require()` does:
150150

151-
```text
151+
<pre>
152152
require(X) from module at path Y
153153
1. If X is a core module,
154154
a. return the core module
@@ -210,7 +210,7 @@ LOAD_PACKAGE_IMPORTS(X, DIR)
210210
2. If no scope was found, return.
211211
3. If the SCOPE/package.json "imports" is null or undefined, return.
212212
4. let MATCH = PACKAGE_IMPORTS_RESOLVE(X, pathToFileURL(SCOPE),
213-
["node", "require"]) defined in the ESM resolver.
213+
["node", "require"]) <a href="esm.md#resolver-algorithm-specification">defined in the ESM resolver</a>.
214214
5. RESOLVE_ESM_MATCH(MATCH).
215215

216216
LOAD_PACKAGE_EXPORTS(X, DIR)
@@ -221,7 +221,7 @@ LOAD_PACKAGE_EXPORTS(X, DIR)
221221
3. Parse DIR/NAME/package.json, and look for "exports" field.
222222
4. If "exports" is null or undefined, return.
223223
5. let MATCH = PACKAGE_EXPORTS_RESOLVE(pathToFileURL(DIR/NAME), "." + SUBPATH,
224-
`package.json` "exports", ["node", "require"]) defined in the ESM resolver.
224+
`package.json` "exports", ["node", "require"]) <a href="esm.md#resolver-algorithm-specification">defined in the ESM resolver</a>.
225225
6. RESOLVE_ESM_MATCH(MATCH)
226226

227227
LOAD_PACKAGE_SELF(X, DIR)
@@ -231,7 +231,7 @@ LOAD_PACKAGE_SELF(X, DIR)
231231
4. If the SCOPE/package.json "name" is not the first segment of X, return.
232232
5. let MATCH = PACKAGE_EXPORTS_RESOLVE(pathToFileURL(SCOPE),
233233
"." + X.slice("name".length), `package.json` "exports", ["node", "require"])
234-
defined in the ESM resolver.
234+
<a href="esm.md#resolver-algorithm-specification">defined in the ESM resolver</a>.
235235
6. RESOLVE_ESM_MATCH(MATCH)
236236

237237
RESOLVE_ESM_MATCH(MATCH)
@@ -244,7 +244,7 @@ RESOLVE_ESM_MATCH(MATCH)
244244
a. LOAD_AS_FILE(RESOLVED_PATH)
245245
b. LOAD_AS_DIRECTORY(RESOLVED_PATH)
246246
5. THROW "not found"
247-
```
247+
</pre>
248248

249249
## Caching
250250

0 commit comments

Comments
 (0)