diff --git a/lib/builder.js b/lib/builder.js index d8735a3..9222d72 100644 --- a/lib/builder.js +++ b/lib/builder.js @@ -151,7 +151,7 @@ Builder.prototype.reset = function(baseLoader) { var loaderConfig = loader.config; loader.config = function(cfg) { - loaderConfig.call(loader, cfg); + loaderConfig.call(this, cfg); loader.pluginLoader.config(cfg); loader.configHash = generateConfigHash(loader); }; diff --git a/lib/trace.js b/lib/trace.js index 247377f..2b1c87b 100644 --- a/lib/trace.js +++ b/lib/trace.js @@ -567,11 +567,11 @@ function toCanonicalConditionalEnv(conditionalEnv) { return Promise.all(Object.keys(conditionalEnv).map(function(m) { var negate = m[0] == '~'; var exportIndex = m.lastIndexOf('|'); - var moduleName = m.substring(negate, exportIndex != -1 && exportIndex); + var moduleName = m.substring(negate, exportIndex != -1 ? exportIndex : m.length); return loader.normalize(moduleName) .then(function(normalized) { - var canonicalCondition = (negate ? '~' : '') + getCanonicalName(loader, normalized) + (exportIndex != -1 ? m.substr(exportIndex) : ''); + var canonicalCondition = (negate ? '~' : '') + getCanonicalName(loader, normalized) + (exportIndex != -1 ? m.substr(exportIndex) : '|default'); canonicalConditionalEnv[canonicalCondition] = conditionalEnv[m]; }); }))