Socket
Socket
Sign inDemoInstall

browser-resolve

Package Overview
Dependencies
Maintainers
2
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

browser-resolve - npm Package Compare versions

Comparing version 1.6.0 to 1.7.0

test/fixtures/node_modules/module-l/browser-direct.js

25

index.js

@@ -174,2 +174,27 @@ // builtin

};
var pathFilter = opts.pathFilter;
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(typeof info.browser) {
mappedPath = info.browser[relativePath];
if(!mappedPath && (relativePath.lastIndexOf(".js") === relativePath.length-3) ) {
mappedPath = info.browser[relativePath+".js"];
}
return mappedPath;
}
};

@@ -176,0 +201,0 @@ return opts;

4

package.json
{
"name": "browser-resolve",
"version": "1.6.0",
"version": "1.7.0",
"description": "resolve which handles browser field support in package.json",

@@ -20,3 +20,3 @@ "main": "index.js",

"dependencies": {
"resolve": "1.0.0"
"resolve": "1.1.0"
},

@@ -23,0 +23,0 @@ "devDependencies": {

@@ -7,14 +7,14 @@ # browser-resolve [![Build Status](https://travis-ci.org/defunctzombie/node-browser-resolve.png?branch=master)](https://travis-ci.org/defunctzombie/node-browser-resolve)

### resolve(pkg, opts={}, cb)
### resolve(id, opts={}, cb)
Resolve a module path and call `cb(err, path)`
Resolve a module path and call `cb(err, path [, pkg])`
Options:
* filename - the calling filename where the require call originated (in the source)
* paths - require.paths array to use if nothing is found on the normal node_modules recursive walk
* packageFilter - transform the parsed package.json contents before looking at the "main" field
* modules - object with module id/name -> path mappings to consult before doing manual resolution (use to provide core modules)
* `filename` - the calling filename where the `require()` call originated (in the source)
* `paths` - `require.paths` array to use if nothing is found on the normal `node_modules` recursive walk
* `packageFilter` - transform the parsed `package.json` contents before looking at the `main` field
* `modules` - object with module id/name -> path mappings to consult before doing manual resolution (use to provide core modules)
### resolve.sync(pkg, opts={})
### resolve.sync(id, opts={})

@@ -21,0 +21,0 @@ Same as the async resolve, just uses sync methods.

@@ -76,2 +76,11 @@ var assert = require('assert');

test('deep module reference mapping', function(done) {
resolve('module-l/direct', { basedir: __dirname + '/fixtures', package: { main: 'fixtures' } }, function(err, path, pkg) {
assert.ifError(err);
assert.equal(path, require.resolve('./fixtures/node_modules/module-l/browser-direct'));
assert.equal(pkg.main, './browser.js');
done();
});
});
// browser field in package.json maps ./foo.js -> ./browser.js

@@ -189,3 +198,3 @@ // when we resolve ./foo while in module-e, this mapping should take effect

package: { main: './index.js' },
modules: { url: "wonderland" }
modules: { url: 'wonderland' }
};

@@ -192,0 +201,0 @@ resolve('url', parent, function(err, path, pkg) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc