diff --git a/ext/npm-convert.js b/ext/npm-convert.js index 625e83fca..47df00be5 100644 --- a/ext/npm-convert.js +++ b/ext/npm-convert.js @@ -122,6 +122,10 @@ function convertPropertyNamesAndValues (context, pkg, map, root, waiting) { if(typeof name !== 'undefined' && typeof val !== 'undefined') { clone[name] = val; } + // keep map entry if the key isn't a package but value might + if (name && typeof val === "undefined") { + clone[name] = map[property]; + } } return clone; } diff --git a/ext/npm-extension.js b/ext/npm-extension.js index ec4b4e207..e4fffd77f 100644 --- a/ext/npm-extension.js +++ b/ext/npm-extension.js @@ -214,8 +214,24 @@ exports.addExtension = function(System){ return oldNormalize.call(this, refPkg.browser[name], parentName, parentAddress, pluginNormalize); } - return oldNormalize.call(this, name, parentName, parentAddress, - pluginNormalize); + // Apply mappings, if they exist in the refPkg + var steal = utils.pkg.config(refPkg); + if (steal && steal.map && typeof steal.map[name] === "string") { + return loader.normalize( + steal.map[name], + parentName, + parentAddress, + pluginNormalize + ); + } else { + return oldNormalize.call( + this, + name, + parentName, + parentAddress, + pluginNormalize + ); + } } return crawl.dep(this.npmContext, parentPkg, refPkg, depPkg, isRoot) .then(createModuleNameAndNormalize); @@ -229,15 +245,14 @@ exports.addExtension = function(System){ if(!parsedModuleName.modulePath) { parsedModuleName.modulePath = utils.pkg.main(depPkg); } - var moduleName = utils.moduleName.create(parsedModuleName); - // Apply mappings, if they exist in the refPkg - var steal = utils.pkg.config(refPkg); - if(steal && steal.map && - typeof steal.map[moduleName] === "string") { - moduleName = steal.map[moduleName]; - } - var p = oldNormalize.call(loader, moduleName, parentName, - parentAddress, pluginNormalize); + + var p = oldNormalize.call( + loader, + utils.moduleName.create(parsedModuleName), + parentName, + parentAddress, + pluginNormalize + ); // For identifiers like ./lib/ save this info as we might // get a 404 and need to retry with lib/index.js diff --git a/test/npm/normalize_test.js b/test/npm/normalize_test.js index bb17d90e0..b1d15deb4 100644 --- a/test/npm/normalize_test.js +++ b/test/npm/normalize_test.js @@ -841,7 +841,7 @@ QUnit.test("descriptive version mismatch error (#1176)", function(assert) { .then(done, helpers.fail(assert, done)); }); -QUnit.skip("'map' configuration where the right-hand identifier is an npm package but the left is not", function(assert){ +QUnit.test("'map' configuration where the right-hand identifier is an npm package but the left is not", function(assert){ var done = assert.async(); var loader = helpers.clone()