browser-resolve
Advanced tools
Comparing version 1.8.1 to 1.8.2
43
index.js
@@ -18,3 +18,3 @@ // builtin | ||
var dir = path.join.apply( | ||
path, parts.slice(0, i + 1).concat(["node_modules"]) | ||
path, parts.slice(0, i + 1).concat(['node_modules']) | ||
); | ||
@@ -174,23 +174,23 @@ if (!parts[0].match(/([A-Za-z]:)/)) { | ||
opts.pathFilter = function(info, path, relativePath) { | ||
if(relativePath[0] != '.') { | ||
relativePath = './' + relativePath; | ||
} | ||
var mappedPath; | ||
if(pathFilter) { | ||
mappedPath = pathFilter.apply(this, arguments); | ||
} | ||
if(mappedPath) { | ||
return mappedPath; | ||
} | ||
if(!info.browser) { | ||
return; | ||
} | ||
if (relativePath[0] != '.') { | ||
relativePath = './' + relativePath; | ||
} | ||
var mappedPath; | ||
if (pathFilter) { | ||
mappedPath = pathFilter.apply(this, arguments); | ||
} | ||
if (mappedPath) { | ||
return mappedPath; | ||
} | ||
if(typeof info.browser) { | ||
mappedPath = info.browser[relativePath]; | ||
if(!mappedPath && (relativePath.lastIndexOf(".js") === relativePath.length-3) ) { | ||
mappedPath = info.browser[relativePath+".js"]; | ||
} | ||
return mappedPath; | ||
} | ||
var replacements = info[browser]; | ||
if (!replacements) { | ||
return; | ||
} | ||
mappedPath = replacements[relativePath]; | ||
if (!mappedPath && (relativePath.lastIndexOf('.js') === relativePath.length - 3)) { | ||
mappedPath = replacements[relativePath + '.js']; | ||
} | ||
return mappedPath; | ||
}; | ||
@@ -329,2 +329,1 @@ | ||
module.exports = resolve; | ||
{ | ||
"name": "browser-resolve", | ||
"version": "1.8.1", | ||
"version": "1.8.2", | ||
"description": "resolve which handles browser field support in package.json", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -7,4 +7,6 @@ { | ||
"chromeapp": { | ||
"url": "./url-chromeapp.js" | ||
"url": "./url-chromeapp.js", | ||
"./index.js": "./chromeapp.js", | ||
"./direct": "./chromeapp-direct.js" | ||
} | ||
} |
@@ -253,1 +253,14 @@ var assert = require('assert'); | ||
}); | ||
test('alt-browser deep module reference mapping', function(done) { | ||
resolve('alt-browser-field/direct', { | ||
basedir: __dirname + '/fixtures', | ||
package: { main: 'fixtures' }, | ||
browser: 'chromeapp' | ||
}, function(err, path, pkg) { | ||
assert.ifError(err); | ||
assert.equal(path, require.resolve('./fixtures/node_modules/alt-browser-field/chromeapp-direct')); | ||
assert.equal(pkg.main, './chromeapp.js'); | ||
done(); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39145
79
901