Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

browser-resolve

Package Overview
Dependencies
Maintainers
1
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 0.0.0 to 0.0.1

README.md

36

index.js

@@ -35,5 +35,8 @@ // builtin

var paths = parent.paths.map(function(p) {
return path.dirname(p);
});
var paths = [];
if (parent && parent.paths) {
paths = parent.paths.map(function(p) {
return path.dirname(p);
});
}

@@ -60,4 +63,4 @@ // TODO(shtylman) if id has no leading '.' then it will be

Object.keys(info.browser).forEach(function(key) {
val = path.resolve(paths[i], info.browser[key]);
key = path.resolve(paths[i], key);
var val = path.resolve(paths[i], info.browser[key]);
var key = path.resolve(paths[i], key);
shims[key] = val;

@@ -70,14 +73,25 @@ });

// if browser field is an object tho?
var full = resv.sync(id, {
var full = resv(id, {
paths: parent.paths,
basedir: base,
packageFilter: function(info) {
// if info.browser is an object?
info.main = info.browser;
// no browser field, keep info unchanged
if (!info.browser) {
return info;
}
// replace main
if (typeof info.browser === 'string') {
info.main = info.browser;
return info;
}
var replace_main = info.browser[info.main || './index.js'];
info.main = replace_main || info.main;
return info;
}
}, function(err, full) {
var resolved = (shims) ? shims[full] || full : full;
cb(null, resolved);
});
var resolved = (shims) ? shims[full] || full : full;
cb(null, resolved);
};

@@ -84,0 +98,0 @@

{
"name": "browser-resolve",
"version": "0.0.0",
"version": "0.0.1",
"description": "resolve which handles browser field support in package.json",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "mocha test/*.js"
},

@@ -20,3 +20,3 @@ "repository": {

"dependencies": {
"resolve": "0.2.3",
"resolve": "0.3.0",
"console-browserify": "0.1.6",

@@ -28,3 +28,6 @@ "vm-browserify": "0.0.1",

"zlib-browserify": "0.0.1"
},
"devDependencies": {
"mocha": "1.8.1"
}
}
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