diff --git a/lib/conditionals.js b/lib/conditionals.js index 43f33619..165d588b 100644 --- a/lib/conditionals.js +++ b/lib/conditionals.js @@ -71,6 +71,9 @@ else if (typeof m == 'object' && m + '' == 'Module') m = m['default']; + if (bool && typeof m != 'boolean') + throw new TypeError('Condition ' + serializeCondition(conditionObj) + ' did not resolve to a boolean.'); + return conditionObj.negate ? !m : m; }); } diff --git a/lib/core.js b/lib/core.js index 2b79681e..c4fbea60 100644 --- a/lib/core.js +++ b/lib/core.js @@ -99,14 +99,20 @@ var nodeCoreModules = ['assert', 'buffer', 'child_process', 'cluster', 'console' defines the `decanonicalize` function and normalizes everything into a URL. */ + +function applyMap(name) { + // first run map config + if (name[0] != '.' && name[0] != '/' && !name.match(absURLRegEx)) { + var mapMatch = getMapMatch(this.map, name); + if (mapMatch) + return this.map[mapMatch] + name.substr(mapMatch.length); + } + return name; +} + hook('normalize', function(normalize) { return function(name, parentName) { - // first run map config - if (name[0] != '.' && name[0] != '/' && !name.match(absURLRegEx)) { - var mapMatch = getMapMatch(this.map, name); - if (mapMatch) - name = this.map[mapMatch] + name.substr(mapMatch.length); - } + name = applyMap.call(this, name); // dynamically load node-core modules when requiring `@node/fs` for example if (name.substr(0, 6) == '@node/' && nodeCoreModules.indexOf(name.substr(6)) != -1) { @@ -397,7 +403,7 @@ SystemJSLoader.prototype.config = function(cfg) { throw new TypeError('"' + p + '" is not a valid package name.'); var defaultJSExtension = loader.defaultJSExtensions && p.substr(p.length - 3, 3) != '.js'; - var prop = loader.decanonicalize(p); + var prop = loader.decanonicalize(applyMap(p)); if (defaultJSExtension && prop.substr(prop.length - 3, 3) == '.js') prop = prop.substr(0, prop.length - 3); @@ -440,7 +446,8 @@ SystemJSLoader.prototype.config = function(cfg) { loader[c][p] = v[p]; } else if (c == 'meta') { - loader[c][loader.decanonicalize(p)] = v[p]; + // meta can go through global map + loader[c][loader.decanonicalize(applyMap(p))] = v[p]; } else if (c == 'depCache') { var defaultJSExtension = loader.defaultJSExtensions && p.substr(p.length - 3, 3) != '.js'; diff --git a/lib/plugins.js b/lib/plugins.js index 450cbb0d..025e9900 100644 --- a/lib/plugins.js +++ b/lib/plugins.js @@ -102,7 +102,7 @@ return Promise.all([ loader.normalize(parsed.argument, parentName, true), - loader.normalize(parsed.plugin, parentName, true) + loader.normalize(parsed.plugin, parentName) ]) .then(function(normalized) { return combinePluginParts(loader, normalized[0], normalized[1], checkDefaultExtension(loader, parsed.argument));