Comparing version 0.9.2 to 0.9.3
@@ -99,3 +99,3 @@ makeInstaller = function (options) { | ||
var parentFile = getOwn(filesByModuleId, this.id); | ||
var missing = {}; | ||
var missing; // Initialized to {} only if necessary. | ||
@@ -106,2 +106,3 @@ function walk(module) { | ||
file.pending = true; | ||
missing = missing || {}; | ||
missing[file.module.id] = file.options; | ||
@@ -122,2 +123,10 @@ each(file.deps, function (parentId, id) { | ||
var absChildId = childFile.module.id; | ||
if (! missing) { | ||
// If there were no missing dynamic modules, we can skip calling | ||
// install.fetch entirely. | ||
return Promise.resolve(absChildId); | ||
} | ||
// The install.fetch function takes an object mapping missing dynamic | ||
@@ -132,3 +141,3 @@ // module identifiers to options objects, and should return a Promise | ||
// form of the given identifier. | ||
return childFile.module.id; | ||
return absChildId; | ||
}); | ||
@@ -135,0 +144,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
makeInstaller=function(n){"use strict";function e(n,e){return o(n)&&(p(M,n,e),u(I)&&I(O)),O}function t(n){this.id=n,this.children=[],this.childrenById={}}function r(n,e){return B.call(n,e)&&n[e]}function o(n){return"object"==typeof n&&null!==n}function u(n){return"function"==typeof n}function i(n){return"string"==typeof n}function s(n){return new Error("Cannot find module '"+n+"'")}function c(n){function e(e){var t=b(n,e);if(t)return f(t,n.module);var r=s(e);if(u(A))return A(e,n.module.id,r);throw r}return u(g)&&(e=g(e,n.module.id)),e.extensions=h(n).slice(0),e.resolve=function(e){var t=b(n,e);if(t)return t.module.id;var r=s(e);if(A&&u(A.resolve))return A.resolve(e,n.module.id,r);throw r},e}function l(n,e){var r=this;r.parent=e=e||null,r.module=new t(n),E[n]=r,r.contents=null,r.deps={}}function f(n,e){var t=n.contents,r=n.module;if(!t){if(n.stub)return n.stub;throw s(r.id)}if(!B.call(r,"exports")){if(e){r.parent=e;var o=e.children;Array.isArray(o)&&o.push(r)}u(r.useNode)&&r.useNode()||t(r.require=r.require||c(n),r.exports=n.stub||{},r,n.module.id,n.parent.module.id),r.loaded=!0}return u(r.runModuleSetters)&&r.runModuleSetters(),r.exports}function d(n){return n&&o(n.contents)}function a(n){return n&&null===n.contents}function p(n,e,t){Array.isArray(e)?(e.forEach(function(t){i(t)?n.deps[t]=n.module.id:u(t)?e=t:o(t)&&(n.stub=n.stub||{},m(t,function(e,t){n.stub[t]=e}))}),u(e)||(e=null)):u(e)||i(e)||o(e)||(e=null),e&&(n.contents=n.contents||(o(e)?{}:e),o(e)&&d(n)&&m(e,function(e,o){if(".."===o)u=n.parent;else{var u=r(n.contents,o);u||(u=n.contents[o]=new l(n.module.id.replace(/\/*$/,"/")+o,n),u.options=t)}p(u,e,t)}))}function m(n,e,t){Object.keys(n).forEach(function(t){e.call(this,n[t],t)},t)}function h(n){return n.options&&n.options.extensions||j}function v(n,e,t){for(;n&&!d(n);)n=n.parent;if(!n||!e||"."===e)return n;if(".."===e)return n.parent;var o=r(n.contents,e);if(t&&(!o||d(o)))for(var u=0;u<t.length;++u){var i=r(n.contents,e+t[u]);if(i&&!d(i))return i}return o}function y(n,e,t){var r=e.split("/");return r.every(function(e,o){return n=o<r.length-1?v(n,e):v(n,e,t)}),n}function w(n,e){var t=e&&e.module;n&&t&&(n.childrenById[t.id]=t)}function b(n,e,t,r){var t=t||n.module,o=h(n);for(n="/"===e.charAt(0)?y(M,e,o):"."===e.charAt(0)?y(n,e,o):x(n,e,o);d(n);){if(r=r||[],r.indexOf(n)<0){r.push(n);var u,s=v(n,"package.json"),c=s&&f(s,t);if(c&&q.some(function(n){return i(u=c[n])})&&(w(t,s),n=y(n,u,o)||b(n,u,t,r)))continue}n=v(n,"index.js")}return n&&i(n.contents)&&(n=b(n,n.contents,t,r)),w(t,n),n}function x(n,e,t){if(u(k)&&(e=k(e,n.module.id)),i(e)){for(var r;n&&!r;n=n.parent)r=d(n)&&y(n,"node_modules/"+e,t);return r}}n=n||{};var j=n.extensions||[".js",".json"],I=n.onInstall,g=n.wrapRequire,k=n.override,A=n.fallback,q=n.mainFields||(n.browser?["browser","main"]:["main"]),B={}.hasOwnProperty,E={},M=new l("/",new l("/..")),O=c(M);return e.fetch=function(){throw new Error("fetch not implemented")},t.prototype.resolve=function(n){return this.require.resolve(n)},t.prototype.prefetch=function(n){function t(n){var e=r(E,n.id);a(e)&&!e.pending&&(e.pending=!0,u[e.module.id]=e.options,m(e.deps,function(n,t){b(e,t,e.module)}),m(e.module.childrenById,t))}var o=r(E,this.id),u={},i=b(o,n,o.module);return i?(m(o.module.childrenById,t),Promise.resolve(e.fetch(u)).then(e).then(function(){return i.module.id})):Promise.reject(s(n))},e.Module=t,e},"object"==typeof exports&&(exports.makeInstaller=makeInstaller); | ||
makeInstaller=function(n){"use strict";function e(n,e){return o(n)&&(p(P,n,e),u(I)&&I(M)),M}function r(n){this.id=n,this.children=[],this.childrenById={}}function t(n,e){return B.call(n,e)&&n[e]}function o(n){return"object"==typeof n&&null!==n}function u(n){return"function"==typeof n}function i(n){return"string"==typeof n}function s(n){return new Error("Cannot find module '"+n+"'")}function c(n){function e(e){var r=b(n,e);if(r)return f(r,n.module);var t=s(e);if(u(A))return A(e,n.module.id,t);throw t}return u(g)&&(e=g(e,n.module.id)),e.extensions=h(n).slice(0),e.resolve=function(e){var r=b(n,e);if(r)return r.module.id;var t=s(e);if(A&&u(A.resolve))return A.resolve(e,n.module.id,t);throw t},e}function l(n,e){var t=this;t.parent=e=e||null,t.module=new r(n),E[n]=t,t.contents=null,t.deps={}}function f(n,e){var r=n.contents,t=n.module;if(!r){if(n.stub)return n.stub;throw s(t.id)}if(!B.call(t,"exports")){if(e){t.parent=e;var o=e.children;Array.isArray(o)&&o.push(t)}u(t.useNode)&&t.useNode()||r(t.require=t.require||c(n),t.exports=n.stub||{},t,n.module.id,n.parent.module.id),t.loaded=!0}return u(t.runModuleSetters)&&t.runModuleSetters(),t.exports}function d(n){return n&&o(n.contents)}function a(n){return n&&null===n.contents}function p(n,e,r){Array.isArray(e)?(e.forEach(function(r){i(r)?n.deps[r]=n.module.id:u(r)?e=r:o(r)&&(n.stub=n.stub||{},m(r,function(e,r){n.stub[r]=e}))}),u(e)||(e=null)):u(e)||i(e)||o(e)||(e=null),e&&(n.contents=n.contents||(o(e)?{}:e),o(e)&&d(n)&&m(e,function(e,o){if(".."===o)u=n.parent;else{var u=t(n.contents,o);u||(u=n.contents[o]=new l(n.module.id.replace(/\/*$/,"/")+o,n),u.options=r)}p(u,e,r)}))}function m(n,e,r){Object.keys(n).forEach(function(r){e.call(this,n[r],r)},r)}function h(n){return n.options&&n.options.extensions||j}function v(n,e,r){for(;n&&!d(n);)n=n.parent;if(!n||!e||"."===e)return n;if(".."===e)return n.parent;var o=t(n.contents,e);if(r&&(!o||d(o)))for(var u=0;u<r.length;++u){var i=t(n.contents,e+r[u]);if(i&&!d(i))return i}return o}function y(n,e,r){var t=e.split("/");return t.every(function(e,o){return n=o<t.length-1?v(n,e):v(n,e,r)}),n}function w(n,e){var r=e&&e.module;n&&r&&(n.childrenById[r.id]=r)}function b(n,e,r,t){var r=r||n.module,o=h(n);for(n="/"===e.charAt(0)?y(P,e,o):"."===e.charAt(0)?y(n,e,o):x(n,e,o);d(n);){if(t=t||[],t.indexOf(n)<0){t.push(n);var u,s=v(n,"package.json"),c=s&&f(s,r);if(c&&q.some(function(n){return i(u=c[n])})&&(w(r,s),n=y(n,u,o)||b(n,u,r,t)))continue}n=v(n,"index.js")}return n&&i(n.contents)&&(n=b(n,n.contents,r,t)),w(r,n),n}function x(n,e,r){if(u(k)&&(e=k(e,n.module.id)),i(e)){for(var t;n&&!t;n=n.parent)t=d(n)&&y(n,"node_modules/"+e,r);return t}}n=n||{};var j=n.extensions||[".js",".json"],I=n.onInstall,g=n.wrapRequire,k=n.override,A=n.fallback,q=n.mainFields||(n.browser?["browser","main"]:["main"]),B={}.hasOwnProperty,E={},P=new l("/",new l("/..")),M=c(P);return e.fetch=function(){throw new Error("fetch not implemented")},r.prototype.resolve=function(n){return this.require.resolve(n)},r.prototype.prefetch=function(n){function r(n){var e=t(E,n.id);a(e)&&!e.pending&&(e.pending=!0,o=o||{},o[e.module.id]=e.options,m(e.deps,function(n,r){b(e,r,e.module)}),m(e.module.childrenById,r))}var o,u=t(E,this.id),i=b(u,n,u.module);if(!i)return Promise.reject(s(n));m(u.module.childrenById,r);var c=i.module.id;return o?Promise.resolve(e.fetch(o)).then(e).then(function(){return c}):Promise.resolve(c)},e.Module=r,e},"object"==typeof exports&&(exports.makeInstaller=makeInstaller); |
@@ -18,3 +18,3 @@ { | ||
], | ||
"version": "0.9.2", | ||
"version": "0.9.3", | ||
"license": "MIT", | ||
@@ -21,0 +21,0 @@ "homepage": "http://github.com/benjamn/install", |
428336
1168