From 188cbc6eeaf5f1180780646da0990c44d094d78a Mon Sep 17 00:00:00 2001 From: Bradley Farias Date: Mon, 27 Feb 2017 12:01:18 -0600 Subject: [PATCH] doc: package main can be directory with an index This behavior dates back to 2011 but was not documented. PR-URL: https://github.com/nodejs/node/pull/11581 Reviewed-By: Bradley Farias Reviewed-By: James Snell --- doc/api/modules.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/doc/api/modules.md b/doc/api/modules.md index 973ee7ee8e03c5..a0c669f20956e8 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -161,14 +161,18 @@ LOAD_AS_FILE(X) 3. If X.json is a file, parse X.json to a JavaScript Object. STOP 4. If X.node is a file, load X.node as binary addon. STOP +LOAD_INDEX(X) +1. If X/index.js is a file, load X/index.js as JavaScript text. STOP +2. If X/index.json is a file, parse X/index.json to a JavaScript object. STOP +3. If X/index.node is a file, load X/index.node as binary addon. STOP + LOAD_AS_DIRECTORY(X) 1. If X/package.json is a file, a. Parse X/package.json, and look for "main" field. b. let M = X + (json main field) c. LOAD_AS_FILE(M) -2. If X/index.js is a file, load X/index.js as JavaScript text. STOP -3. If X/index.json is a file, parse X/index.json to a JavaScript object. STOP -4. If X/index.node is a file, load X/index.node as binary addon. STOP + d. LOAD_INDEX(M) +2. LOAD_INDEX(X) LOAD_NODE_MODULES(X, START) 1. let DIRS=NODE_MODULES_PATHS(START)