From 721ca13a22426fe5da9769ad992f705a8699a8b3 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Thu, 16 Nov 2017 16:33:39 -0500 Subject: [PATCH 01/53] chore(package): update mocha to version 4.0.1 (#34) Closes #33 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8cf9e71..24aabbf 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ }, "devDependencies": { "docco": "^0.7.0", - "mocha": "^3.2.0", + "mocha": "^4.0.1", "uglify-js": "^3.0.12", "reify": "^0.11.20" }, From 9b45cf00de207625153efc4bfcd623c40c5bc9c9 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Thu, 16 Nov 2017 16:33:58 -0500 Subject: [PATCH 02/53] chore(package): update reify to version 0.12.3 (#35) Closes #32 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 24aabbf..00f1bb3 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "docco": "^0.7.0", "mocha": "^4.0.1", "uglify-js": "^3.0.12", - "reify": "^0.11.20" + "reify": "^0.12.3" }, "license": "MIT", "engines": { From 29bab8a9d1e6facf7615c4c138406e8eba9dab00 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Mon, 11 Sep 2017 18:15:17 -0400 Subject: [PATCH 03/53] Reverse order of isObject conjunction clauses. --- install.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.js b/install.js index cd057ec..122f48a 100644 --- a/install.js +++ b/install.js @@ -189,7 +189,7 @@ makeInstaller = function (options) { } function isObject(value) { - return typeof value === "object" && value !== null; + return value !== null && typeof value === "object"; } function isFunction(value) { From be2cd976731c0ed6f3ac1cf1ad29b6e00a4ab00d Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Mon, 11 Sep 2017 18:27:07 -0400 Subject: [PATCH 04/53] Remove unnecessary conditional. --- install.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.js b/install.js index 122f48a..e89a147 100644 --- a/install.js +++ b/install.js @@ -166,7 +166,7 @@ makeInstaller = function (options) { ).then(function (tree) { function both() { - if (tree) install(tree); + install(tree); return absChildId; } From 1c80ac7643466fb84257542046e3769646024dcd Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Tue, 12 Sep 2017 22:06:54 -0400 Subject: [PATCH 05/53] Use a stricter version of Object.prototype.hasOwnProperty. --- install.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/install.js b/install.js index e89a147..b788ddd 100644 --- a/install.js +++ b/install.js @@ -40,8 +40,10 @@ makeInstaller = function (options) { // might make sense to support the object version, a la browserify. (options.browser ? ["browser", "main"] : ["main"]); - // Called below as hasOwn.call(obj, key). var hasOwn = {}.hasOwnProperty; + function strictHasOwn(obj, key) { + return isObject(obj) && isString(key) && hasOwn.call(obj, key); + } // Cache for looking up File objects given absolute module identifiers. // Invariants: @@ -185,7 +187,7 @@ makeInstaller = function (options) { install.Module = Module; function getOwn(obj, key) { - return hasOwn.call(obj, key) && obj[key]; + return strictHasOwn(obj, key) && obj[key]; } function isObject(value) { @@ -284,7 +286,7 @@ makeInstaller = function (options) { function fileEvaluate(file, parentModule) { var module = file.module; - if (! hasOwn.call(module, "exports")) { + if (! strictHasOwn(module, "exports")) { var contents = file.contents; if (! contents) { // If this file was installed with array notation, and the array From 8733c6822b501a24d0e550e3da620868b430fc3c Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Thu, 16 Nov 2017 16:36:52 -0500 Subject: [PATCH 06/53] Add a package-lock.json file for reproducible installs. --- package-lock.json | 321 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 321 insertions(+) create mode 100644 package-lock.json diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..b7d3489 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,321 @@ +{ + "name": "install", + "version": "0.10.1", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "acorn": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.1.2.tgz", + "integrity": "sha512-o96FZLJBPY1lvTuJylGA9Bk3t/GKPPJG8H0ydQQl01crzwJgspa4AEIq/pVTXigmK0PHVQhiAtn8WMBLL9D2WA==", + "dev": true + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "brace-expansion": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", + "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", + "dev": true, + "requires": { + "balanced-match": "1.0.0", + "concat-map": "0.0.1" + } + }, + "browser-stdout": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.0.tgz", + "integrity": "sha1-81HTKWnTL6XXpVZxVCY9korjvR8=", + "dev": true + }, + "commander": { + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", + "integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "diff": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.3.1.tgz", + "integrity": "sha512-MKPHZDMB0o6yHyDryUOScqZibp914ksXwAMYMTHj6KO8UeKsRYNJD3oNCKjTqZon+V488P7N/HzXF8t7ZR95ww==", + "dev": true + }, + "docco": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/docco/-/docco-0.7.0.tgz", + "integrity": "sha1-1gblqZDLoFLKHhgDqcWH7O48XDg=", + "dev": true, + "requires": { + "commander": "2.11.0", + "fs-extra": "4.0.2", + "highlight.js": "9.12.0", + "marked": "0.3.6", + "underscore": "1.8.3" + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "fs-extra": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.2.tgz", + "integrity": "sha1-+RcExT0bRh+JNFKwwwfZmXZHq2s=", + "dev": true, + "requires": { + "graceful-fs": "4.1.11", + "jsonfile": "4.0.0", + "universalify": "0.1.1" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + }, + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "dev": true + }, + "growl": { + "version": "1.10.3", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", + "dev": true + }, + "has-flag": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", + "dev": true + }, + "he": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "dev": true + }, + "highlight.js": { + "version": "9.12.0", + "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-9.12.0.tgz", + "integrity": "sha1-5tnb5Xy+/mB1HwKvM2GVhwyQwB4=", + "dev": true + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "1.4.0", + "wrappy": "1.0.2" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "dev": true, + "requires": { + "graceful-fs": "4.1.11" + } + }, + "marked": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.6.tgz", + "integrity": "sha1-ssbGGPzOzk74bE/Gy4p8v1rtqNc=", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "1.1.8" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + }, + "minipass": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.2.1.tgz", + "integrity": "sha512-u1aUllxPJUI07cOqzR7reGmQxmCqlH88uIIsf6XZFEWgw7gXKpJdR+5R9Y3KEDmWYkdIz9wXZs3C0jOPxejk/Q==", + "dev": true, + "requires": { + "yallist": "3.0.2" + } + }, + "minizlib": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.0.4.tgz", + "integrity": "sha512-sN4U9tIJtBRwKbwgFh9qJfrPIQ/GGTRr1MGqkgOeMTLy8/lM0FcWU//FqlnZ3Vb7gJ+Mxh3FOg1EklibdajbaQ==", + "dev": true, + "requires": { + "minipass": "2.2.1" + } + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, + "mocha": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-4.0.1.tgz", + "integrity": "sha512-evDmhkoA+cBNiQQQdSKZa2b9+W2mpLoj50367lhy+Klnx9OV8XlCIhigUnn1gaTFLQCa0kdNhEGDr0hCXOQFDw==", + "dev": true, + "requires": { + "browser-stdout": "1.3.0", + "commander": "2.11.0", + "debug": "3.1.0", + "diff": "3.3.1", + "escape-string-regexp": "1.0.5", + "glob": "7.1.2", + "growl": "1.10.3", + "he": "1.1.1", + "mkdirp": "0.5.1", + "supports-color": "4.4.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1.0.2" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "reify": { + "version": "0.12.3", + "resolved": "https://registry.npmjs.org/reify/-/reify-0.12.3.tgz", + "integrity": "sha512-s13k0kuZbhBzeRoJQGomWnLj2y10wK3FYXRXbZoydowAMmY0jTiFN98TgLkaE8uZkVCaoq3djnDo7mksWLsx4g==", + "dev": true, + "requires": { + "acorn": "5.1.2", + "minizlib": "1.0.4", + "semver": "5.4.1" + } + }, + "semver": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz", + "integrity": "sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg==", + "dev": true + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + }, + "supports-color": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz", + "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==", + "dev": true, + "requires": { + "has-flag": "2.0.0" + } + }, + "uglify-js": { + "version": "3.1.9", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.1.9.tgz", + "integrity": "sha512-ari2E89bD7f+fMU173NgF12JBcOhgoxeyuCs97h5K58IBENrnG9eVj2lFadrOPdqf0KifsxVmUQfzA2cHNxCZQ==", + "dev": true, + "requires": { + "commander": "2.11.0", + "source-map": "0.6.1" + } + }, + "underscore": { + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz", + "integrity": "sha1-Tz+1OxBuYJf8+ctBCfKl6b36UCI=", + "dev": true + }, + "universalify": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.1.tgz", + "integrity": "sha1-+nG63UQ3r0wUiEHjs7Fl+enlkLc=", + "dev": true + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, + "yallist": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.2.tgz", + "integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=", + "dev": true + } + } +} From b8e62ae078b373d421145156e17a80caed181758 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Thu, 16 Nov 2017 17:19:45 -0500 Subject: [PATCH 07/53] Batch multiple calls to module.prefetch into one install.fetch call. By sharing the missing object across multiple calls to module.prefetch, and waiting until the next tick to call install.fetch, we can batch a rapid succession of module.prefetch calls into a single call to the install.fetch callback, potentially resulting in fewer HTTP requests. --- install.js | 20 +++++++++++++------ test/run.js | 57 ++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 53 insertions(+), 24 deletions(-) diff --git a/install.js b/install.js index b788ddd..ea818bb 100644 --- a/install.js +++ b/install.js @@ -96,16 +96,18 @@ makeInstaller = function (options) { return this.require.resolve(id); }; - var resolvedPromise; + // Used to keep module.prefetch promise resolutions well-ordered. var lastPrefetchPromise; + // May be shared by multiple sequential calls to module.prefetch. + // Initialized to {} only when necessary. + var missing; + Module.prototype.prefetch = function (id) { var module = this; var parentFile = getOwn(filesByModuleId, module.id); - var missing; // Initialized to {} only if necessary. - resolvedPromise = resolvedPromise || Promise.resolve(); - lastPrefetchPromise = lastPrefetchPromise || resolvedPromise; + lastPrefetchPromise = lastPrefetchPromise || Promise.resolve(); var previousPromise = lastPrefetchPromise; function walk(module) { @@ -154,9 +156,15 @@ makeInstaller = function (options) { } } - return lastPrefetchPromise = resolvedPromise.then(function () { + return lastPrefetchPromise = new Promise(function (resolve) { var absChildId = module.resolve(id); each(module.childrenById, walk); + resolve(absChildId); + + }).then(function (absChildId) { + // Grab the current missing object and fetch its contents. + var toBeFetched = missing; + missing = null; return Promise.resolve( // The install.fetch function takes an object mapping missing @@ -164,7 +172,7 @@ makeInstaller = function (options) { // return a Promise that resolves to a module tree that can be // installed. As an optimization, if there were no missing dynamic // modules, then we can skip calling install.fetch entirely. - missing && install.fetch(missing) + toBeFetched && install.fetch(toBeFetched) ).then(function (tree) { function both() { diff --git a/test/run.js b/test/run.js index e36ec24..e7aef3c 100644 --- a/test/run.js +++ b/test/run.js @@ -1035,10 +1035,6 @@ describe("install", function () { it("enforces ordering of module.prefetch promise resolution", function () { var install = makeInstaller(); - var bResolve; - var bPromise = new Promise(function (resolve) { - bResolve = resolve; - }); function exportName(r, exports, module) { exports.name = module.id; @@ -1048,20 +1044,12 @@ describe("install", function () { // though module.prefetch is called in the other order. install.fetch = function (ids) { var keys = Object.keys(ids); - assert.strictEqual(keys.length, 1); - - if (keys[0] === "/a.js") { - return bPromise.then(function () { - return { "a.js": exportName }; - }); - } - - if (keys[0] === "/b.js") { - bResolve({ "b.js": exportName }); - return bPromise; - } - - throw new Error("unreached"); + assert.strictEqual(keys.length, 2); + var tree = {}; + keys.forEach(function (key) { + tree[key.split("/").pop()] = exportName; + }); + return tree; }; var require = install({ @@ -1087,6 +1075,39 @@ describe("install", function () { return require("./main"); }); + it("batches module.prefetch calls into one install.fetch call", function () { + var install = makeInstaller(); + var fetchCallCount = 0; + + install.fetch = function (ids) { + ++fetchCallCount; + assert.deepEqual(Object.keys(ids).sort(), [ + "/a.js", + "/b.js", + ]); + return {}; + }; + + var require = install({ + "main.js": function (require, exports, module) { + exports.promise = Promise.all([ + module.prefetch("./a"), + module.prefetch("./b") + ]); + }, + "a.js": [], + "b.js": [] + }); + + return require("./main").promise.then(function (ab) { + assert.strictEqual(fetchCallCount, 1); + assert.deepEqual(ab.sort(), [ + "/a.js", + "/b.js", + ]); + }); + }); + it("respects module.exports before file.contents", function () { var install = makeInstaller(); From 668ff6b6d1089fd7f9bd77ecf129c00c4dbedbc3 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Thu, 16 Nov 2017 17:22:08 -0500 Subject: [PATCH 08/53] Bump NPM version to 0.10.2 in preparation for publishing. --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index b7d3489..82ec70f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "install", - "version": "0.10.1", + "version": "0.10.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 00f1bb3..0cb4084 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "packager", "install" ], - "version": "0.10.1", + "version": "0.10.2", "license": "MIT", "homepage": "http://github.com/benjamn/install", "repository": { From 7f90133855b34af96892a0eb328ea16efa0dabdd Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Thu, 16 Nov 2017 17:23:16 -0500 Subject: [PATCH 09/53] Run Travis CI tests in Node 8 and 9, too. --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 21db349..732834e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,8 @@ language: node_js sudo: false node_js: + - "9" + - "8" - "7" - "6" - "5" From d16b781f4f783198b643fc28a8cc10669747b879 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Mon, 22 Jan 2018 10:38:39 -0500 Subject: [PATCH 10/53] chore(package): update mocha to version 5.0.0 (#38) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0cb4084..a245568 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ }, "devDependencies": { "docco": "^0.7.0", - "mocha": "^4.0.1", + "mocha": "^5.0.0", "uglify-js": "^3.0.12", "reify": "^0.12.3" }, From f18d0283c609b4b55907d08610d0ca1981fcce90 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Mon, 22 Jan 2018 10:39:31 -0500 Subject: [PATCH 11/53] chore(package): update docco to version 0.8.0 (#37) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a245568..9013493 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "test": "mocha --reporter spec --full-trace test/run.js" }, "devDependencies": { - "docco": "^0.7.0", + "docco": "^0.8.0", "mocha": "^5.0.0", "uglify-js": "^3.0.12", "reify": "^0.12.3" From 3d34a1f2d06d3f2f1cb1e1bddfb9e345d5ffc18d Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Mon, 22 Jan 2018 10:39:54 -0500 Subject: [PATCH 12/53] chore(package): update reify to version 0.13.7 (#39) Closes #36 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9013493..a252739 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "docco": "^0.8.0", "mocha": "^5.0.0", "uglify-js": "^3.0.12", - "reify": "^0.12.3" + "reify": "^0.13.7" }, "license": "MIT", "engines": { From 3f5df34b87a90d0570a7740449508eed55112cda Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Mon, 22 Jan 2018 10:40:38 -0500 Subject: [PATCH 13/53] Update package-lock.json. --- package-lock.json | 82 ++++++++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 37 deletions(-) diff --git a/package-lock.json b/package-lock.json index 82ec70f..3736099 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,9 +5,9 @@ "requires": true, "dependencies": { "acorn": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.1.2.tgz", - "integrity": "sha512-o96FZLJBPY1lvTuJylGA9Bk3t/GKPPJG8H0ydQQl01crzwJgspa4AEIq/pVTXigmK0PHVQhiAtn8WMBLL9D2WA==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.3.0.tgz", + "integrity": "sha512-Yej+zOJ1Dm/IMZzzj78OntP/r3zHEaKcyNoU2lAaxPtrseM6rF0xwqoz5Q5ysAiED9hTjI2hgtvLXitlCN1/Ug==", "dev": true }, "balanced-match": { @@ -33,9 +33,9 @@ "dev": true }, "commander": { - "version": "2.11.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", - "integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==", + "version": "2.13.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.13.0.tgz", + "integrity": "sha512-MVuS359B+YzaWqjCL/c+22gfryv+mCBPHAv3zyVI2GN8EY6IRP8VwtasXn8jyyhvvq84R4ImN1OKRtcbIasjYA==", "dev": true }, "concat-map": { @@ -60,15 +60,15 @@ "dev": true }, "docco": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/docco/-/docco-0.7.0.tgz", - "integrity": "sha1-1gblqZDLoFLKHhgDqcWH7O48XDg=", + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/docco/-/docco-0.8.0.tgz", + "integrity": "sha512-QcWBDnnGaT+rgC0wqynznXv0/4hd6nAFdWNs2fN4FvkH2yAnCYVeRU7GIZXNCeUQ955Lufq+TmZcSXiBa1cGQQ==", "dev": true, "requires": { - "commander": "2.11.0", - "fs-extra": "4.0.2", + "commander": "2.13.0", + "fs-extra": "5.0.0", "highlight.js": "9.12.0", - "marked": "0.3.6", + "marked": "0.3.12", "underscore": "1.8.3" } }, @@ -79,9 +79,9 @@ "dev": true }, "fs-extra": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.2.tgz", - "integrity": "sha1-+RcExT0bRh+JNFKwwwfZmXZHq2s=", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-5.0.0.tgz", + "integrity": "sha512-66Pm4RYbjzdyeuqudYqhFiNBbCIuI9kgRqLPSHIlXHidW8NIQtVdkM1yeZ4lXwuhbTETv3EUGMNHAAw6hiundQ==", "dev": true, "requires": { "graceful-fs": "4.1.11", @@ -165,9 +165,9 @@ } }, "marked": { - "version": "0.3.6", - "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.6.tgz", - "integrity": "sha1-ssbGGPzOzk74bE/Gy4p8v1rtqNc=", + "version": "0.3.12", + "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.12.tgz", + "integrity": "sha512-k4NaW+vS7ytQn6MgJn3fYpQt20/mOgYM5Ft9BYMfQJDz2QT6yEeS9XJ8k2Nw8JTeWK/znPPW2n3UJGzyYEiMoA==", "dev": true }, "minimatch": { @@ -195,9 +195,9 @@ } }, "minizlib": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.0.4.tgz", - "integrity": "sha512-sN4U9tIJtBRwKbwgFh9qJfrPIQ/GGTRr1MGqkgOeMTLy8/lM0FcWU//FqlnZ3Vb7gJ+Mxh3FOg1EklibdajbaQ==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.1.0.tgz", + "integrity": "sha512-4T6Ur/GctZ27nHfpt9THOdRZNgyJ9FZchYO1ceg5S8Q3DNLCKYy44nCZzgCJgcvx2UM8czmqak5BCxJMrq37lA==", "dev": true, "requires": { "minipass": "2.2.1" @@ -213,9 +213,9 @@ } }, "mocha": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-4.0.1.tgz", - "integrity": "sha512-evDmhkoA+cBNiQQQdSKZa2b9+W2mpLoj50367lhy+Klnx9OV8XlCIhigUnn1gaTFLQCa0kdNhEGDr0hCXOQFDw==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.0.0.tgz", + "integrity": "sha512-ukB2dF+u4aeJjc6IGtPNnJXfeby5d4ZqySlIBT0OEyva/DrMjVm5HkQxKnHDLKEfEQBsEnwTg9HHhtPHJdTd8w==", "dev": true, "requires": { "browser-stdout": "1.3.0", @@ -228,6 +228,14 @@ "he": "1.1.1", "mkdirp": "0.5.1", "supports-color": "4.4.0" + }, + "dependencies": { + "commander": { + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", + "integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==", + "dev": true + } } }, "ms": { @@ -252,20 +260,20 @@ "dev": true }, "reify": { - "version": "0.12.3", - "resolved": "https://registry.npmjs.org/reify/-/reify-0.12.3.tgz", - "integrity": "sha512-s13k0kuZbhBzeRoJQGomWnLj2y10wK3FYXRXbZoydowAMmY0jTiFN98TgLkaE8uZkVCaoq3djnDo7mksWLsx4g==", + "version": "0.13.7", + "resolved": "https://registry.npmjs.org/reify/-/reify-0.13.7.tgz", + "integrity": "sha512-jA6C/TdOf0g1A9WlQL7enh8yfGXgCmU3qbOpgc98vzRNEgu4TrAnSGec+uLxHdci96lftdBow3q0X3pbXnzmGQ==", "dev": true, "requires": { - "acorn": "5.1.2", - "minizlib": "1.0.4", - "semver": "5.4.1" + "acorn": "5.3.0", + "minizlib": "1.1.0", + "semver": "5.5.0" } }, "semver": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz", - "integrity": "sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg==", + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "source-map": { @@ -284,12 +292,12 @@ } }, "uglify-js": { - "version": "3.1.9", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.1.9.tgz", - "integrity": "sha512-ari2E89bD7f+fMU173NgF12JBcOhgoxeyuCs97h5K58IBENrnG9eVj2lFadrOPdqf0KifsxVmUQfzA2cHNxCZQ==", + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.3.8.tgz", + "integrity": "sha512-X0jAGtpSZRtd4RhbVNuGHyjZNa/h2MrVkKrR3Ew5iL2MJw6d7FmBke+fhVCALWySv1ygHnjjROG1KI1FAPvddw==", "dev": true, "requires": { - "commander": "2.11.0", + "commander": "2.13.0", "source-map": "0.6.1" } }, From 3d58d21fb5fb2c1b94831966c36226f6a0ef9691 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Mon, 22 Jan 2018 10:45:34 -0500 Subject: [PATCH 14/53] Switch to using docs/ directory on master for GitHub pages. --- docs/index.html | 1178 +++++++++++++++++++++++++++++++++++++++++++++ docs/install.html | 742 ---------------------------- scripts/docs.sh | 13 +- 3 files changed, 1180 insertions(+), 753 deletions(-) create mode 100644 docs/index.html delete mode 100644 docs/install.html diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 0000000..8cbf3d9 --- /dev/null +++ b/docs/index.html @@ -0,0 +1,1178 @@ + + + + + install.js + + + + + +
+
+ +
    + +
  • +
    +

    install.js

    +
    +
  • + + + +
  • +
    + +
    + +
    + +
    + +
    makeInstaller = function (options) {
    +  "use strict";
    +
    +  options = options || {};
    + +
  • + + +
  • +
    + +
    + +
    +

    These file extensions will be appended to required module identifiers +if they do not exactly match an installed module.

    + +
    + +
      var defaultExtensions = options.extensions || [".js", ".json"];
    + +
  • + + +
  • +
    + +
    + +
    +

    If defined, the options.onInstall function will be called any time +new modules are installed.

    + +
    + +
      var onInstall = options.onInstall;
    + +
  • + + +
  • +
    + +
    + +
    +

    If defined, each module-specific require function will be passed to +this function, along with the module object of the parent module, and +the result will be used in place of the original require function.

    + +
    + +
      var wrapRequire = options.wrapRequire;
    + +
  • + + +
  • +
    + +
    + +
    +

    If defined, the options.override function will be called before +looking up any top-level package identifiers in node_modules +directories. It can either return a string to provide an alternate +package identifier, or a non-string value to prevent the lookup from +proceeding.

    + +
    + +
      var override = options.override;
    + +
  • + + +
  • +
    + +
    + +
    +

    If defined, the options.fallback function will be called when no +installed module is found for a required module identifier. Often +options.fallback will be implemented in terms of the native Node +require function, which has the ability to load binary modules.

    + +
    + +
      var fallback = options.fallback;
    + +
  • + + +
  • +
    + +
    + +
    +

    List of fields to look for in package.json files to determine the +main entry module of the package. The first field listed here whose +value is a string will be used to resolve the entry module.

    + +
    + +
      var mainFields = options.mainFields ||
    + +
  • + + +
  • +
    + +
    + +
    +

    If options.mainFields is absent and options.browser is truthy, +package resolution will prefer the “browser” field of package.json +files to the “main” field. Note that this only supports +string-valued “browser” fields for now, though in the future it +might make sense to support the object version, a la browserify.

    + +
    + +
        (options.browser ? ["browser", "main"] : ["main"]);
    +
    +  var hasOwn = {}.hasOwnProperty;
    +  function strictHasOwn(obj, key) {
    +    return isObject(obj) && isString(key) && hasOwn.call(obj, key);
    +  }
    + +
  • + + +
  • +
    + +
    + +
    +

    Cache for looking up File objects given absolute module identifiers. +Invariants: + filesByModuleId[module.id] === fileAppendId(root, module.id) + filesByModuleId[module.id].module === module

    + +
    + +
      var filesByModuleId = {};
    + +
  • + + +
  • +
    + +
    + +
    +

    The file object representing the root directory of the installed +module tree.

    + +
    + +
      var root = new File("/", new File("/.."));
    +  var rootRequire = makeRequire(root);
    + +
  • + + +
  • +
    + +
    + +
    +

    Merges the given tree of directories and module factory functions +into the tree of installed modules and returns a require function +that behaves as if called from a module in the root directory.

    + +
    + +
      function install(tree, options) {
    +    if (isObject(tree)) {
    +      fileMergeContents(root, tree, options);
    +      if (isFunction(onInstall)) {
    +        onInstall(rootRequire);
    +      }
    +    }
    +    return rootRequire;
    +  }
    + +
  • + + +
  • +
    + +
    + +
    +

    Replace this function to enable Module.prototype.prefetch.

    + +
    + +
      install.fetch = function (ids) {
    +    throw new Error("fetch not implemented");
    +  };
    + +
  • + + +
  • +
    + +
    + +
    +

    This constructor will be used to instantiate the module objects +passed to module factory functions (i.e. the third argument after +require and exports), and is exposed as install.Module in case the +caller of makeInstaller wishes to modify Module.prototype.

    + +
    + +
      function Module(id) {
    +    this.id = id;
    + +
  • + + +
  • +
    + +
    + +
    +

    The Node implementation of module.children unfortunately includes +only those child modules that were imported for the first time by +this parent module (i.e., child.parent === this).

    + +
    + +
        this.children = [];
    + +
  • + + +
  • +
    + +
    + +
    +

    This object is an install.js extension that includes all child +modules imported by this module, even if this module is not the +first to import them.

    + +
    + +
        this.childrenById = {};
    +  }
    +
    +  Module.prototype.resolve = function (id) {
    +    return this.require.resolve(id);
    +  };
    + +
  • + + +
  • +
    + +
    + +
    +

    Used to keep module.prefetch promise resolutions well-ordered.

    + +
    + +
      var lastPrefetchPromise;
    + +
  • + + +
  • +
    + +
    + +
    +

    May be shared by multiple sequential calls to module.prefetch. +Initialized to {} only when necessary.

    + +
    + +
      var missing;
    +
    +  Module.prototype.prefetch = function (id) {
    +    var module = this;
    +    var parentFile = getOwn(filesByModuleId, module.id);
    +
    +    lastPrefetchPromise = lastPrefetchPromise || Promise.resolve();
    +    var previousPromise = lastPrefetchPromise;
    +
    +    function walk(module) {
    +      var file = getOwn(filesByModuleId, module.id);
    +      if (fileIsDynamic(file) && ! file.pending) {
    +        file.pending = true;
    +        missing = missing || {};
    + +
  • + + +
  • +
    + +
    + +
    +

    These are the data that will be exposed to the install.fetch +callback, so it’s worth documenting each item with a comment.

    + +
    + +
            missing[module.id] = {
    + +
  • + + +
  • +
    + +
    + +
    +

    The CommonJS module object that will be exposed to this +dynamic module when it is evaluated. Note that install.fetch +could decide to populate module.exports directly, instead of +fetching anything. In that case, install.fetch should omit +this module from the tree that it produces.

    + +
    + +
              module: file.module,
    + +
  • + + +
  • +
    + +
    + +
    +

    List of module identifier strings imported by this module. +Note that the missing object already contains all available +dependencies (including transitive dependencies), so +install.fetch should not need to traverse these dependencies +in most cases; however, they may be useful for other reasons. +Though the strings are unique, note that two different +strings could resolve to the same module.

    + +
    + +
              deps: Object.keys(file.deps),
    + +
  • + + +
  • +
    + +
    + +
    +

    The options (if any) that were passed as the second argument +to the install(tree, options) function when this stub was +first registered. Typically contains options.extensions, but +could contain any information appropriate for the entire tree +as originally installed. These options will be automatically +inherited by the newly fetched modules, so install.fetch +should not need to modify them.

    + +
    + +
              options: file.options,
    + +
  • + + +
  • +
    + +
    + +
    +

    Any stub data included in the array notation from the +original entry for this dynamic module. Typically contains +“main” and/or “browser” fields for package.json files, and is +otherwise undefined.

    + +
    + +
              stub: file.stub
    +        };
    +
    +        each(file.deps, function (parentId, id) {
    +          fileResolve(file, id);
    +        });
    +
    +        each(module.childrenById, walk);
    +      }
    +    }
    +
    +    return lastPrefetchPromise = new Promise(function (resolve) {
    +      var absChildId = module.resolve(id);
    +      each(module.childrenById, walk);
    +      resolve(absChildId);
    +
    +    }).then(function (absChildId) {
    + +
  • + + +
  • +
    + +
    + +
    +

    Grab the current missing object and fetch its contents.

    + +
    + +
          var toBeFetched = missing;
    +      missing = null;
    +
    +      return Promise.resolve(
    + +
  • + + +
  • +
    + +
    + +
    +

    The install.fetch function takes an object mapping missing +dynamic module identifiers to options objects, and should +return a Promise that resolves to a module tree that can be +installed. As an optimization, if there were no missing dynamic +modules, then we can skip calling install.fetch entirely.

    + +
    + +
            toBeFetched && install.fetch(toBeFetched)
    +
    +      ).then(function (tree) {
    +        function both() {
    +          install(tree);
    +          return absChildId;
    +        }
    + +
  • + + +
  • +
    + +
    + +
    +

    Although we want multiple install.fetch calls to run in +parallel, it is important that the promises returned by +module.prefetch are resolved in the same order as the original +calls to module.prefetch, because previous fetches may include +modules assumed to exist by more recent module.prefetch calls. +Whether previousPromise was resolved or rejected, carry on with +the installation regardless.

    + +
    + +
            return previousPromise.then(both, both);
    +      });
    +    });
    +  };
    +
    +  install.Module = Module;
    +
    +  function getOwn(obj, key) {
    +    return strictHasOwn(obj, key) && obj[key];
    +  }
    +
    +  function isObject(value) {
    +    return value !== null && typeof value === "object";
    +  }
    +
    +  function isFunction(value) {
    +    return typeof value === "function";
    +  }
    +
    +  function isString(value) {
    +    return typeof value === "string";
    +  }
    +
    +  function makeMissingError(id) {
    +    return new Error("Cannot find module '" + id + "'");
    +  }
    +
    +  function makeRequire(file) {
    +    function require(id) {
    +      var result = fileResolve(file, id);
    +      if (result) {
    +        return fileEvaluate(result, file.module);
    +      }
    +
    +      var error = makeMissingError(id);
    +
    +      if (isFunction(fallback)) {
    +        return fallback(
    +          id, // The missing module identifier.
    +          file.module.id, // The path of the requiring file.
    +          error // The error we would have thrown.
    +        );
    +      }
    +
    +      throw error;
    +    }
    +
    +    if (isFunction(wrapRequire)) {
    +      require = wrapRequire(require, file.module);
    +    }
    +
    +    require.extensions = fileGetExtensions(file).slice(0);
    +
    +    require.resolve = function (id) {
    +      var f = fileResolve(file, id);
    +      if (f) return f.module.id;
    +      var error = makeMissingError(id);
    +      if (fallback && isFunction(fallback.resolve)) {
    +        return fallback.resolve(id, file.module.id, error);
    +      }
    +      throw error;
    +    };
    +
    +    return require;
    +  }
    + +
  • + + +
  • +
    + +
    + +
    +

    File objects represent either directories or modules that have been +installed. When a File respresents a directory, its .contents +property is an object containing the names of the files (or +directories) that it contains. When a File represents a module, its +.contents property is a function that can be invoked with the +appropriate (require, exports, module) arguments to evaluate the +module. If the .contents property is a string, that string will be +resolved as a module identifier, and the exports of the resulting +module will provide the exports of the original file. The .parent +property of a File is either a directory File or null. Note that +a child may claim another File as its parent even if the parent +does not have an entry for that child in its .contents object. +This is important for implementing anonymous files, and preventing +child modules from using ../relative/identifier syntax to examine +unrelated modules.

    + +
    + +
      function File(moduleId, parent) {
    +    var file = this;
    + +
  • + + +
  • +
    + +
    + +
    +

    Link to the parent file.

    + +
    + +
        file.parent = parent = parent || null;
    + +
  • + + +
  • +
    + +
    + +
    +

    The module object for this File, which will eventually boast an +.exports property when/if the file is evaluated.

    + +
    + +
        file.module = new Module(moduleId);
    +    filesByModuleId[moduleId] = file;
    + +
  • + + +
  • +
    + +
    + +
    +

    The .contents of the file can be either (1) an object, if the file +represents a directory containing other files; (2) a factory +function, if the file represents a module that can be imported; (3) +a string, if the file is an alias for another file; or (4) null, if +the file’s contents are not (yet) available.

    + +
    + +
        file.contents = null;
    + +
  • + + +
  • +
    + +
    + +
    +

    Set of module identifiers imported by this module. Note that this +set is not necessarily complete, so don’t rely on it unless you +know what you’re doing.

    + +
    + +
        file.deps = {};
    +  }
    +
    +  function fileEvaluate(file, parentModule) {
    +    var module = file.module;
    +    if (! strictHasOwn(module, "exports")) {
    +      var contents = file.contents;
    +      if (! contents) {
    + +
  • + + +
  • +
    + +
    + +
    +

    If this file was installed with array notation, and the array +contained one or more objects but no functions, then the combined +properties of the objects are treated as a temporary stub for +file.module.exports. This is particularly important for partial +package.json modules, so that the resolution logic can know the +value of the “main” and/or “browser” fields, at least, even if +the rest of the package.json file is not (yet) available.

    + +
    + +
            if (file.stub) {
    +          return file.stub;
    +        }
    +
    +        throw makeMissingError(module.id);
    +      }
    +
    +      if (parentModule) {
    +        module.parent = parentModule;
    +        var children = parentModule.children;
    +        if (Array.isArray(children)) {
    +          children.push(module);
    +        }
    +      }
    + +
  • + + +
  • +
    + +
    + +
    +

    If a Module.prototype.useNode method is defined, give it a chance +to define module.exports based on module.id using Node.

    + +
    + +
          if (! isFunction(module.useNode) ||
    +          ! module.useNode()) {
    +        contents(
    +          module.require = module.require || makeRequire(file),
    + +
  • + + +
  • +
    + +
    + +
    +

    If the file had a .stub, reuse the same object for exports.

    + +
    + +
              module.exports = file.stub || {},
    +          module,
    +          file.module.id,
    +          file.parent.module.id
    +        );
    +      }
    +
    +      module.loaded = true;
    +    }
    + +
  • + + +
  • +
    + +
    + +
    +

    The module.runModuleSetters method will be deprecated in favor of +just module.runSetters: https://github.com/benjamn/reify/pull/160

    + +
    + +
        var runSetters = module.runSetters || module.runModuleSetters;
    +    if (isFunction(runSetters)) {
    +      runSetters.call(module);
    +    }
    +
    +    return module.exports;
    +  }
    +
    +  function fileIsDirectory(file) {
    +    return file && isObject(file.contents);
    +  }
    +
    +  function fileIsDynamic(file) {
    +    return file && file.contents === null;
    +  }
    +
    +  function fileMergeContents(file, contents, options) {
    +    if (Array.isArray(contents)) {
    +      contents.forEach(function (item) {
    +        if (isString(item)) {
    +          file.deps[item] = file.module.id;
    +        } else if (isFunction(item)) {
    +          contents = item;
    +        } else if (isObject(item)) {
    +          file.stub = file.stub || {};
    +          each(item, function (value, key) {
    +            file.stub[key] = value;
    +          });
    +        }
    +      });
    +
    +      if (! isFunction(contents)) {
    + +
  • + + +
  • +
    + +
    + +
    +

    If the array did not contain a function, merge nothing.

    + +
    + +
            contents = null;
    +      }
    +
    +    } else if (! isFunction(contents) &&
    +               ! isString(contents) &&
    +               ! isObject(contents)) {
    + +
  • + + +
  • +
    + +
    + +
    +

    If contents is neither an array nor a function nor a string nor +an object, just give up and merge nothing.

    + +
    + +
          contents = null;
    +    }
    +
    +    if (contents) {
    +      file.contents = file.contents || (isObject(contents) ? {} : contents);
    +      if (isObject(contents) && fileIsDirectory(file)) {
    +        each(contents, function (value, key) {
    +          if (key === "..") {
    +            child = file.parent;
    +
    +          } else {
    +            var child = getOwn(file.contents, key);
    +
    +            if (! child) {
    +              child = file.contents[key] = new File(
    +                file.module.id.replace(/\/*$/, "/") + key,
    +                file
    +              );
    +
    +              child.options = options;
    +            }
    +          }
    +
    +          fileMergeContents(child, value, options);
    +        });
    +      }
    +    }
    +  }
    +
    +  function each(obj, callback, context) {
    +    Object.keys(obj).forEach(function (key) {
    +      callback.call(this, obj[key], key);
    +    }, context);
    +  }
    +
    +  function fileGetExtensions(file) {
    +    return file.options
    +      && file.options.extensions
    +      || defaultExtensions;
    +  }
    +
    +  function fileAppendIdPart(file, part, extensions) {
    + +
  • + + +
  • +
    + +
    + +
    +

    Always append relative to a directory.

    + +
    + +
        while (file && ! fileIsDirectory(file)) {
    +      file = file.parent;
    +    }
    +
    +    if (! file || ! part || part === ".") {
    +      return file;
    +    }
    +
    +    if (part === "..") {
    +      return file.parent;
    +    }
    +
    +    var exactChild = getOwn(file.contents, part);
    + +
  • + + +
  • +
    + +
    + +
    +

    Only consider multiple file extensions if this part is the last +part of a module identifier and not equal to . or .., and there +was no exact match or the exact match was a directory.

    + +
    + +
        if (extensions && (! exactChild || fileIsDirectory(exactChild))) {
    +      for (var e = 0; e < extensions.length; ++e) {
    +        var child = getOwn(file.contents, part + extensions[e]);
    +        if (child && ! fileIsDirectory(child)) {
    +          return child;
    +        }
    +      }
    +    }
    +
    +    return exactChild;
    +  }
    +
    +  function fileAppendId(file, id, extensions) {
    +    var parts = id.split("/");
    + +
  • + + +
  • +
    + +
    + +
    +

    Use Array.prototype.every to terminate iteration early if +fileAppendIdPart returns a falsy value.

    + +
    + +
        parts.every(function (part, i) {
    +      return file = i < parts.length - 1
    +        ? fileAppendIdPart(file, part)
    +        : fileAppendIdPart(file, part, extensions);
    +    });
    +
    +    return file;
    +  }
    +
    +  function recordChild(parentModule, childFile) {
    +    var childModule = childFile && childFile.module;
    +    if (parentModule && childModule) {
    +      parentModule.childrenById[childModule.id] = childModule;
    +    }
    +  }
    +
    +  function fileResolve(file, id, parentModule, seenDirFiles) {
    +    var parentModule = parentModule || file.module;
    +    var extensions = fileGetExtensions(file);
    +
    +    file =
    + +
  • + + +
  • +
    + +
    + +
    +

    Absolute module identifiers (i.e. those that begin with a / +character) are interpreted relative to the root directory, which +is a slight deviation from Node, which has access to the entire +file system.

    + +
    + +
          id.charAt(0) === "/" ? fileAppendId(root, id, extensions) :
    + +
  • + + +
  • +
    + +
    + +
    +

    Relative module identifiers are interpreted relative to the +current file, naturally.

    + +
    + +
          id.charAt(0) === "." ? fileAppendId(file, id, extensions) :
    + +
  • + + +
  • +
    + +
    + +
    +

    Top-level module identifiers are interpreted as referring to +packages in node_modules directories.

    + +
    + +
          nodeModulesLookup(file, id, extensions);
    + +
  • + + +
  • +
    + +
    + +
    +

    If the identifier resolves to a directory, we use the same logic as +Node to find an index.js or package.json file to evaluate.

    + +
    + +
        while (fileIsDirectory(file)) {
    +      seenDirFiles = seenDirFiles || [];
    + +
  • + + +
  • +
    + +
    + +
    +

    If the “main” field of a package.json file resolves to a +directory we’ve already considered, then we should not attempt to +read the same package.json file again. Using an array as a set +is acceptable here because the number of directories to consider +is rarely greater than 1 or 2. Also, using indexOf allows us to +store File objects instead of strings.

    + +
    + +
          if (seenDirFiles.indexOf(file) < 0) {
    +        seenDirFiles.push(file);
    +
    +        var pkgJsonFile = fileAppendIdPart(file, "package.json"), main;
    +        var pkg = pkgJsonFile && fileEvaluate(pkgJsonFile, parentModule);
    +        if (pkg &&
    +            mainFields.some(function (name) {
    +              return isString(main = pkg[name]);
    +            })) {
    +          recordChild(parentModule, pkgJsonFile);
    + +
  • + + +
  • +
    + +
    + +
    +

    The “main” field of package.json does not have to begin with +./ to be considered relative, so first we try simply +appending it to the directory path before falling back to a +full fileResolve, which might return a package from a +node_modules directory.

    + +
    + +
              file = fileAppendId(file, main, extensions) ||
    +            fileResolve(file, main, parentModule, seenDirFiles);
    +
    +          if (file) {
    + +
  • + + +
  • +
    + +
    + +
    +

    The fileAppendId call above may have returned a directory, +so continue the loop to make sure we resolve it to a +non-directory file.

    + +
    + +
                continue;
    +          }
    +        }
    +      }
    + +
  • + + +
  • +
    + +
    + +
    +

    If we didn’t find a package.json file, or it didn’t have a +resolvable .main property, the only possibility left to +consider is that this directory contains an index.js module. +This assignment almost always terminates the while loop, because +there’s very little chance fileIsDirectory(file) will be true +for the result of fileAppendIdPart(file, "index.js"). However, +in principle it is remotely possible that a file called +index.js could be a directory instead of a file.

    + +
    + +
          file = fileAppendIdPart(file, "index.js");
    +    }
    +
    +    if (file && isString(file.contents)) {
    +      file = fileResolve(file, file.contents, parentModule, seenDirFiles);
    +    }
    +
    +    recordChild(parentModule, file);
    +
    +    return file;
    +  };
    +
    +  function nodeModulesLookup(file, id, extensions) {
    +    if (isFunction(override)) {
    +      id = override(id, file.module.id);
    +    }
    +
    +    if (isString(id)) {
    +      for (var resolved; file && ! resolved; file = file.parent) {
    +        resolved = fileIsDirectory(file) &&
    +          fileAppendId(file, "node_modules/" + id, extensions);
    +      }
    +
    +      return resolved;
    +    }
    +  }
    +
    +  return install;
    +};
    +
    +if (typeof exports === "object") {
    +  exports.makeInstaller = makeInstaller;
    +}
    + +
  • + +
+
+ + diff --git a/docs/install.html b/docs/install.html deleted file mode 100644 index e655355..0000000 --- a/docs/install.html +++ /dev/null @@ -1,742 +0,0 @@ - - - - - install.js - - - - - -
-
- -
    - -
  • -
    -

    install.js

    -
    -
  • - - - -
  • -
    - -
    - -
    - -
    - -
    (function (global, undefined) {
    -  if (global.makeInstaller) {
    -    return;
    -  }
    -
    -  function makeInstaller(options) {
    -    var root = new File({});
    - -
  • - - -
  • -
    - -
    - -
    -

    Set up a simple queue for tracking required modules with unmet -dependencies. See also queueAppend and queueFlush.

    - -
    - -
        var q = root.q = {};
    -    q.h = q.t = {}; // Queue head, queue tail.
    - -
  • - - -
  • -
    - -
    - -
    -

    Configurable function for deferring queue flushes.

    - -
    - -
        q.d = options && options.defer || function (fn) {
    -      setTimeout(fn, 0);
    -    };
    -
    -    return function install(tree) {
    -      if (isObject(tree)) {
    -        fileMergeContents(root, tree);
    -        queueFlush(root.q);
    -      }
    -      return root.r;
    -    };
    -  }
    -
    -  global.makeInstaller = makeInstaller;
    -
    -  if (typeof exports === "object") {
    -    exports.makeInstaller = makeInstaller;
    -  }
    -
    -  var extensions = ["", ".js", ".json"];
    -  var MISSING = {};
    -  var hasOwn = MISSING.hasOwnProperty;
    -  var Ap = Array.prototype;
    -
    -  function getOwn(obj, key) {
    -    return hasOwn.call(obj, key) && obj[key];
    -  }
    -
    -  function isObject(value) {
    -    return value && typeof value === "object";
    -  }
    -
    -  function isFunction(value) {
    -    return typeof value === "function";
    -  }
    -
    -  function isString(value) {
    -    return typeof value === "string";
    -  }
    -
    -  function queueAppend(q, file) {
    - -
  • - - -
  • -
    - -
    - -
    -

    Property names shortened to shave bytes: .t means .tail, .h -means .head, .n means .next, and .f means .file.

    - -
    - -
        q.t = q.t.n = { f: file };
    -    if (q.h.n === q.t) {
    - -
  • - - -
  • -
    - -
    - -
    -

    If the queue contains only one File (the one we just added), go -ahead and schedule a flush.

    - -
    - -
          queueFlush(q);
    -    }
    -  }
    -
    -  function queueFlush(q) {
    - -
  • - - -
  • -
    - -
    - -
    -

    The q.p property is set to indicate a flush is pending.

    - -
    - -
        q.p || (q.p = true, q.d(function () {
    -      q.p = undefined;
    -      var next = q.h.n;
    -      if (next && fileReady(next.f)) {
    -        queueFlush(q); // Schedule the next flush.
    -        q.h = next;
    -        fileEvaluate(next.f);
    -      }
    -    }));
    -  }
    - -
  • - - -
  • -
    - -
    - -
    -

    These unbound{Require,Ensure} functions need to be bound to File -objects before they can be used. See makeRequire.

    - -
    - -
    -  function unboundRequire(id) {
    -    var result = fileEvaluate(fileResolve(this, id));
    -    if (result === MISSING) {
    -      throw new Error("Cannot find module '" + id + "'");
    -    }
    -    return result;
    -  }
    -
    -  function unboundEnsure() {
    - -
  • - - -
  • -
    - -
    - -
    -

    Flatten arguments into an array containing relative module -identifier strings and an optional callback function, then coerce -that array into a callback function with a .d property.

    - -
    - -
        var flatArgs = Ap.concat.apply(Ap, arguments);
    -    var callback = ensureObjectOrFunction(flatArgs);
    - -
  • - - -
  • -
    - -
    - -
    -

    Note that queueAppend schedules a flush if there are no other -callbacks waiting in the queue.

    - -
    - -
        queueAppend(this.q, new File(callback, this));
    -  }
    -
    -  function makeRequire(file) {
    -    var require = unboundRequire.bind(file);
    -    require.ensure = unboundEnsure.bind(file);
    - -
  • - - -
  • -
    - -
    - -
    -

    TODO Consider adding require.promise.

    - -
    - -
        return require;
    -  }
    - -
  • - - -
  • -
    - -
    - -
    -

    File objects represent either directories or modules that have been -installed. When a File respresents a directory, its .c (contents) -property is an object containing the names of the files (or -directories) that it contains. When a File represents a module, its -.c property is a function that can be invoked with the appropriate -(require, exports, module) arguments to evaluate the module. The -.p (parent) property of a File is either a directory File or -null. Note that a child may claim another File as its parent even -if the parent does not have an entry for that child in its .c -object. This is important for implementing anonymous files, and -preventing child modules from using ../relative/identifier syntax -to examine unrelated modules.

    - -
    - -
      function File(contents, /*optional:*/ parent, name) {
    -    var file = this;
    - -
  • - - -
  • -
    - -
    - -
    -

    Link to the parent file.

    - -
    - -
        file.p = parent = parent || null;
    -
    -    if (name) {
    - -
  • - - -
  • -
    - -
    - -
    -

    If this file was created with name, join it with parent.id to -generate a module identifier.

    - -
    - -
          file.id = (parent && parent.id || "") + "/" + name;
    -    }
    - -
  • - - -
  • -
    - -
    - -
    -

    Queue for tracking required modules with unmet dependencies, -inherited from the parent.

    - -
    - -
        file.q = parent && parent.q;
    - -
  • - - -
  • -
    - -
    - -
    -

    Each directory has its own bound version of the require function -that can resolve relative identifiers. Non-directory Files inherit -the require function of their parent directories, so we don’t have -to create a new require function every time we evaluate a module.

    - -
    - -
        file.r = isObject(contents)
    -      ? makeRequire(file)
    -      : parent && parent.r;
    - -
  • - - -
  • -
    - -
    - -
    -

    Set the initial value of file.c (the “contents” of the File).

    - -
    - -
        fileMergeContents(file, contents);
    - -
  • - - -
  • -
    - -
    - -
    -

    When the file is a directory, file.ready is an object mapping -module identifiers to boolean ready statuses. This information can -be shared by all files in the directory, because module resolution -always has the same results for all files in a given directory.

    - -
    - -
        file.ready = fileIsDirectory(file) && {};
    -  }
    - -
  • - - -
  • -
    - -
    - -
    -

    A file is ready if all of its dependencies are installed and ready.

    - -
    - -
      function fileReady(file) {
    -    var result = !! file;
    -    var module = file && file.c;
    -    var deps = isFunction(module) && module.d;
    -    if (deps && ! getOwn(module, "seen")) {
    -      module.seen = true;
    -      var parentReadyCache = file.p.ready;
    -      result = Object.keys(deps).every(function (dep) {
    - -
  • - - -
  • -
    - -
    - -
    -

    By storing the results of these lookups in parentReadyCache, -we benefit when any other file in the same directory resolves -the same identifier.

    - -
    - -
            return parentReadyCache[dep] =
    -          parentReadyCache[dep] ||
    -          fileReady(fileResolve(file.p, dep));
    -      });
    -      module.seen = undefined;
    -    }
    -    return result;
    -  }
    -
    -  function fileEvaluate(file) {
    -    var module = file && file.c;
    -    if (isFunction(module)) {
    -      if (! hasOwn.call(module, "exports")) {
    -        module.id = file.id;
    -        module.call(global, file.r, module.exports = {}, module);
    -      }
    -      return module.exports;
    -    }
    -    return MISSING;
    -  }
    -
    -  function fileIsDirectory(file) {
    -    return isObject(file.c);
    -  }
    -
    -  function fileMergeContents(file, contents) {
    -    if ((contents = ensureObjectOrFunction(contents))) {
    -      var fileContents = file.c = file.c || (
    -        isFunction(contents) ? contents : {}
    -      );
    -
    -      if (isObject(contents) && fileIsDirectory(file)) {
    -        Object.keys(contents).forEach(function (key) {
    -          var child = getOwn(fileContents, key);
    -          if (child) {
    -            fileMergeContents(child, contents[key]);
    -          } else {
    -            fileContents[key] = new File(contents[key], file, key);
    -          }
    -        });
    -      }
    -    }
    -  };
    -
    -  function ensureObjectOrFunction(contents) {
    - -
  • - - -
  • -
    - -
    - -
    -

    If contents is an array of strings and functions, return the last -function with a .d property containing all the strings.

    - -
    - -
        if (Array.isArray(contents)) {
    -      var deps = {};
    -      var func;
    -
    -      contents.forEach(function (item) {
    -        if (isString(item)) {
    -          deps[item] = false; // Initially unsatisfied.
    -        } else if (isFunction(item)) {
    -          func = item;
    -        }
    -      });
    - -
  • - - -
  • -
    - -
    - -
    -

    If no function was found in the array, provide a default function -that simply requires each dependency (really common case).

    - -
    - -
          contents = func || function (module, require) {
    -        Object.keys(deps).forEach(require);
    -      };
    -
    -      contents.d = deps;
    -
    -    } else if (isFunction(contents)) {
    - -
  • - - -
  • -
    - -
    - -
    -

    If contents is already a function, make sure it has deps.

    - -
    - -
          contents.d = contents.d || {};
    -
    -    } else if (! isObject(contents)) {
    - -
  • - - -
  • -
    - -
    - -
    -

    If contents is neither an array nor a function nor an object, -just give up and return null.

    - -
    - -
          contents = null;
    -    }
    -
    -    return contents;
    -  }
    -
    -  function fileAppendIdPart(file, part, isLastPart) {
    - -
  • - - -
  • -
    - -
    - -
    -

    Always append relative to a directory.

    - -
    - -
        while (file && ! fileIsDirectory(file)) {
    -      file = file.p;
    -    }
    -
    -    if (! file || ! part || part === ".") {
    -      return file;
    -    }
    -
    -    if (part === "..") {
    -      return file.p;
    -    }
    -
    -    for (var e = 0; e < extensions.length; ++e) {
    -      var withExtension = part + extensions[e];
    -
    -      var child = getOwn(file.c, withExtension);
    -      if (child) {
    -        return child;
    -      }
    -
    -      if (! isLastPart) {
    - -
  • - - -
  • -
    - -
    - -
    -

    Only consider multiple file extensions if this part is the last -part of a module identifier, and not . or ...

    - -
    - -
            break;
    -      }
    -    }
    -  };
    -
    -  function fileAppendId(file, id) {
    -    var parts = id.split("/");
    - -
  • - - -
  • -
    - -
    - -
    -

    Use Array.prototype.every to terminate iteration early if -fileAppendIdPart returns a falsy value.

    - -
    - -
        parts.every(function (part, i) {
    -      return file = fileAppendIdPart(file, part, i === parts.length - 1);
    -    });
    -    return file;
    -  };
    -
    -  function fileGetRoot(file) {
    -    return file && fileGetRoot(file.p) || file;
    -  }
    -
    -  function fileResolve(file, id) {
    -    file =
    - -
  • - - -
  • -
    - -
    - -
    -

    Absolute module identifiers (i.e. those that begin with a / -character) are interpreted relative to the root directory, which -is a slight deviation from Node, which has access to the entire -file system.

    - -
    - -
          id.charAt(0) === "/" ? fileAppendId(fileGetRoot(file), id) :
    - -
  • - - -
  • -
    - -
    - -
    -

    Relative module identifiers are interpreted relative to the -current file, naturally.

    - -
    - -
          id.charAt(0) === "." ? fileAppendId(file, id) :
    - -
  • - - -
  • -
    - -
    - -
    -

    Top-level module identifiers are interpreted as referring to -packages in node_modules directories.

    - -
    - -
          nodeModulesLookup(file, id);
    - -
  • - - -
  • -
    - -
    - -
    -

    If the identifier resolves to a directory, we use the same logic as -Node to find an index.js or package.json file to evaluate.

    - -
    - -
        while (file && fileIsDirectory(file)) {
    - -
  • - - -
  • -
    - -
    - -
    -

    If package.json does not exist, fileEvaluate will return the -MISSING object, which has no .main property.

    - -
    - -
          var pkg = fileEvaluate(fileAppendIdPart(file, "package.json"));
    -      file = pkg && isString(pkg.main) &&
    -        fileAppendId(file, pkg.main) || // Might resolve to another directory!
    -        fileAppendIdPart(file, "index.js");
    -    }
    -
    -    return file;
    -  };
    -
    -  function nodeModulesLookup(file, id) {
    -    return fileIsDirectory(file) &&
    -      fileAppendId(file, "node_modules/" + id) ||
    -      (file.p && nodeModulesLookup(file.p, id));
    -  }
    -})("object" === typeof global ? global :
    -   "object" === typeof window ? window :
    -   "object" === typeof self ? self : this);
    - -
  • - -
-
- - diff --git a/scripts/docs.sh b/scripts/docs.sh index f5a8b91..4fe073d 100755 --- a/scripts/docs.sh +++ b/scripts/docs.sh @@ -1,16 +1,7 @@ #!/usr/bin/env bash cd $(dirname $0)/.. - docco install.js -git fetch origin -BRANCH=$(git rev-parse --abbrev-ref HEAD) -tar czvf docs.tgz docs -git checkout gh-pages -git rebase origin/gh-pages -tar xf docs.tgz --strip-components 1 +cd docs mv install.html index.html -git commit -a -m "Regenerate docs." -git push origin gh-pages -git checkout ${BRANCH} -rm docs.tgz +cd .. From d8142eb42e22363d06e7282812955adcd572325e Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Mon, 22 Jan 2018 11:07:28 -0500 Subject: [PATCH 15/53] Fall back to index.js when package.json "main" module missing. --- install.js | 8 ++++---- test/run.js | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/install.js b/install.js index ea818bb..9fa5d0f 100644 --- a/install.js +++ b/install.js @@ -509,17 +509,17 @@ makeInstaller = function (options) { mainFields.some(function (name) { return isString(main = pkg[name]); })) { - recordChild(parentModule, pkgJsonFile); - // The "main" field of package.json does not have to begin with // ./ to be considered relative, so first we try simply // appending it to the directory path before falling back to a // full fileResolve, which might return a package from a // node_modules directory. - file = fileAppendId(file, main, extensions) || + var mainFile = fileAppendId(file, main, extensions) || fileResolve(file, main, parentModule, seenDirFiles); - if (file) { + if (mainFile) { + file = mainFile; + recordChild(parentModule, pkgJsonFile); // The fileAppendId call above may have returned a directory, // so continue the loop to make sure we resolve it to a // non-directory file. diff --git a/test/run.js b/test/run.js index e7aef3c..1e7256b 100644 --- a/test/run.js +++ b/test/run.js @@ -1138,4 +1138,39 @@ describe("install", function () { return require("./a").promise; }); + + it('falls back to index.js when package.json "main" missing', function () { + var install = makeInstaller(); + var require = install({ + "main.js"(require, exports, module) { + exports.result = require("pkg"); + }, + + node_modules: { + pkg: { + "package.json"(require, exports, module) { + // Since this file is missing, the root index.js should be used. + exports.main = "dist/index.js"; + }, + + "index.js"(require, exports, module) { + exports.isRoot = true; + exports.id = module.id; + exports.oyez = require("./dist/oyez.js"); + }, + + dist: { + "oyez.js"(require, exports, module) { + exports.id = module.id; + } + } + } + } + }); + + var result = require("./main").result; + assert.strictEqual(result.isRoot, true); + assert.strictEqual(result.id, "/node_modules/pkg/index.js"); + assert.strictEqual(result.oyez.id, "/node_modules/pkg/dist/oyez.js"); + }); }); From 71283e40ebccefe76f4507abe65c6f4d801c706d Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Mon, 22 Jan 2018 11:10:15 -0500 Subject: [PATCH 16/53] Use method shorthand syntax in README.md examples. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 43d5149..1a96664 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ objects and functions to the `install` function: ```js var require = install({ - "main.js": function (require, exports, module) { + "main.js"(require, exports, module) { // On the client, the "assert" module should be install-ed just like // any other module. On the server, since "assert" is a built-in Node // module, it may make sense to let the options.fallback function @@ -76,13 +76,13 @@ var require = install({ // If package.json is not defined, a module called "index.js" will // be used as the main entry point for the package. Otherwise the // exports.main property will identify the entry point. - "package.json": function (require, exports, module) { + "package.json"(require, exports, module) { exports.name = "package"; exports.version = "0.1.0"; exports.main = "entry.js"; }, - "entry.js": function (require, exports, module) { + "entry.js"(require, exports, module) { exports.name = module.id; } } From bead9d38f0b5a67582c782e277cc59c6f6284736 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Mon, 22 Jan 2018 11:08:03 -0500 Subject: [PATCH 17/53] Bump NPM version to 0.10.3 in preparation for publishing. --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3736099..d1939c7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "install", - "version": "0.10.2", + "version": "0.10.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index a252739..c675538 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "packager", "install" ], - "version": "0.10.2", + "version": "0.10.3", "license": "MIT", "homepage": "http://github.com/benjamn/install", "repository": { From 05e461fe5537a3068f118275cc61b170d6bd3764 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Mon, 22 Jan 2018 11:13:20 -0500 Subject: [PATCH 18/53] Add docs/ directory to .npmignore. --- .npmignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.npmignore b/.npmignore index e216ae5..dcbaa2d 100644 --- a/.npmignore +++ b/.npmignore @@ -1,2 +1,3 @@ /node_modules /test +/docs From 6412f4aabbb44501ad557f578d8ab39f78f22d2c Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Mon, 22 Jan 2018 11:13:40 -0500 Subject: [PATCH 19/53] Bump NPM version to 0.10.4 in preparation for publishing. --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index d1939c7..08b40fb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "install", - "version": "0.10.3", + "version": "0.10.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index c675538..2ea603d 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "packager", "install" ], - "version": "0.10.3", + "version": "0.10.4", "license": "MIT", "homepage": "http://github.com/benjamn/install", "repository": { From 69a15ac4edabee55aecd89500ca57d32cd95b45a Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Thu, 22 Mar 2018 22:02:29 -0400 Subject: [PATCH 20/53] chore(package): update reify to version 0.14.2 (#41) Closes #40 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2ea603d..d19a1ba 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "docco": "^0.8.0", "mocha": "^5.0.0", "uglify-js": "^3.0.12", - "reify": "^0.13.7" + "reify": "^0.14.2" }, "license": "MIT", "engines": { From 64d06b034a555d8319b403c77e9b5b8bfc246381 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Thu, 22 Mar 2018 22:03:22 -0400 Subject: [PATCH 21/53] Update package-lock.json. --- package-lock.json | 83 +++++++++++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 38 deletions(-) diff --git a/package-lock.json b/package-lock.json index 08b40fb..49a154f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,9 +5,9 @@ "requires": true, "dependencies": { "acorn": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.3.0.tgz", - "integrity": "sha512-Yej+zOJ1Dm/IMZzzj78OntP/r3zHEaKcyNoU2lAaxPtrseM6rF0xwqoz5Q5ysAiED9hTjI2hgtvLXitlCN1/Ug==", + "version": "5.5.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.5.3.tgz", + "integrity": "sha512-jd5MkIUlbbmb07nXH0DT3y7rDVtkzDi4XZOUVWAer8ajmF/DTSSbl5oNFyDOl/OXA33Bl79+ypHhl2pN20VeOQ==", "dev": true }, "balanced-match": { @@ -17,9 +17,9 @@ "dev": true }, "brace-expansion": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", - "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -27,15 +27,15 @@ } }, "browser-stdout": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.0.tgz", - "integrity": "sha1-81HTKWnTL6XXpVZxVCY9korjvR8=", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", "dev": true }, "commander": { - "version": "2.13.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.13.0.tgz", - "integrity": "sha512-MVuS359B+YzaWqjCL/c+22gfryv+mCBPHAv3zyVI2GN8EY6IRP8VwtasXn8jyyhvvq84R4ImN1OKRtcbIasjYA==", + "version": "2.15.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", + "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", "dev": true }, "concat-map": { @@ -54,9 +54,9 @@ } }, "diff": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.3.1.tgz", - "integrity": "sha512-MKPHZDMB0o6yHyDryUOScqZibp914ksXwAMYMTHj6KO8UeKsRYNJD3oNCKjTqZon+V488P7N/HzXF8t7ZR95ww==", + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", "dev": true }, "docco": { @@ -65,10 +65,10 @@ "integrity": "sha512-QcWBDnnGaT+rgC0wqynznXv0/4hd6nAFdWNs2fN4FvkH2yAnCYVeRU7GIZXNCeUQ955Lufq+TmZcSXiBa1cGQQ==", "dev": true, "requires": { - "commander": "2.13.0", + "commander": "2.15.1", "fs-extra": "5.0.0", "highlight.js": "9.12.0", - "marked": "0.3.12", + "marked": "0.3.18", "underscore": "1.8.3" } }, @@ -165,9 +165,9 @@ } }, "marked": { - "version": "0.3.12", - "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.12.tgz", - "integrity": "sha512-k4NaW+vS7ytQn6MgJn3fYpQt20/mOgYM5Ft9BYMfQJDz2QT6yEeS9XJ8k2Nw8JTeWK/znPPW2n3UJGzyYEiMoA==", + "version": "0.3.18", + "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.18.tgz", + "integrity": "sha512-49i2QYhfULqaXzNZpxC808PisuCTGT2fgG0zrzdCI9N3rIfAWfW0nggvbXr6zvpynZdOG5+9xNxdzP0kwZnERw==", "dev": true }, "minimatch": { @@ -176,7 +176,7 @@ "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { - "brace-expansion": "1.1.8" + "brace-expansion": "1.1.11" } }, "minimist": { @@ -186,11 +186,12 @@ "dev": true }, "minipass": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.2.1.tgz", - "integrity": "sha512-u1aUllxPJUI07cOqzR7reGmQxmCqlH88uIIsf6XZFEWgw7gXKpJdR+5R9Y3KEDmWYkdIz9wXZs3C0jOPxejk/Q==", + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.2.4.tgz", + "integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==", "dev": true, "requires": { + "safe-buffer": "5.1.1", "yallist": "3.0.2" } }, @@ -200,7 +201,7 @@ "integrity": "sha512-4T6Ur/GctZ27nHfpt9THOdRZNgyJ9FZchYO1ceg5S8Q3DNLCKYy44nCZzgCJgcvx2UM8czmqak5BCxJMrq37lA==", "dev": true, "requires": { - "minipass": "2.2.1" + "minipass": "2.2.4" } }, "mkdirp": { @@ -213,15 +214,15 @@ } }, "mocha": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.0.0.tgz", - "integrity": "sha512-ukB2dF+u4aeJjc6IGtPNnJXfeby5d4ZqySlIBT0OEyva/DrMjVm5HkQxKnHDLKEfEQBsEnwTg9HHhtPHJdTd8w==", + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.0.5.tgz", + "integrity": "sha512-3MM3UjZ5p8EJrYpG7s+29HAI9G7sTzKEe4+w37Dg0QP7qL4XGsV+Q2xet2cE37AqdgN1OtYQB6Vl98YiPV3PgA==", "dev": true, "requires": { - "browser-stdout": "1.3.0", + "browser-stdout": "1.3.1", "commander": "2.11.0", "debug": "3.1.0", - "diff": "3.3.1", + "diff": "3.5.0", "escape-string-regexp": "1.0.5", "glob": "7.1.2", "growl": "1.10.3", @@ -260,16 +261,22 @@ "dev": true }, "reify": { - "version": "0.13.7", - "resolved": "https://registry.npmjs.org/reify/-/reify-0.13.7.tgz", - "integrity": "sha512-jA6C/TdOf0g1A9WlQL7enh8yfGXgCmU3qbOpgc98vzRNEgu4TrAnSGec+uLxHdci96lftdBow3q0X3pbXnzmGQ==", + "version": "0.14.2", + "resolved": "https://registry.npmjs.org/reify/-/reify-0.14.2.tgz", + "integrity": "sha512-gJA67pCidAROSmr4/8SQuMQXtZwtSvoVIDR6KjoWxnO4LSD8iYNjMcRrHuQQ/c8cXYaoCpEQh0rO9CNNu1z5lA==", "dev": true, "requires": { - "acorn": "5.3.0", + "acorn": "5.5.3", "minizlib": "1.1.0", "semver": "5.5.0" } }, + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", + "dev": true + }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", @@ -292,12 +299,12 @@ } }, "uglify-js": { - "version": "3.3.8", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.3.8.tgz", - "integrity": "sha512-X0jAGtpSZRtd4RhbVNuGHyjZNa/h2MrVkKrR3Ew5iL2MJw6d7FmBke+fhVCALWySv1ygHnjjROG1KI1FAPvddw==", + "version": "3.3.16", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.3.16.tgz", + "integrity": "sha512-FMh5SRqJRGhv9BbaTffENIpDDQIoPDR8DBraunGORGhySArsXlw9++CN+BWzPBLpoI4RcSnpfGPnilTxWL3Vvg==", "dev": true, "requires": { - "commander": "2.13.0", + "commander": "2.15.1", "source-map": "0.6.1" } }, From f69158f0a1f9fa0bb29db71666997a28f8be2fca Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Thu, 22 Mar 2018 22:05:04 -0400 Subject: [PATCH 22/53] Remove support for calling Module.prototype.useNode. This method was a Meteor-specific escape hatch for switching to native Node evaluation (e.g. for native .node modules) rather than evaluating bundled modules within the install.js module system. Starting with Meteor 1.6.2, Meteor will generate stub modules that call module.useNode() themselves, rather than relying on install.js to check whether module.useNode is defined and then call it. Not only is this a much cleaner separation of concerns, it also eliminates a small amount of performance overhead for every module evaluation, and it means we won't always switch to native Node evaluation just because we can, leaving room for bundled code to run instead. --- install.js | 21 ++++++++------------- test/run.js | 28 ---------------------------- 2 files changed, 8 insertions(+), 41 deletions(-) diff --git a/install.js b/install.js index 9fa5d0f..ddc6397 100644 --- a/install.js +++ b/install.js @@ -319,19 +319,14 @@ makeInstaller = function (options) { } } - // If a Module.prototype.useNode method is defined, give it a chance - // to define module.exports based on module.id using Node. - if (! isFunction(module.useNode) || - ! module.useNode()) { - contents( - module.require = module.require || makeRequire(file), - // If the file had a .stub, reuse the same object for exports. - module.exports = file.stub || {}, - module, - file.module.id, - file.parent.module.id - ); - } + contents( + module.require = module.require || makeRequire(file), + // If the file had a .stub, reuse the same object for exports. + module.exports = file.stub || {}, + module, + file.module.id, + file.parent.module.id + ); module.loaded = true; } diff --git a/test/run.js b/test/run.js index 1e7256b..d9b9b18 100644 --- a/test/run.js +++ b/test/run.js @@ -549,34 +549,6 @@ describe("install", function () { require("./a"); }); - it("respects Module.prototype.useNode", function () { - var install = main.makeInstaller(); - - install.Module.prototype.useNode = function () { - if (this.id.split("/").pop() === "b") { - assert.strictEqual(typeof this.exports, "undefined"); - this.exports = { - usedNode: true - }; - return true; - } - }; - - var require = install({ - a: function (require, exports) { - exports.b = require("./b"); - }, - - b: function (r, exports) { - exports.usedNode = false; - } - }); - - assert.strictEqual(require("./a").b.usedNode, true); - assert.strictEqual(require("./b").usedNode, true); - assert.strictEqual(require("./a").b, require("./b")); - }); - it("runs setters", function () { var install = main.makeInstaller(); var markers = []; From 24b72f848c1d1dfdeec12a877e4c1f6a168a5714 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Thu, 22 Mar 2018 22:13:03 -0400 Subject: [PATCH 23/53] Bump NPM version to 0.11.0 in preparation for publishing. --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 49a154f..edbf44f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "install", - "version": "0.10.4", + "version": "0.11.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index d19a1ba..a150945 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "packager", "install" ], - "version": "0.10.4", + "version": "0.11.0", "license": "MIT", "homepage": "http://github.com/benjamn/install", "repository": { From e36fc03e5f1f72a8571c9948f88e02ae83c88d8c Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Fri, 23 Mar 2018 17:39:12 -0400 Subject: [PATCH 24/53] chore(package): update reify to version 0.15.0 (#42) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a150945..f927c15 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "docco": "^0.8.0", "mocha": "^5.0.0", "uglify-js": "^3.0.12", - "reify": "^0.14.2" + "reify": "^0.15.0" }, "license": "MIT", "engines": { From 84046cb4899e6849168cd32aca8ab836cddf6020 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Thu, 24 May 2018 22:11:26 -0400 Subject: [PATCH 25/53] chore(package): update reify to version 0.16.1 (#45) Closes #44 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f927c15..2e4e87c 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "docco": "^0.8.0", "mocha": "^5.0.0", "uglify-js": "^3.0.12", - "reify": "^0.15.0" + "reify": "^0.16.1" }, "license": "MIT", "engines": { From 49edd2c5dfd5a39bff52f3b4d046573fd683b3ab Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Fri, 8 Jun 2018 15:28:44 -0400 Subject: [PATCH 26/53] Update reify to latest version. --- package.json | 4 ++-- test/run.js | 12 ++++-------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 2e4e87c..d556c50 100644 --- a/package.json +++ b/package.json @@ -31,8 +31,8 @@ "devDependencies": { "docco": "^0.8.0", "mocha": "^5.0.0", - "uglify-js": "^3.0.12", - "reify": "^0.16.1" + "reify": "^0.16.2", + "uglify-js": "^3.0.12" }, "license": "MIT", "engines": { diff --git a/test/run.js b/test/run.js index d9b9b18..58ac71e 100644 --- a/test/run.js +++ b/test/run.js @@ -556,12 +556,10 @@ describe("install", function () { a: function (r, exports, module) { exports.one = 1; - // Enable module.{importSync,export}. + // Enable module.watch. reify(module); - (module.importSync || - module.import - ).call(module, "./b", { + module.watch(require("./b"), { one: function (v) { markers.push("ab1", v); }, @@ -577,12 +575,10 @@ describe("install", function () { b: function (r, exports, module) { exports.one = 1; - // Enable module.{importSync,export}. + // Enable module.watch. reify(module); - (module.importSync || - module.import - ).call(module, "./a", { + module.watch(require("./a"), { one: function (v) { markers.push("ba1", v); }, From c24cefbdf913a30c4c771ac6540e74bd7c8faf6d Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Fri, 8 Jun 2018 15:28:28 -0400 Subject: [PATCH 27/53] Update package-lock.json. --- package-lock.json | 157 +++++++++++++++++----------------------------- 1 file changed, 59 insertions(+), 98 deletions(-) diff --git a/package-lock.json b/package-lock.json index edbf44f..3f88d28 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,9 +5,9 @@ "requires": true, "dependencies": { "acorn": { - "version": "5.5.3", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.5.3.tgz", - "integrity": "sha512-jd5MkIUlbbmb07nXH0DT3y7rDVtkzDi4XZOUVWAer8ajmF/DTSSbl5oNFyDOl/OXA33Bl79+ypHhl2pN20VeOQ==", + "version": "5.6.2", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.6.2.tgz", + "integrity": "sha512-zUzo1E5dI2Ey8+82egfnttyMlMZ2y0D8xOCO3PNPPlYXpl8NZvF6Qk9L9BEtJs+43FqEmfBViDqc5d1ckRDguw==", "dev": true }, "balanced-match": { @@ -22,7 +22,7 @@ "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { - "balanced-match": "1.0.0", + "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, @@ -65,11 +65,11 @@ "integrity": "sha512-QcWBDnnGaT+rgC0wqynznXv0/4hd6nAFdWNs2fN4FvkH2yAnCYVeRU7GIZXNCeUQ955Lufq+TmZcSXiBa1cGQQ==", "dev": true, "requires": { - "commander": "2.15.1", - "fs-extra": "5.0.0", - "highlight.js": "9.12.0", - "marked": "0.3.18", - "underscore": "1.8.3" + "commander": ">= 0.5.2", + "fs-extra": ">= 0.6.0", + "highlight.js": ">= 8.0.x", + "marked": ">= 0.2.7", + "underscore": ">= 1.0.0" } }, "escape-string-regexp": { @@ -79,14 +79,14 @@ "dev": true }, "fs-extra": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-5.0.0.tgz", - "integrity": "sha512-66Pm4RYbjzdyeuqudYqhFiNBbCIuI9kgRqLPSHIlXHidW8NIQtVdkM1yeZ4lXwuhbTETv3EUGMNHAAw6hiundQ==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-6.0.1.tgz", + "integrity": "sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA==", "dev": true, "requires": { - "graceful-fs": "4.1.11", - "jsonfile": "4.0.0", - "universalify": "0.1.1" + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" } }, "fs.realpath": { @@ -101,12 +101,12 @@ "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" } }, "graceful-fs": { @@ -116,15 +116,15 @@ "dev": true }, "growl": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", "dev": true }, "has-flag": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", - "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", "dev": true }, "he": { @@ -145,8 +145,8 @@ "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "dev": true, "requires": { - "once": "1.4.0", - "wrappy": "1.0.2" + "once": "^1.3.0", + "wrappy": "1" } }, "inherits": { @@ -161,13 +161,13 @@ "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", "dev": true, "requires": { - "graceful-fs": "4.1.11" + "graceful-fs": "^4.1.6" } }, "marked": { - "version": "0.3.18", - "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.18.tgz", - "integrity": "sha512-49i2QYhfULqaXzNZpxC808PisuCTGT2fgG0zrzdCI9N3rIfAWfW0nggvbXr6zvpynZdOG5+9xNxdzP0kwZnERw==", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/marked/-/marked-0.4.0.tgz", + "integrity": "sha512-tMsdNBgOsrUophCAFQl0XPe6Zqk/uy9gnue+jIIKhykO51hxyu6uNx7zBPy0+y/WKYVZZMspV9YeXLNdKk+iYw==", "dev": true }, "minimatch": { @@ -176,7 +176,7 @@ "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { - "brace-expansion": "1.1.11" + "brace-expansion": "^1.1.7" } }, "minimist": { @@ -185,25 +185,6 @@ "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", "dev": true }, - "minipass": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.2.4.tgz", - "integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==", - "dev": true, - "requires": { - "safe-buffer": "5.1.1", - "yallist": "3.0.2" - } - }, - "minizlib": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.1.0.tgz", - "integrity": "sha512-4T6Ur/GctZ27nHfpt9THOdRZNgyJ9FZchYO1ceg5S8Q3DNLCKYy44nCZzgCJgcvx2UM8czmqak5BCxJMrq37lA==", - "dev": true, - "requires": { - "minipass": "2.2.4" - } - }, "mkdirp": { "version": "0.5.1", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", @@ -214,29 +195,22 @@ } }, "mocha": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.0.5.tgz", - "integrity": "sha512-3MM3UjZ5p8EJrYpG7s+29HAI9G7sTzKEe4+w37Dg0QP7qL4XGsV+Q2xet2cE37AqdgN1OtYQB6Vl98YiPV3PgA==", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", + "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", "dev": true, "requires": { "browser-stdout": "1.3.1", - "commander": "2.11.0", + "commander": "2.15.1", "debug": "3.1.0", "diff": "3.5.0", "escape-string-regexp": "1.0.5", "glob": "7.1.2", - "growl": "1.10.3", + "growl": "1.10.5", "he": "1.1.1", + "minimatch": "3.0.4", "mkdirp": "0.5.1", - "supports-color": "4.4.0" - }, - "dependencies": { - "commander": { - "version": "2.11.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", - "integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==", - "dev": true - } + "supports-color": "5.4.0" } }, "ms": { @@ -251,7 +225,7 @@ "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, "requires": { - "wrappy": "1.0.2" + "wrappy": "1" } }, "path-is-absolute": { @@ -261,22 +235,15 @@ "dev": true }, "reify": { - "version": "0.14.2", - "resolved": "https://registry.npmjs.org/reify/-/reify-0.14.2.tgz", - "integrity": "sha512-gJA67pCidAROSmr4/8SQuMQXtZwtSvoVIDR6KjoWxnO4LSD8iYNjMcRrHuQQ/c8cXYaoCpEQh0rO9CNNu1z5lA==", + "version": "0.16.2", + "resolved": "https://registry.npmjs.org/reify/-/reify-0.16.2.tgz", + "integrity": "sha512-9kL/IYcFiBbwpQFScNcFBJ5zhCEJTNujeDEEv5SoSg5er0V5CDbef2zNEk9FBeI9oehGOG5zM4APXgp5n3Llbw==", "dev": true, "requires": { - "acorn": "5.5.3", - "minizlib": "1.1.0", - "semver": "5.5.0" + "acorn": "^5.5.3", + "semver": "^5.4.1" } }, - "safe-buffer": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", - "dev": true - }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", @@ -290,28 +257,28 @@ "dev": true }, "supports-color": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz", - "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==", + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", + "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", "dev": true, "requires": { - "has-flag": "2.0.0" + "has-flag": "^3.0.0" } }, "uglify-js": { - "version": "3.3.16", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.3.16.tgz", - "integrity": "sha512-FMh5SRqJRGhv9BbaTffENIpDDQIoPDR8DBraunGORGhySArsXlw9++CN+BWzPBLpoI4RcSnpfGPnilTxWL3Vvg==", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.0.tgz", + "integrity": "sha512-Jcf5naPkX3rVPSQpRn9Vm6Rr572I1gTtR9LnqKgXjmOgfYQ/QS0V2WRStFR53Bdj520M66aCZqt9uzYXgtGrJQ==", "dev": true, "requires": { - "commander": "2.15.1", - "source-map": "0.6.1" + "commander": "~2.15.0", + "source-map": "~0.6.1" } }, "underscore": { - "version": "1.8.3", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz", - "integrity": "sha1-Tz+1OxBuYJf8+ctBCfKl6b36UCI=", + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz", + "integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg==", "dev": true }, "universalify": { @@ -325,12 +292,6 @@ "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true - }, - "yallist": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.2.tgz", - "integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=", - "dev": true } } } From 59b1fb55b59e8eea5eaa7dc70327028db5077658 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Fri, 8 Jun 2018 15:30:50 -0400 Subject: [PATCH 28/53] Run Travis CI tests in Node 10, too. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 732834e..82ef4bb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: node_js sudo: false node_js: + - "10" - "9" - "8" - "7" From c417044421ff3026fa6053663eaea018be7652e2 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Mon, 25 Jun 2018 13:02:15 -0400 Subject: [PATCH 29/53] Try file extensions when resolving index.* modules. --- install.js | 8 ++++---- test/run.js | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/install.js b/install.js index ddc6397..84c19fd 100644 --- a/install.js +++ b/install.js @@ -528,10 +528,10 @@ makeInstaller = function (options) { // consider is that this directory contains an `index.js` module. // This assignment almost always terminates the while loop, because // there's very little chance `fileIsDirectory(file)` will be true - // for the result of `fileAppendIdPart(file, "index.js")`. However, - // in principle it is remotely possible that a file called - // `index.js` could be a directory instead of a file. - file = fileAppendIdPart(file, "index.js"); + // for `fileAppendIdPart(file, "index", extensions)`. However, in + // principle it is remotely possible that a file called `index.js` + // could be a directory instead of a file. + file = fileAppendIdPart(file, "index", extensions); } if (file && isString(file.contents)) { diff --git a/test/run.js b/test/run.js index 58ac71e..c071069 100644 --- a/test/run.js +++ b/test/run.js @@ -1141,4 +1141,45 @@ describe("install", function () { assert.strictEqual(result.id, "/node_modules/pkg/index.js"); assert.strictEqual(result.oyez.id, "/node_modules/pkg/dist/oyez.js"); }); + + it("tolerates index.* modules with alternate extensions", function () { + var extensions = [".js", ".json"]; + var require = makeInstaller({ + extensions, + })({ + "main.js"(require, exports, module) { + exports.json = require("./jsonDir"); + }, + + jsonDir: { + "index.json"(require, exports, module) { + exports.name = module.id; + } + }, + + tsxDir: { + "index.tsx"(require, exports, module) { + exports.name = module.id; + } + } + }); + + var main = require("./main"); + assert.strictEqual(main.json.name, "/jsonDir/index.json"); + + var threw = false; + try { + require("/tsxDir"); + } catch (e) { + threw = true; + assert.strictEqual(e.message, "Cannot find module '/tsxDir'"); + } + assert.strictEqual(threw, true); + + extensions.push(".tsx"); + assert.strictEqual( + require("/tsxDir").name, + "/tsxDir/index.tsx" + ); + }); }); From d52429b017ff158abacd12352d8da83deee1d3f5 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Mon, 25 Jun 2018 13:14:11 -0400 Subject: [PATCH 30/53] Bump npm version to 0.11.1 in preparation for publishing. --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3f88d28..46bad08 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "install", - "version": "0.11.0", + "version": "0.11.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index d556c50..07a6378 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "packager", "install" ], - "version": "0.11.0", + "version": "0.11.1", "license": "MIT", "homepage": "http://github.com/benjamn/install", "repository": { From a630b5c2acbb0ec272692c7fec0667f47b3c1e4a Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Mon, 25 Jun 2018 14:58:37 -0400 Subject: [PATCH 31/53] Implement Module.prototype.require. Not only does this simplify the work of makeRequire (which is called just before every module begins evaluation), but it also removes the need for options.wrapRequire, since Module.prototype.require can be easily wrapped. --- install.js | 62 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/install.js b/install.js index 84c19fd..6a9efe0 100644 --- a/install.js +++ b/install.js @@ -92,10 +92,6 @@ makeInstaller = function (options) { this.childrenById = {}; } - Module.prototype.resolve = function (id) { - return this.require.resolve(id); - }; - // Used to keep module.prefetch promise resolutions well-ordered. var lastPrefetchPromise; @@ -214,24 +210,40 @@ makeInstaller = function (options) { return new Error("Cannot find module '" + id + "'"); } - function makeRequire(file) { - function require(id) { - var result = fileResolve(file, id); - if (result) { - return fileEvaluate(result, file.module); - } + Module.prototype.resolve = function (id) { + var file = fileResolve(filesByModuleId[this.id], id); + if (file) return file.module.id; + var error = makeMissingError(id); + if (fallback && isFunction(fallback.resolve)) { + return fallback.resolve(id, this.id, error); + } + throw error; + }; - var error = makeMissingError(id); + Module.prototype.require = function require(id) { + var result = fileResolve(filesByModuleId[this.id], id); + if (result) { + return fileEvaluate(result, this); + } - if (isFunction(fallback)) { - return fallback( - id, // The missing module identifier. - file.module.id, // The path of the requiring file. - error // The error we would have thrown. - ); - } + var error = makeMissingError(id); - throw error; + if (isFunction(fallback)) { + return fallback( + id, // The missing module identifier. + this.id, // ID of the parent module. + error // The error we would have thrown. + ); + } + + throw error; + }; + + function makeRequire(file) { + var module = file.module; + + function require(id) { + return module.require(id); } if (isFunction(wrapRequire)) { @@ -240,14 +252,8 @@ makeInstaller = function (options) { require.extensions = fileGetExtensions(file).slice(0); - require.resolve = function (id) { - var f = fileResolve(file, id); - if (f) return f.module.id; - var error = makeMissingError(id); - if (fallback && isFunction(fallback.resolve)) { - return fallback.resolve(id, file.module.id, error); - } - throw error; + require.resolve = function resolve(id) { + return module.resolve(id); }; return require; @@ -320,7 +326,7 @@ makeInstaller = function (options) { } contents( - module.require = module.require || makeRequire(file), + makeRequire(file), // If the file had a .stub, reuse the same object for exports. module.exports = file.stub || {}, module, From 325b3bad0787321578e6f8560e757b7fec9fb990 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Mon, 25 Jun 2018 15:37:24 -0400 Subject: [PATCH 32/53] Bump npm version to 0.11.2 in preparation for publishing. --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 46bad08..c88b02b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "install", - "version": "0.11.1", + "version": "0.11.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 07a6378..df98dc6 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "packager", "install" ], - "version": "0.11.1", + "version": "0.11.2", "license": "MIT", "homepage": "http://github.com/benjamn/install", "repository": { From 7a9abeca886c7c201bc96b98225e836326a337a8 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Mon, 25 Jun 2018 15:47:37 -0400 Subject: [PATCH 33/53] Remove options.wrapRequire. --- install.js | 9 --------- test/run.js | 21 --------------------- 2 files changed, 30 deletions(-) diff --git a/install.js b/install.js index 6a9efe0..2e7d0d3 100644 --- a/install.js +++ b/install.js @@ -11,11 +11,6 @@ makeInstaller = function (options) { // new modules are installed. var onInstall = options.onInstall; - // If defined, each module-specific require function will be passed to - // this function, along with the module object of the parent module, and - // the result will be used in place of the original require function. - var wrapRequire = options.wrapRequire; - // If defined, the options.override function will be called before // looking up any top-level package identifiers in node_modules // directories. It can either return a string to provide an alternate @@ -246,10 +241,6 @@ makeInstaller = function (options) { return module.require(id); } - if (isFunction(wrapRequire)) { - require = wrapRequire(require, file.module); - } - require.extensions = fileGetExtensions(file).slice(0); require.resolve = function resolve(id) { diff --git a/test/run.js b/test/run.js index c071069..808f4e2 100644 --- a/test/run.js +++ b/test/run.js @@ -606,27 +606,6 @@ describe("install", function () { ]); }); - it("supports options.wrapRequire", function () { - main.makeInstaller({ - wrapRequire: function (require, parent) { - assert.strictEqual(typeof require, "function"); - assert.strictEqual(typeof parent, "object"); - assert.strictEqual(typeof parent.id, "string"); - - function wrapper() { - return require.apply(this, arguments); - } - - wrapper.parentId = parent.id; - return wrapper; - } - })({ - a: function (require, exports, module) { - assert.strictEqual(require.parentId, module.id); - } - })("./a"); - }); - it("supports options.browser", function () { var require = main.makeInstaller({ browser: true From c8529befe6a82f5070679b0ab01fd0dde1806c95 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Mon, 25 Jun 2018 15:51:10 -0400 Subject: [PATCH 34/53] Remove options.onInstall. --- install.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/install.js b/install.js index 2e7d0d3..2842010 100644 --- a/install.js +++ b/install.js @@ -7,10 +7,6 @@ makeInstaller = function (options) { // if they do not exactly match an installed module. var defaultExtensions = options.extensions || [".js", ".json"]; - // If defined, the options.onInstall function will be called any time - // new modules are installed. - var onInstall = options.onInstall; - // If defined, the options.override function will be called before // looking up any top-level package identifiers in node_modules // directories. It can either return a string to provide an alternate @@ -57,9 +53,6 @@ makeInstaller = function (options) { function install(tree, options) { if (isObject(tree)) { fileMergeContents(root, tree, options); - if (isFunction(onInstall)) { - onInstall(rootRequire); - } } return rootRequire; } From 1836fc46cd06b558ebe677331dcb97a75e44fc50 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Mon, 25 Jun 2018 16:01:29 -0400 Subject: [PATCH 35/53] Remove options.override. --- install.js | 22 +++------------- test/run.js | 76 ----------------------------------------------------- 2 files changed, 4 insertions(+), 94 deletions(-) diff --git a/install.js b/install.js index 2842010..56bab87 100644 --- a/install.js +++ b/install.js @@ -7,13 +7,6 @@ makeInstaller = function (options) { // if they do not exactly match an installed module. var defaultExtensions = options.extensions || [".js", ".json"]; - // If defined, the options.override function will be called before - // looking up any top-level package identifiers in node_modules - // directories. It can either return a string to provide an alternate - // package identifier, or a non-string value to prevent the lookup from - // proceeding. - var override = options.override; - // If defined, the options.fallback function will be called when no // installed module is found for a required module identifier. Often // options.fallback will be implemented in terms of the native Node @@ -534,18 +527,11 @@ makeInstaller = function (options) { }; function nodeModulesLookup(file, id, extensions) { - if (isFunction(override)) { - id = override(id, file.module.id); - } - - if (isString(id)) { - for (var resolved; file && ! resolved; file = file.parent) { - resolved = fileIsDirectory(file) && - fileAppendId(file, "node_modules/" + id, extensions); - } - - return resolved; + for (var resolved; file && ! resolved; file = file.parent) { + resolved = fileIsDirectory(file) && + fileAppendId(file, "node_modules/" + id, extensions); } + return resolved; } return install; diff --git a/test/run.js b/test/run.js index 808f4e2..9918edb 100644 --- a/test/run.js +++ b/test/run.js @@ -410,82 +410,6 @@ describe("install", function () { })("./a"); }); - it("allows package overrides and fallbacks", function () { - var install = main.makeInstaller({ - override: function (id, parentId) { - assert.strictEqual(parentId, "/parent.js"); - - var parts = id.split("/"); - - if (parts[0] === "forbidden") { - return false; - } - - if (parts[0] === "overridden") { - parts[0] = "alternate"; - return parts.join("/"); - } - - return id; - }, - - fallback: function (id, parentId, error) { - assert.strictEqual(id, "forbidden"); - assert.strictEqual(parentId, "/parent.js"); - throw error; - } - }); - - var require = install({ - "parent.js": ["forbidden", "overridden", "alternate", function (require, exports, module) { - var error; - try { - require("forbidden"); - } catch (e) { - error = e; - } - assert.ok(error instanceof Error); - assert.strictEqual(error.message, "Cannot find module 'forbidden'"); - - assert.strictEqual( - require("overridden").name, - "/node_modules/alternate/index.js" - ); - - assert.strictEqual( - require("overridden/index").name, - "/node_modules/alternate/index.js" - ); - - assert.strictEqual( - require("alternate").name, - "/node_modules/alternate/index.js" - ); - - assert.strictEqual( - require(module.id), - exports - ); - }], - - node_modules: { - "forbidden": { - "index.js": function () { - throw new Error("package should have been forbidden"); - } - }, - - "alternate": { - "index.js": function (require, exports, module) { - exports.name = module.id; - } - } - } - }); - - require("./parent"); - }); - it("allows global installation", function () { var install = main.makeInstaller(); From 49679ee935a456a486e14e1371682844cb77cf0d Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Mon, 25 Jun 2018 16:02:50 -0400 Subject: [PATCH 36/53] Simplify calling makeInstaller in tests. --- test/run.js | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/test/run.js b/test/run.js index 9918edb..d0505a1 100644 --- a/test/run.js +++ b/test/run.js @@ -1,10 +1,10 @@ var assert = require("assert"); -var main = require("../install.js"); +var makeInstaller = require("../install.js").makeInstaller; var reify = require("reify/lib/runtime").enable; describe("install", function () { it("binds this to global", function () { - main.makeInstaller()({ + makeInstaller()({ "index.js": function () { assert.strictEqual( Object.prototype.toString.call(this), @@ -15,7 +15,7 @@ describe("install", function () { }); it("permits synchronous require", function () { - var install = main.makeInstaller(); + var install = makeInstaller(); var require = install({ "foo.js": function (require, exports, module) { @@ -52,7 +52,7 @@ describe("install", function () { }); it("supports a variety of relative identifiers", function () { - var install = main.makeInstaller(); + var install = makeInstaller(); var value = {}; function n(require, exports) { @@ -85,7 +85,7 @@ describe("install", function () { }); it("supports global modules", function () { - var install = main.makeInstaller(); + var install = makeInstaller(); install({ node_modules: { @@ -133,7 +133,7 @@ describe("install", function () { var obj = {}; var fun = function () {}; - var require = main.makeInstaller()({ + var require = makeInstaller()({ "object": function (r, e, module) { module.exports = obj; }, @@ -166,7 +166,7 @@ describe("install", function () { it("copes with long dependency chains", function () { var n = 500; var count = 0; - var install = main.makeInstaller({ + var install = makeInstaller({ defer: setImmediate }); @@ -198,7 +198,7 @@ describe("install", function () { }); it("prefers fuzzy files to exact directories", function () { - var install = main.makeInstaller(); + var install = makeInstaller(); var require = install({ "node_modules": { "foo.js": function (r, exports) { @@ -229,7 +229,7 @@ describe("install", function () { it("supports options.fallback", function (done) { var unknown = {}; - var install = main.makeInstaller({ + var install = makeInstaller({ fallback: function (id, parentId, error) { assert.strictEqual(id, "unknown-module"); assert.strictEqual(parentId, "/foo/bar/parent.js"); @@ -257,7 +257,7 @@ describe("install", function () { }); it("supports options.fallback.resolve", function () { - var install = main.makeInstaller({ + var install = makeInstaller({ fallback: { resolve: function (id, parentId, error) { if (id === "assert") return id; @@ -285,7 +285,7 @@ describe("install", function () { }); it("supports symbolic links", function () { - var install = main.makeInstaller(); + var install = makeInstaller(); var require = install({ a: "./dir/c", dir: { @@ -339,7 +339,7 @@ describe("install", function () { }); it("avoids circular package.json resolution chains", function () { - main.makeInstaller()({ + makeInstaller()({ // Module a imports package b, whose package.json file delegates to // package c, whose package.json file delegates to c's own // directory, which contains an index.js file symbolically linked @@ -373,7 +373,7 @@ describe("install", function () { }); it("provides __filename and __dirname", function (done) { - var require = main.makeInstaller()({ + var require = makeInstaller()({ a: { b: { "c.js": function (r, e, m, __filename, __dirname) { @@ -395,7 +395,7 @@ describe("install", function () { }); it("allows alternate extensions", function (done) { - main.makeInstaller()({ + makeInstaller()({ "a.js": function (require) { assert.strictEqual(require("./b").name, "/b.foo"); assert.strictEqual(require("/b").name, "/b.foo"); @@ -411,7 +411,7 @@ describe("install", function () { }); it("allows global installation", function () { - var install = main.makeInstaller(); + var install = makeInstaller(); var require = install({ node_modules: { @@ -440,7 +440,7 @@ describe("install", function () { }); it("supports module.parent", function (done) { - var install = main.makeInstaller(); + var install = makeInstaller(); var require = install({ a: function (require, exports, module) { assert.strictEqual(module.parent.id, "/"); @@ -474,7 +474,7 @@ describe("install", function () { }); it("runs setters", function () { - var install = main.makeInstaller(); + var install = makeInstaller(); var markers = []; var require = install({ a: function (r, exports, module) { @@ -531,7 +531,7 @@ describe("install", function () { }); it("supports options.browser", function () { - var require = main.makeInstaller({ + var require = makeInstaller({ browser: true })({ a: function (require, exports, module) { @@ -556,7 +556,7 @@ describe("install", function () { it("supports pkg.module", function () { function check(makeInstallerOptions) { - var require = main.makeInstaller( + var require = makeInstaller( makeInstallerOptions )({ a: function (require, exports, module) { @@ -627,7 +627,7 @@ describe("install", function () { }); it("exposes require.extensions", function () { - var install = main.makeInstaller({ + var install = makeInstaller({ extensions: [".js", ".json", ".css"] }); From 1acc91833a72adb4f003d2ca4680dce71ed96a7e Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Mon, 25 Jun 2018 16:29:05 -0400 Subject: [PATCH 37/53] Bump npm version to 0.12.0 in preparation for publishing. --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index c88b02b..50e4f99 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "install", - "version": "0.11.2", + "version": "0.12.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index df98dc6..a6d4bee 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "packager", "install" ], - "version": "0.11.2", + "version": "0.12.0", "license": "MIT", "homepage": "http://github.com/benjamn/install", "repository": { From 561c21ac52be181f5729df2cec15e1d1604360dd Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Tue, 26 Jun 2018 15:41:24 -0400 Subject: [PATCH 38/53] Remove deprecated options from README.md. --- README.md | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 1a96664..b477413 100644 --- a/README.md +++ b/README.md @@ -30,22 +30,21 @@ var install = require("install").makeInstaller({ // identifiers if they do not exactly match an installed module. extensions: [".js", ".json"], - // If defined, the options.onInstall function will be called any time - // new modules are installed. - onInstall, - - // If defined, the options.override function will be called before - // looking up any top-level package identifiers in node_modules - // directories. It can return either a string to provide an alternate - // package identifier or a non-string value to prevent the lookup from - // proceeding. - override, - // If defined, the options.fallback function will be called when no // installed module is found for a required module identifier. Often // options.fallback will be implemented in terms of the native Node // require function, which has the ability to load binary modules. - fallback + fallback, + + // Boolean flag indicating whether the installed code will be running in + // a web browser. + browser, + + // List of fields to look for in package.json files to determine the + // main entry module of the package. The first field listed here whose + // value is a string will be used to resolve the entry module. Defaults + // to just ["main"], or ["browser", "main"] if options.browser is true. + mainFields: ["browser", "main"], }); ``` From d7e7df8258797cfe275df2825752f000f2a9c15b Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Tue, 26 Jun 2018 15:41:38 -0400 Subject: [PATCH 39/53] Mention makeInstaller(options).Module in README.md. --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index b477413..abbaadb 100644 --- a/README.md +++ b/README.md @@ -103,5 +103,21 @@ function. If you're using the `install` package in a CommonJS environment like Node, be careful that you don't overwrite the `require` function provided by that system. +If you need to change the behavior of the `module` object that each module +function receives as its third parameter, the shared `Module` constructor +is exposed as a property of the `install` function returned by the +`makeInstaller` factory: + +```js +var install = makeInstaller(options); +var proto = install.Module.prototype; + +// Wrap all Module.prototype.require calls with some sort of logging. +proto.require = wrapWithLogging(proto.require); + +// Add a new method available to all modules via module.newMethod(...). +proto.newMethod = function () {...}; +``` + Many more examples of how to use the `install` package can be found in the [tests](https://github.com/benjamn/install/blob/master/test/run.js). From 0c1897d18fefeba1abe13750f91f4618b7798a7c Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Tue, 26 Jun 2018 15:42:02 -0400 Subject: [PATCH 40/53] Bump npm version to 0.12.1 in preparation for publishing. --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 50e4f99..c954d06 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "install", - "version": "0.12.0", + "version": "0.12.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index a6d4bee..d6b1d1d 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "packager", "install" ], - "version": "0.12.0", + "version": "0.12.1", "license": "MIT", "homepage": "http://github.com/benjamn/install", "repository": { From 31013c32f0fa2355e387935dadc0a4dcb997d71c Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Tue, 26 Jun 2018 15:43:37 -0400 Subject: [PATCH 41/53] Regenerate docs. --- docs/index.html | 342 +++++++++++++++++++----------------------------- 1 file changed, 133 insertions(+), 209 deletions(-) diff --git a/docs/index.html b/docs/index.html index 8cbf3d9..95b4c89 100644 --- a/docs/index.html +++ b/docs/index.html @@ -60,58 +60,6 @@

install.js

-

If defined, the options.onInstall function will be called any time -new modules are installed.

- - - -
  var onInstall = options.onInstall;
- - - - -
  • -
    - -
    - -
    -

    If defined, each module-specific require function will be passed to -this function, along with the module object of the parent module, and -the result will be used in place of the original require function.

    - -
    - -
      var wrapRequire = options.wrapRequire;
    - -
  • - - -
  • -
    - -
    - -
    -

    If defined, the options.override function will be called before -looking up any top-level package identifiers in node_modules -directories. It can either return a string to provide an alternate -package identifier, or a non-string value to prevent the lookup from -proceeding.

    - -
    - -
      var override = options.override;
    - -
  • - - -
  • -
    - -
    - -

    If defined, the options.fallback function will be called when no installed module is found for a required module identifier. Often options.fallback will be implemented in terms of the native Node @@ -124,11 +72,11 @@

    install.js

  • -
  • +
  • - +

    List of fields to look for in package.json files to determine the main entry module of the package. The first field listed here whose @@ -141,11 +89,11 @@

    install.js

  • -
  • +
  • - +

    If options.mainFields is absent and options.browser is truthy, package resolution will prefer the “browser” field of package.json @@ -165,11 +113,11 @@

    install.js

  • -
  • +
  • - +

    Cache for looking up File objects given absolute module identifiers. Invariants: @@ -183,11 +131,11 @@

    install.js

  • -
  • +
  • - +

    The file object representing the root directory of the installed module tree.

    @@ -200,11 +148,11 @@

    install.js

  • -
  • +
  • - +

    Merges the given tree of directories and module factory functions into the tree of installed modules and returns a require function @@ -215,9 +163,6 @@

    install.js

      function install(tree, options) {
         if (isObject(tree)) {
           fileMergeContents(root, tree, options);
    -      if (isFunction(onInstall)) {
    -        onInstall(rootRequire);
    -      }
         }
         return rootRequire;
       }
    @@ -225,11 +170,11 @@

    install.js

  • -
  • +
  • - +

    Replace this function to enable Module.prototype.prefetch.

    @@ -242,11 +187,11 @@

    install.js

  • -
  • +
  • - +

    This constructor will be used to instantiate the module objects passed to module factory functions (i.e. the third argument after @@ -261,11 +206,11 @@

    install.js

  • -
  • +
  • - +

    The Node implementation of module.children unfortunately includes only those child modules that were imported for the first time by @@ -278,11 +223,11 @@

    install.js

  • -
  • +
  • - +

    This object is an install.js extension that includes all child modules imported by this module, even if this module is not the @@ -291,20 +236,16 @@

    install.js

        this.childrenById = {};
    -  }
    -
    -  Module.prototype.resolve = function (id) {
    -    return this.require.resolve(id);
    -  };
    + }
  • -
  • +
  • - +

    Used to keep module.prefetch promise resolutions well-ordered.

    @@ -315,11 +256,11 @@

    install.js

  • -
  • +
  • - +

    May be shared by multiple sequential calls to module.prefetch. Initialized to {} only when necessary.

    @@ -344,11 +285,11 @@

    install.js

  • -
  • +
  • - +

    These are the data that will be exposed to the install.fetch callback, so it’s worth documenting each item with a comment.

    @@ -360,11 +301,11 @@

    install.js

  • -
  • +
  • - +

    The CommonJS module object that will be exposed to this dynamic module when it is evaluated. Note that install.fetch @@ -379,11 +320,11 @@

    install.js

  • -
  • +
  • - +

    List of module identifier strings imported by this module. Note that the missing object already contains all available @@ -400,11 +341,11 @@

    install.js

  • -
  • +
  • - +

    The options (if any) that were passed as the second argument to the install(tree, options) function when this stub was @@ -421,11 +362,11 @@

    install.js

  • -
  • +
  • - +

    Any stub data included in the array notation from the original entry for this dynamic module. Typically contains @@ -455,11 +396,11 @@

    install.js

  • -
  • +
  • - +

    Grab the current missing object and fetch its contents.

    @@ -473,11 +414,11 @@

    install.js

  • -
  • +
  • - +

    The install.fetch function takes an object mapping missing dynamic module identifiers to options objects, and should @@ -498,11 +439,11 @@

    install.js

  • -
  • +
  • - +

    Although we want multiple install.fetch calls to run in parallel, it is important that the promises returned by @@ -541,40 +482,46 @@

    install.js

    return new Error("Cannot find module '" + id + "'"); } - function makeRequire(file) { - function require(id) { - var result = fileResolve(file, id); - if (result) { - return fileEvaluate(result, file.module); - } + Module.prototype.resolve = function (id) { + var file = fileResolve(filesByModuleId[this.id], id); + if (file) return file.module.id; + var error = makeMissingError(id); + if (fallback && isFunction(fallback.resolve)) { + return fallback.resolve(id, this.id, error); + } + throw error; + }; - var error = makeMissingError(id); + Module.prototype.require = function require(id) { + var result = fileResolve(filesByModuleId[this.id], id); + if (result) { + return fileEvaluate(result, this); + } - if (isFunction(fallback)) { - return fallback( - id, // The missing module identifier. - file.module.id, // The path of the requiring file. - error // The error we would have thrown. - ); - } + var error = makeMissingError(id); - throw error; + if (isFunction(fallback)) { + return fallback( + id, // The missing module identifier. + this.id, // ID of the parent module. + error // The error we would have thrown. + ); } - if (isFunction(wrapRequire)) { - require = wrapRequire(require, file.module); + throw error; + }; + + function makeRequire(file) { + var module = file.module; + + function require(id) { + return module.require(id); } require.extensions = fileGetExtensions(file).slice(0); - require.resolve = function (id) { - var f = fileResolve(file, id); - if (f) return f.module.id; - var error = makeMissingError(id); - if (fallback && isFunction(fallback.resolve)) { - return fallback.resolve(id, file.module.id, error); - } - throw error; + require.resolve = function resolve(id) { + return module.resolve(id); }; return require; @@ -583,11 +530,11 @@

    install.js

  • -
  • +
  • - +

    File objects represent either directories or modules that have been installed. When a File respresents a directory, its .contents @@ -613,11 +560,11 @@

    install.js

  • -
  • +
  • - +

    Link to the parent file.

    @@ -628,11 +575,11 @@

    install.js

  • -
  • +
  • - +

    The module object for this File, which will eventually boast an .exports property when/if the file is evaluated.

    @@ -645,11 +592,11 @@

    install.js

  • -
  • +
  • - +

    The .contents of the file can be either (1) an object, if the file represents a directory containing other files; (2) a factory @@ -664,11 +611,11 @@

    install.js

  • -
  • +
  • - +

    Set of module identifiers imported by this module. Note that this set is not necessarily complete, so don’t rely on it unless you @@ -688,11 +635,11 @@

    install.js

  • -
  • +
  • - +

    If this file was installed with array notation, and the array contained one or more objects but no functions, then the combined @@ -717,46 +664,29 @@

    install.js

    if (Array.isArray(children)) { children.push(module); } - }
    - -
  • - - -
  • -
    - -
    - -
    -

    If a Module.prototype.useNode method is defined, give it a chance -to define module.exports based on module.id using Node.

    + } -
    - -
          if (! isFunction(module.useNode) ||
    -          ! module.useNode()) {
    -        contents(
    -          module.require = module.require || makeRequire(file),
    + contents( + makeRequire(file),
  • -
  • +
  • - +

    If the file had a .stub, reuse the same object for exports.

    -
              module.exports = file.stub || {},
    -          module,
    -          file.module.id,
    -          file.parent.module.id
    -        );
    -      }
    +            
            module.exports = file.stub || {},
    +        module,
    +        file.module.id,
    +        file.parent.module.id
    +      );
     
           module.loaded = true;
         }
    @@ -764,11 +694,11 @@

    install.js

  • -
  • +
  • - +

    The module.runModuleSetters method will be deprecated in favor of just module.runSetters: https://github.com/benjamn/reify/pull/160

    @@ -811,11 +741,11 @@

    install.js

  • -
  • +
  • - +

    If the array did not contain a function, merge nothing.

    @@ -831,11 +761,11 @@

    install.js

  • -
  • +
  • - +

    If contents is neither an array nor a function nor a string nor an object, just give up and merge nothing.

    @@ -888,11 +818,11 @@

    install.js

  • -
  • +
  • - +

    Always append relative to a directory.

    @@ -915,11 +845,11 @@

    install.js

  • -
  • +
  • - +

    Only consider multiple file extensions if this part is the last part of a module identifier and not equal to . or .., and there @@ -945,11 +875,11 @@

    install.js

  • -
  • +
  • - +

    Use Array.prototype.every to terminate iteration early if fileAppendIdPart returns a falsy value.

    @@ -981,11 +911,11 @@

    install.js

  • -
  • +
  • - +

    Absolute module identifiers (i.e. those that begin with a / character) are interpreted relative to the root directory, which @@ -999,11 +929,11 @@

    install.js

  • -
  • +
  • - +

    Relative module identifiers are interpreted relative to the current file, naturally.

    @@ -1015,11 +945,11 @@

    install.js

  • -
  • +
  • - +

    Top-level module identifiers are interpreted as referring to packages in node_modules directories.

    @@ -1031,11 +961,11 @@

    install.js

  • -
  • +
  • - +

    If the identifier resolves to a directory, we use the same logic as Node to find an index.js or package.json file to evaluate.

    @@ -1048,11 +978,11 @@

    install.js

  • -
  • +
  • - +

    If the “main” field of a package.json file resolves to a directory we’ve already considered, then we should not attempt to @@ -1071,17 +1001,16 @@

    install.js

    if (pkg && mainFields.some(function (name) { return isString(main = pkg[name]); - })) { - recordChild(parentModule, pkgJsonFile);
    + })) {
  • -
  • +
  • - +

    The “main” field of package.json does not have to begin with ./ to be considered relative, so first we try simply @@ -1091,19 +1020,21 @@

    install.js

    -
              file = fileAppendId(file, main, extensions) ||
    +            
              var mainFile = fileAppendId(file, main, extensions) ||
                 fileResolve(file, main, parentModule, seenDirFiles);
     
    -          if (file) {
    + if (mainFile) { + file = mainFile; + recordChild(parentModule, pkgJsonFile);
  • -
  • +
  • - +

    The fileAppendId call above may have returned a directory, so continue the loop to make sure we resolve it to a @@ -1119,24 +1050,24 @@

    install.js

  • -
  • +
  • - +

    If we didn’t find a package.json file, or it didn’t have a resolvable .main property, the only possibility left to consider is that this directory contains an index.js module. This assignment almost always terminates the while loop, because there’s very little chance fileIsDirectory(file) will be true -for the result of fileAppendIdPart(file, "index.js"). However, -in principle it is remotely possible that a file called -index.js could be a directory instead of a file.

    +for fileAppendIdPart(file, "index", extensions). However, in +principle it is remotely possible that a file called index.js +could be a directory instead of a file.

    -
          file = fileAppendIdPart(file, "index.js");
    +            
          file = fileAppendIdPart(file, "index", extensions);
         }
     
         if (file && isString(file.contents)) {
    @@ -1149,18 +1080,11 @@ 

    install.js

    }; function nodeModulesLookup(file, id, extensions) { - if (isFunction(override)) { - id = override(id, file.module.id); - } - - if (isString(id)) { - for (var resolved; file && ! resolved; file = file.parent) { - resolved = fileIsDirectory(file) && - fileAppendId(file, "node_modules/" + id, extensions); - } - - return resolved; + for (var resolved; file && ! resolved; file = file.parent) { + resolved = fileIsDirectory(file) && + fileAppendId(file, "node_modules/" + id, extensions); } + return resolved; } return install; From 002133f91b7dec677c37159465424651552e3ba4 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Wed, 1 Aug 2018 00:45:46 +0000 Subject: [PATCH 42/53] chore(package): update reify to version 0.17.2 Closes #47 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d6b1d1d..c0769e7 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "devDependencies": { "docco": "^0.8.0", "mocha": "^5.0.0", - "reify": "^0.16.2", + "reify": "^0.17.2", "uglify-js": "^3.0.12" }, "license": "MIT", From 5ff764269840b2e80637d77d1c6e16e2454b354e Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Wed, 1 Aug 2018 09:31:38 -0400 Subject: [PATCH 43/53] Update package-lock.json. --- package-lock.json | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/package-lock.json b/package-lock.json index c954d06..227ae8d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,9 +5,9 @@ "requires": true, "dependencies": { "acorn": { - "version": "5.6.2", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.6.2.tgz", - "integrity": "sha512-zUzo1E5dI2Ey8+82egfnttyMlMZ2y0D8xOCO3PNPPlYXpl8NZvF6Qk9L9BEtJs+43FqEmfBViDqc5d1ckRDguw==", + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.1.tgz", + "integrity": "sha512-d+nbxBUGKg7Arpsvbnlq61mc12ek3EY8EQldM3GPAhWJ1UVxC6TDGbIvUMNU6obBX3i1+ptCIzV4vq0gFPEGVQ==", "dev": true }, "balanced-match": { @@ -33,9 +33,9 @@ "dev": true }, "commander": { - "version": "2.15.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", - "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", + "version": "2.16.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.16.0.tgz", + "integrity": "sha512-sVXqklSaotK9at437sFlFpyOcJonxe0yST/AG9DkQKUdIE6IqGIMv4SfAQSKaJbSdVEJYItASCrBiVQHq1HQew==", "dev": true }, "concat-map": { @@ -79,9 +79,9 @@ "dev": true }, "fs-extra": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-6.0.1.tgz", - "integrity": "sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.0.tgz", + "integrity": "sha512-EglNDLRpmaTWiD/qraZn6HREAEAHJcJOmxNEYwq6xeMKnVMAy3GUcFB+wXt2C6k4CNvB/mP1y/U3dzvKKj5OtQ==", "dev": true, "requires": { "graceful-fs": "^4.1.2", @@ -211,6 +211,14 @@ "minimatch": "3.0.4", "mkdirp": "0.5.1", "supports-color": "5.4.0" + }, + "dependencies": { + "commander": { + "version": "2.15.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", + "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", + "dev": true + } } }, "ms": { @@ -235,9 +243,9 @@ "dev": true }, "reify": { - "version": "0.16.2", - "resolved": "https://registry.npmjs.org/reify/-/reify-0.16.2.tgz", - "integrity": "sha512-9kL/IYcFiBbwpQFScNcFBJ5zhCEJTNujeDEEv5SoSg5er0V5CDbef2zNEk9FBeI9oehGOG5zM4APXgp5n3Llbw==", + "version": "0.17.2", + "resolved": "https://registry.npmjs.org/reify/-/reify-0.17.2.tgz", + "integrity": "sha512-FUWN1JNaFCrpmUzG+Wf77jf5u1D7ThCdxl1WSHLw9OMUworZnR/l4DL+pM0l7jcePIBxsp+iD7faGsGN+Kxupw==", "dev": true, "requires": { "acorn": "^5.5.3", @@ -266,12 +274,12 @@ } }, "uglify-js": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.0.tgz", - "integrity": "sha512-Jcf5naPkX3rVPSQpRn9Vm6Rr572I1gTtR9LnqKgXjmOgfYQ/QS0V2WRStFR53Bdj520M66aCZqt9uzYXgtGrJQ==", + "version": "3.4.6", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.6.tgz", + "integrity": "sha512-O1D7L6WcOzS1qW2ehopEm4cWm5yA6bQBozlks8jO8ODxYCy4zv+bR/la4Lwp01tpkYGNonnpXvUpYtrvSu8Yzg==", "dev": true, "requires": { - "commander": "~2.15.0", + "commander": "~2.16.0", "source-map": "~0.6.1" } }, @@ -282,9 +290,9 @@ "dev": true }, "universalify": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.1.tgz", - "integrity": "sha1-+nG63UQ3r0wUiEHjs7Fl+enlkLc=", + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", "dev": true }, "wrappy": { From 780df3e10eb72eaf4d2fb6fb3623336f3952dc68 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Wed, 1 Aug 2018 09:31:58 -0400 Subject: [PATCH 44/53] Switch from module.watch to module.link. --- test/run.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/run.js b/test/run.js index d0505a1..f196951 100644 --- a/test/run.js +++ b/test/run.js @@ -480,10 +480,10 @@ describe("install", function () { a: function (r, exports, module) { exports.one = 1; - // Enable module.watch. + // Enable module.link. reify(module); - module.watch(require("./b"), { + module.link("./b", { one: function (v) { markers.push("ab1", v); }, @@ -499,10 +499,10 @@ describe("install", function () { b: function (r, exports, module) { exports.one = 1; - // Enable module.watch. + // Enable module.link. reify(module); - module.watch(require("./a"), { + module.link("./a", { one: function (v) { markers.push("ba1", v); }, @@ -522,6 +522,8 @@ describe("install", function () { }); assert.deepEqual(markers, [ + "ab1", void 0, + "ab2", void 0, "ba1", 1, "ba2", void 0, "ab1", 1, From 8e420c4b31bdaf43d0a580a5f15b1525dd4b71aa Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Sat, 13 Oct 2018 18:15:34 -0400 Subject: [PATCH 45/53] Greenkeeper/reify 0.18.1 (#52) * chore(package): update reify to version 0.18.1 Closes #51 * chore(package): update lockfile package-lock.json --- package-lock.json | 18 +++++++++--------- package.json | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 227ae8d..b2fccdd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,9 +5,9 @@ "requires": true, "dependencies": { "acorn": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.1.tgz", - "integrity": "sha512-d+nbxBUGKg7Arpsvbnlq61mc12ek3EY8EQldM3GPAhWJ1UVxC6TDGbIvUMNU6obBX3i1+ptCIzV4vq0gFPEGVQ==", + "version": "5.7.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz", + "integrity": "sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==", "dev": true }, "balanced-match": { @@ -243,9 +243,9 @@ "dev": true }, "reify": { - "version": "0.17.2", - "resolved": "https://registry.npmjs.org/reify/-/reify-0.17.2.tgz", - "integrity": "sha512-FUWN1JNaFCrpmUzG+Wf77jf5u1D7ThCdxl1WSHLw9OMUworZnR/l4DL+pM0l7jcePIBxsp+iD7faGsGN+Kxupw==", + "version": "0.18.1", + "resolved": "https://registry.npmjs.org/reify/-/reify-0.18.1.tgz", + "integrity": "sha512-eNiNGxo5Cz/s/7DOeQW5+lTAxMexZPFA8XW/ef6f8WBLtQfYAhDNXxva7ROFC/Wa3q91usYzqJYwC85OXaWUzA==", "dev": true, "requires": { "acorn": "^5.5.3", @@ -253,9 +253,9 @@ } }, "semver": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", + "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", "dev": true }, "source-map": { diff --git a/package.json b/package.json index c0769e7..21291b4 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "devDependencies": { "docco": "^0.8.0", "mocha": "^5.0.0", - "reify": "^0.17.2", + "reify": "^0.18.1", "uglify-js": "^3.0.12" }, "license": "MIT", From 146bb3bebad3ca8a99c3bc410b1693e6c05576e3 Mon Sep 17 00:00:00 2001 From: Dominik Date: Tue, 25 Sep 2018 15:08:41 +0200 Subject: [PATCH 46/53] Enable retrying dynamic imports after failure. Fixes https://github.com/meteor/meteor/issues/10182. --- install.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/install.js b/install.js index 56bab87..3cc0f26 100644 --- a/install.js +++ b/install.js @@ -142,6 +142,8 @@ makeInstaller = function (options) { // Grab the current missing object and fetch its contents. var toBeFetched = missing; missing = null; + // Grab file so we can reset pending later + var file = getOwn(filesByModuleId, absChildId); return Promise.resolve( // The install.fetch function takes an object mapping missing @@ -154,6 +156,8 @@ makeInstaller = function (options) { ).then(function (tree) { function both() { install(tree); + // File has been fetched && installed + file.pending = false; return absChildId; } @@ -165,6 +169,12 @@ makeInstaller = function (options) { // Whether previousPromise was resolved or rejected, carry on with // the installation regardless. return previousPromise.then(both, both); + }).catch(function (error) { + // File hasn't been fetch, but we need to reset pending, so + // condition for checking missing file in prefetch walk + // behave appropriately : https://github.com/meteor/meteor/issues/10182 + file.pending = false; + throw new Error(error); }); }); }; From d33b1336e087a92abac7dffc38316d024f2fed88 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Sat, 13 Oct 2018 18:27:22 -0400 Subject: [PATCH 47/53] Reset file.pending for all fetched files. --- install.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/install.js b/install.js index 3cc0f26..3a6c8ba 100644 --- a/install.js +++ b/install.js @@ -142,8 +142,14 @@ makeInstaller = function (options) { // Grab the current missing object and fetch its contents. var toBeFetched = missing; missing = null; - // Grab file so we can reset pending later - var file = getOwn(filesByModuleId, absChildId); + + function clearPending() { + if (toBeFetched) { + Object.keys(toBeFetched).forEach(function (id) { + getOwn(filesByModuleId, id).pending = false; + }); + } + } return Promise.resolve( // The install.fetch function takes an object mapping missing @@ -156,8 +162,7 @@ makeInstaller = function (options) { ).then(function (tree) { function both() { install(tree); - // File has been fetched && installed - file.pending = false; + clearPending(); return absChildId; } @@ -169,12 +174,11 @@ makeInstaller = function (options) { // Whether previousPromise was resolved or rejected, carry on with // the installation regardless. return previousPromise.then(both, both); - }).catch(function (error) { - // File hasn't been fetch, but we need to reset pending, so - // condition for checking missing file in prefetch walk - // behave appropriately : https://github.com/meteor/meteor/issues/10182 - file.pending = false; - throw new Error(error); + + }, function (error) { + // Fixes https://github.com/meteor/meteor/issues/10182. + clearPending(); + throw error; }); }); }; From 3509cc9ccd85d093ebfe20b5f50dece42cd4c83e Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Sat, 13 Oct 2018 19:01:28 -0400 Subject: [PATCH 48/53] Tolerate install.fetch throwing instead of merely rejecting. --- install.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/install.js b/install.js index 3a6c8ba..c962a87 100644 --- a/install.js +++ b/install.js @@ -151,15 +151,15 @@ makeInstaller = function (options) { } } - return Promise.resolve( + return new Promise(function (resolve) { // The install.fetch function takes an object mapping missing // dynamic module identifiers to options objects, and should // return a Promise that resolves to a module tree that can be // installed. As an optimization, if there were no missing dynamic // modules, then we can skip calling install.fetch entirely. - toBeFetched && install.fetch(toBeFetched) + resolve(toBeFetched && install.fetch(toBeFetched)); - ).then(function (tree) { + }).then(function (tree) { function both() { install(tree); clearPending(); From ed1a8038c921d2bf5ec009e356ff761803fb9f47 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Sat, 13 Oct 2018 19:01:48 -0400 Subject: [PATCH 49/53] Add a test of retrying dynamic imports after failure. --- test/run.js | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/test/run.js b/test/run.js index f196951..f93233f 100644 --- a/test/run.js +++ b/test/run.js @@ -981,6 +981,60 @@ describe("install", function () { }); }); + it("supports retrying dynamic imports after failure", function () { + var install = makeInstaller(); + + var threw = false; + install.fetch = function (ids) { + if (! threw) { + threw = true; + debugger; + throw new Error("network failure, or something"); + } + + var tree = {}; + + Object.keys(ids).forEach(function (id) { + var info = ids[id]; + assert.strictEqual(info.module.id, id); + addToTree(tree, id, function (r, exports, module) { + assert.strictEqual(module, info.module); + exports.name = module.id; + }); + }); + + return tree; + }; + + var require = install({ + "main.js": function (require, exports, module) { + exports.attempt = function (id) { + return module.prefetch(id); + }; + }, + "a.js": ["./c", "./b"], + "b.js": ["./a", "./c"], + "c.js": ["./a", "./b"] + }); + + var attempt = require("./main").attempt; + + return attempt("./a").then(function () { + throw new Error("should have failed"); + }, function (error) { + assert.strictEqual(threw, true); + assert.strictEqual( + error.message, + "network failure, or something" + ); + + return attempt("./c").then(function (id) { + assert.strictEqual(id, "/c.js"); + assert.strictEqual(require("./c").name, id); + }); + }); + }); + it("respects module.exports before file.contents", function () { var install = makeInstaller(); From 95756facbe6779dd296d527b4735cdb2780b5335 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Sat, 13 Oct 2018 19:10:36 -0400 Subject: [PATCH 50/53] Switch from uglify-js to terser. --- package-lock.json | 43 ++++++++++++++++++++++++++++++++++--------- package.json | 2 +- scripts/prepublish.sh | 2 +- 3 files changed, 36 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index b2fccdd..ddc6a81 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,6 +32,12 @@ "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", "dev": true }, + "buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", + "dev": true + }, "commander": { "version": "2.16.0", "resolved": "https://registry.npmjs.org/commander/-/commander-2.16.0.tgz", @@ -181,13 +187,13 @@ }, "minimist": { "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", "dev": true }, "mkdirp": { "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, "requires": { @@ -215,7 +221,7 @@ "dependencies": { "commander": { "version": "2.15.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", + "resolved": "http://registry.npmjs.org/commander/-/commander-2.15.1.tgz", "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", "dev": true } @@ -264,6 +270,16 @@ "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, + "source-map-support": { + "version": "0.5.9", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.9.tgz", + "integrity": "sha512-gR6Rw4MvUlYy83vP0vxoVNzM6t8MUXqNuRsuBmBHQDu1Fh6X015FrLdgoDKcNdkwGubozq0P4N0Q37UyFVr1EA==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, "supports-color": { "version": "5.4.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", @@ -273,14 +289,23 @@ "has-flag": "^3.0.0" } }, - "uglify-js": { - "version": "3.4.6", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.6.tgz", - "integrity": "sha512-O1D7L6WcOzS1qW2ehopEm4cWm5yA6bQBozlks8jO8ODxYCy4zv+bR/la4Lwp01tpkYGNonnpXvUpYtrvSu8Yzg==", + "terser": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/terser/-/terser-3.10.0.tgz", + "integrity": "sha512-hNh2WR3YxtKoY7BNSb3+CJ9Xv9bbUuOU9uriIf2F1tiAYNA4rNy2wWuSDV8iKcag27q65KPJ/sPpMWEh6qttgw==", "dev": true, "requires": { - "commander": "~2.16.0", - "source-map": "~0.6.1" + "commander": "~2.17.1", + "source-map": "~0.6.1", + "source-map-support": "~0.5.6" + }, + "dependencies": { + "commander": { + "version": "2.17.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.17.1.tgz", + "integrity": "sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg==", + "dev": true + } } }, "underscore": { diff --git a/package.json b/package.json index 21291b4..3e8bfa5 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "docco": "^0.8.0", "mocha": "^5.0.0", "reify": "^0.18.1", - "uglify-js": "^3.0.12" + "terser": "^3.10.0" }, "license": "MIT", "engines": { diff --git a/scripts/prepublish.sh b/scripts/prepublish.sh index ec40961..a8da219 100755 --- a/scripts/prepublish.sh +++ b/scripts/prepublish.sh @@ -2,4 +2,4 @@ cd $(dirname $0)/.. -uglifyjs install.js -c -m > install.min.js +terser install.js -c -m > install.min.js From d2c369d69e75e27c1b6fb37afda198144bf0f24e Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Sat, 13 Oct 2018 19:11:51 -0400 Subject: [PATCH 51/53] Update package-lock.json. --- package-lock.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index ddc6a81..637ddd9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -39,9 +39,9 @@ "dev": true }, "commander": { - "version": "2.16.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.16.0.tgz", - "integrity": "sha512-sVXqklSaotK9at437sFlFpyOcJonxe0yST/AG9DkQKUdIE6IqGIMv4SfAQSKaJbSdVEJYItASCrBiVQHq1HQew==", + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.19.0.tgz", + "integrity": "sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==", "dev": true }, "concat-map": { @@ -140,9 +140,9 @@ "dev": true }, "highlight.js": { - "version": "9.12.0", - "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-9.12.0.tgz", - "integrity": "sha1-5tnb5Xy+/mB1HwKvM2GVhwyQwB4=", + "version": "9.13.0", + "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-9.13.0.tgz", + "integrity": "sha512-2B90kcNnErqRTmzdZw6IPLEC9CdsiIMhj+r8L3LJKRCgtEJ+LY5yzWuQCVnADTI0wwocQinFzaaL/JjTQNqI/g==", "dev": true }, "inflight": { @@ -171,9 +171,9 @@ } }, "marked": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/marked/-/marked-0.4.0.tgz", - "integrity": "sha512-tMsdNBgOsrUophCAFQl0XPe6Zqk/uy9gnue+jIIKhykO51hxyu6uNx7zBPy0+y/WKYVZZMspV9YeXLNdKk+iYw==", + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/marked/-/marked-0.5.1.tgz", + "integrity": "sha512-iUkBZegCZou4AdwbKTwSW/lNDcz5OuRSl3qdcl31Ia0B2QPG0Jn+tKblh/9/eP9/6+4h27vpoh8wel/vQOV0vw==", "dev": true }, "minimatch": { From d173487a019af67105ae678b68cde7172a613b74 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Sat, 13 Oct 2018 19:13:52 -0400 Subject: [PATCH 52/53] Bump npm version to 0.12.2 in preparation for publishing. --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 637ddd9..ff98716 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "install", - "version": "0.12.1", + "version": "0.12.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 3e8bfa5..de66fcb 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "email": "bn@cs.stanford.edu" }, "name": "install", + "version": "0.12.2", "description": "Minimal JavaScript module loader", "keywords": [ "modules", @@ -15,7 +16,6 @@ "packager", "install" ], - "version": "0.12.1", "license": "MIT", "homepage": "http://github.com/benjamn/install", "repository": { From fefe375868ce52ec6f6c3230e439d0ac33405a8d Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Sat, 13 Oct 2018 19:16:06 -0400 Subject: [PATCH 53/53] Regenerate docs. --- docs/index.html | 117 +++++++++++++++++++++++++++++------------------- 1 file changed, 72 insertions(+), 45 deletions(-) diff --git a/docs/index.html b/docs/index.html index 95b4c89..c662402 100644 --- a/docs/index.html +++ b/docs/index.html @@ -409,7 +409,15 @@

    install.js

          var toBeFetched = missing;
           missing = null;
     
    -      return Promise.resolve(
    + function clearPending() { + if (toBeFetched) { + Object.keys(toBeFetched).forEach(function (id) { + getOwn(filesByModuleId, id).pending = false; + }); + } + } + + return new Promise(function (resolve) {
  • @@ -428,11 +436,12 @@

    install.js

    -
            toBeFetched && install.fetch(toBeFetched)
    +            
            resolve(toBeFetched && install.fetch(toBeFetched));
     
    -      ).then(function (tree) {
    +      }).then(function (tree) {
             function both() {
               install(tree);
    +          clearPending();
               return absChildId;
             }
    @@ -456,6 +465,24 @@

    install.js

            return previousPromise.then(both, both);
    +
    +      }, function (error) {
    + + + + +
  • + + +
            clearPending();
    +        throw error;
           });
         });
       };
    @@ -530,11 +557,11 @@ 

    install.js

  • -
  • +
  • - +

    File objects represent either directories or modules that have been installed. When a File respresents a directory, its .contents @@ -560,11 +587,11 @@

    install.js

  • -
  • +
  • - +

    Link to the parent file.

    @@ -575,11 +602,11 @@

    install.js

  • -
  • +
  • - +

    The module object for this File, which will eventually boast an .exports property when/if the file is evaluated.

    @@ -592,11 +619,11 @@

    install.js

  • -
  • +
  • - +

    The .contents of the file can be either (1) an object, if the file represents a directory containing other files; (2) a factory @@ -611,11 +638,11 @@

    install.js

  • -
  • +
  • - +

    Set of module identifiers imported by this module. Note that this set is not necessarily complete, so don’t rely on it unless you @@ -635,11 +662,11 @@

    install.js

  • -
  • +
  • - +

    If this file was installed with array notation, and the array contained one or more objects but no functions, then the combined @@ -672,11 +699,11 @@

    install.js

  • -
  • +
  • - +

    If the file had a .stub, reuse the same object for exports.

    @@ -694,11 +721,11 @@

    install.js

  • -
  • +
  • - +

    The module.runModuleSetters method will be deprecated in favor of just module.runSetters: https://github.com/benjamn/reify/pull/160

    @@ -741,11 +768,11 @@

    install.js

  • -
  • +
  • - +

    If the array did not contain a function, merge nothing.

    @@ -761,11 +788,11 @@

    install.js

  • -
  • +
  • - +

    If contents is neither an array nor a function nor a string nor an object, just give up and merge nothing.

    @@ -818,11 +845,11 @@

    install.js

  • -
  • +
  • - +

    Always append relative to a directory.

    @@ -845,11 +872,11 @@

    install.js

  • -
  • +
  • - +

    Only consider multiple file extensions if this part is the last part of a module identifier and not equal to . or .., and there @@ -875,11 +902,11 @@

    install.js

  • -
  • +
  • - +

    Use Array.prototype.every to terminate iteration early if fileAppendIdPart returns a falsy value.

    @@ -911,11 +938,11 @@

    install.js

  • -
  • +
  • - +

    Absolute module identifiers (i.e. those that begin with a / character) are interpreted relative to the root directory, which @@ -929,11 +956,11 @@

    install.js

  • -
  • +
  • - +

    Relative module identifiers are interpreted relative to the current file, naturally.

    @@ -945,11 +972,11 @@

    install.js

  • -
  • +
  • - +

    Top-level module identifiers are interpreted as referring to packages in node_modules directories.

    @@ -961,11 +988,11 @@

    install.js

  • -
  • +
  • - +

    If the identifier resolves to a directory, we use the same logic as Node to find an index.js or package.json file to evaluate.

    @@ -978,11 +1005,11 @@

    install.js

  • -
  • +
  • - +

    If the “main” field of a package.json file resolves to a directory we’ve already considered, then we should not attempt to @@ -1006,11 +1033,11 @@

    install.js

  • -
  • +
  • - +

    The “main” field of package.json does not have to begin with ./ to be considered relative, so first we try simply @@ -1030,11 +1057,11 @@

    install.js

  • -
  • +
  • - +

    The fileAppendId call above may have returned a directory, so continue the loop to make sure we resolve it to a @@ -1050,11 +1077,11 @@

    install.js

  • -
  • +
  • - +

    If we didn’t find a package.json file, or it didn’t have a resolvable .main property, the only possibility left to