Skip to content

Commit 188cbc6

Browse files
bmeckitaloacasas
authored andcommitted
doc: package main can be directory with an index
This behavior dates back to 2011 but was not documented. PR-URL: #11581 Reviewed-By: Bradley Farias <[email protected]> Reviewed-By: James Snell <[email protected]>
1 parent a20aa0e commit 188cbc6

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

doc/api/modules.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,18 @@ LOAD_AS_FILE(X)
161161
3. If X.json is a file, parse X.json to a JavaScript Object. STOP
162162
4. If X.node is a file, load X.node as binary addon. STOP
163163
164+
LOAD_INDEX(X)
165+
1. If X/index.js is a file, load X/index.js as JavaScript text. STOP
166+
2. If X/index.json is a file, parse X/index.json to a JavaScript object. STOP
167+
3. If X/index.node is a file, load X/index.node as binary addon. STOP
168+
164169
LOAD_AS_DIRECTORY(X)
165170
1. If X/package.json is a file,
166171
a. Parse X/package.json, and look for "main" field.
167172
b. let M = X + (json main field)
168173
c. LOAD_AS_FILE(M)
169-
2. If X/index.js is a file, load X/index.js as JavaScript text. STOP
170-
3. If X/index.json is a file, parse X/index.json to a JavaScript object. STOP
171-
4. If X/index.node is a file, load X/index.node as binary addon. STOP
174+
d. LOAD_INDEX(M)
175+
2. LOAD_INDEX(X)
172176
173177
LOAD_NODE_MODULES(X, START)
174178
1. let DIRS=NODE_MODULES_PATHS(START)

0 commit comments

Comments
 (0)