browser-resolve
Advanced tools
Comparing version 0.0.0 to 0.0.1
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" | ||
} | ||
} |
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
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
71559
27
2109
2
0
15
1
3
+ Addedresolve@0.3.0(transitive)
- Removedresolve@0.2.3(transitive)
Updatedresolve@0.3.0