🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

browser-resolve

Package Overview
Dependencies
Maintainers
40
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

to
2.0.0

CHANGELOG.md

10

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

@@ -11,7 +11,7 @@ "main": "index.js",

"scripts": {
"test": "mocha --reporter list test/*.js"
"test": "node scripts/setup-symlinks.js && mocha --reporter list test/*.js"
},
"repository": {
"type": "git",
"url": "git://github.com/shtylman/node-browser-resolve.git"
"url": "git://github.com/browserify/browser-resolve.git"
},

@@ -25,7 +25,7 @@ "keywords": [

"dependencies": {
"resolve": "1.1.7"
"resolve": "^1.17.0"
},
"devDependencies": {
"mocha": "1.14.0"
"mocha": "^2.5.3"
}
}

@@ -1,2 +0,2 @@

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

@@ -7,3 +7,3 @@ node.js resolve algorithm with [browser field](https://github.com/defunctzombie/package-browser-field-spec) support.

### resolve(id, opts={}, cb)
### bresolve(id, opts={}, cb)

@@ -21,9 +21,9 @@ Resolve a module path and call `cb(err, path [, pkg])`

Options supported by [node-resolve](https://github.com/substack/node-resolve#resolveid-opts-cb) can be used.
Additionally, options supported by [node-resolve](https://github.com/browserify/resolve#resolveid-opts-cb) can be used.
### resolve.sync(id, opts={})
### bresolve.sync(id, opts={})
Same as the async resolve, just uses sync methods.
Options supported by [node-resolve](https://github.com/substack/node-resolve#resolvesyncid-opts) `sync` can be used.
Additionally, options supported by [node-resolve](https://github.com/browserify/resolve#resolvesyncid-opts-cb) can be used.

@@ -34,4 +34,4 @@ ## basic usage

``` js
var resolve = require('browser-resolve');
resolve('../', { filename: __filename }, function(err, path) {
var bresolve = require('browser-resolve');
bresolve('../', { filename: __filename }, function(err, path) {
console.log(path);

@@ -43,3 +43,3 @@ });

$ node example/resolve.js
/home/substack/projects/node-browser-resolve/index.js
/home/substack/projects/browser-resolve/index.js
```

@@ -56,4 +56,4 @@

var resolve = require('browser-resolve');
resolve('fs', { modules: shims }, function(err, path) {
var bresolve = require('browser-resolve');
bresolve('http', { modules: shims }, function(err, path) {
console.log(path);

@@ -65,3 +65,3 @@ });

$ node example/builtin.js
/home/substack/projects/node-browser-resolve/builtin/fs.js
/home/substack/projects/browser-resolve/builtin/http.js
```

@@ -72,3 +72,3 @@

``` js
``` json
{

@@ -79,5 +79,2 @@ "name": "custom",

"./main.js": "custom.js"
},
"chromeapp": {
"./main.js": "custom-chromeapp.js"
}

@@ -88,5 +85,5 @@ }

``` js
var resolve = require('browser-resolve');
var parent = { filename: __dirname + '/custom/file.js' /*, browser: 'chromeapp' */ };
resolve('./main.js', parent, function(err, path) {
var bresolve = require('browser-resolve');
var parent = { filename: __dirname + '/custom/file.js' };
bresolve('./main.js', parent, function(err, path) {
console.log(path);

@@ -98,5 +95,27 @@ });

$ node example/custom.js
/home/substack/projects/node-browser-resolve/example/custom/custom.js
/home/substack/projects/browser-resolve/example/custom/custom.js
```
You can use different package.json properties for the resolution, if you want to allow packages to target different environments for example:
``` json
{
"browser": { "./main.js": "custom.js" },
"chromeapp": { "./main.js": "custom-chromeapp.js" }
}
```
``` js
var bresolve = require('browser-resolve');
var parent = { filename: __dirname + '/custom/file.js', browser: 'chromeapp' };
bresolve('./main.js', parent, function(err, path) {
console.log(path);
});
```
```
$ node example/custom.js
/home/substack/projects/browser-resolve/example/custom/custom-chromeapp.js
```
## skip

@@ -136,5 +155,5 @@

``` js
var resolve = require('browser-resolve');
var bresolve = require('browser-resolve');
var parent = { filename: __dirname + '/skip/main.js' };
resolve('tar', parent, function(err, path) {
bresolve('tar', parent, function(err, path) {
console.log(path);

@@ -146,3 +165,3 @@ });

$ node example/skip.js
/home/substack/projects/node-browser-resolve/empty.js
/home/substack/projects/browser-resolve/empty.js
```

@@ -156,4 +175,4 @@

Prior to v1.x this library provided shims for node core modules. These have since been removed. If you want to have alternative core modules provided, use the `modules` option when calling resolve.
Prior to v1.x this library provided shims for node core modules. These have since been removed. If you want to have alternative core modules provided, use the `modules` option when calling `bresolve()`.
This was done to allow package managers to choose which shims they want to use without browser-resolve being the central point of update.