-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.json
38 lines (38 loc) · 4.57 KB
/
package.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{
"name": "browser-resolve",
"version": "1.9.0",
"description": "resolve which handles browser field support in package.json",
"main": "index.js",
"scripts": {
"test": "mocha --reporter list test/*.js"
},
"repository": {
"type": "git",
"url": "git://github.com/shtylman/node-browser-resolve.git"
},
"keywords": [
"resolve",
"browser"
],
"author": {
"name": "Roman Shtylman",
"email": "shtylman@gmail.com"
},
"license": "MIT",
"dependencies": {
"resolve": "1.1.6"
},
"devDependencies": {
"mocha": "1.14.0"
},
"readme": "# browser-resolve [![Build Status](https://travis-ci.org/defunctzombie/node-browser-resolve.png?branch=master)](https://travis-ci.org/defunctzombie/node-browser-resolve)\n\nnode.js resolve algorithm with [browser](https://gist.github.com/defunctzombie/4339901) field support.\n\n## api\n\n### resolve(id, opts={}, cb)\n\nResolve a module path and call `cb(err, path [, pkg])`\n\nOptions:\n\n* `filename` - the calling filename where the `require()` call originated (in the source)\n* `paths` - `require.paths` array to use if nothing is found on the normal `node_modules` recursive walk\n* `packageFilter` - transform the parsed `package.json` contents before looking at the `main` field\n* `modules` - object with module id/name -> path mappings to consult before doing manual resolution (use to provide core modules)\n* `browser` - the 'browser' property to use from package.json (defaults to 'browser')\n\n### resolve.sync(id, opts={})\n\nSame as the async resolve, just uses sync methods.\n\n## basic usage\n\nyou can resolve files like `require.resolve()`:\n``` js\nvar resolve = require('browser-resolve');\nresolve('../', { filename: __filename }, function(err, path) {\n console.log(path);\n});\n```\n\n```\n$ node example/resolve.js\n/home/substack/projects/node-browser-resolve/index.js\n```\n\n## core modules\n\nBy default, core modules (http, dgram, etc) will return their same name as the path. If you want to have specific paths returned, specify a `modules` property in the options object.\n\n``` js\nvar shims = {\n http: '/your/path/to/http.js'\n};\n\nvar resolve = require('browser-resolve');\nresolve('fs', { modules: shims }, function(err, path) {\n console.log(path);\n});\n```\n\n```\n$ node example/builtin.js\n/home/substack/projects/node-browser-resolve/builtin/fs.js\n```\n\n## browser field\nbrowser-specific versions of modules\n\n``` js\n{\n \"name\": \"custom\",\n \"version\": \"0.0.0\",\n \"browser\": {\n \"./main.js\": \"custom.js\"\n },\n \"chromeapp\": {\n \"./main.js\": \"custom-chromeapp.js\"\n }\n}\n```\n\n``` js\nvar resolve = require('browser-resolve');\nvar parent = { filename: __dirname + '/custom/file.js' /*, browser: 'chromeapp' */ };\nresolve('./main.js', parent, function(err, path) {\n console.log(path);\n});\n```\n\n```\n$ node example/custom.js\n/home/substack/projects/node-browser-resolve/example/custom/custom.js\n```\n\n## skip\n\nYou can skip over dependencies by setting a\n[browser field](https://gist.github.com/defunctzombie/4339901)\nvalue to `false`:\n\n``` json\n{\n \"name\": \"skip\",\n \"version\": \"0.0.0\",\n \"browser\": {\n \"tar\": false\n }\n}\n```\n\nThis is handy if you have code like:\n\n``` js\nvar tar = require('tar');\n\nexports.add = function (a, b) {\n return a + b;\n};\n\nexports.parse = function () {\n return tar.Parse();\n};\n```\n\nso that `require('tar')` will just return `{}` in the browser because you don't\nintend to support the `.parse()` export in a browser environment.\n\n``` js\nvar resolve = require('browser-resolve');\nvar parent = { filename: __dirname + '/skip/main.js' };\nresolve('tar', parent, function(err, path) {\n console.log(path);\n});\n```\n\n```\n$ node example/skip.js\n/home/substack/projects/node-browser-resolve/empty.js\n```\n\n# license\n\nMIT\n\n# upgrade notes\n\nPrior 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.\n\nThis was done to allow package managers to choose which shims they want to use without browser-resolve being the central point of update.\n",
"readmeFilename": "README.md",
"bugs": {
"url": "https://github.com/shtylman/node-browser-resolve/issues"
},
"homepage": "https://github.com/shtylman/node-browser-resolve",
"_id": "browser-resolve@1.9.0",
"_shasum": "a3ab60185582063f8317fe48a1380f2ea81425ec",
"_from": "browser-resolve@>=1.7.1 <2.0.0",
"_resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-1.9.0.tgz"
}