{ "name": "browser-resolve", "version": "0.1.1", "description": "resolve which handles browser field support in package.json", "main": "index.js", "scripts": { "test": "mocha 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": "0.3.1", "console-browserify": "0.1.6", "vm-browserify": "0.0.1", "crypto-browserify": "0.2.1", "http-browserify": "0.1.11", "buffer-browserify": "0.0.5", "zlib-browserify": "0.0.1" }, "devDependencies": { "mocha": "1.8.1" }, "readme": "# browser-resolve [![Build Status](https://travis-ci.org/shtylman/node-browser-resolve.png?branch=master)](https://travis-ci.org/shtylman/node-browser-resolve)\n\nnode.js resolve algorithm with [browser](https://gist.github.com/shtylman/4339901) field support.\n\n# example\n\n## relative\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\n\nor if you `require()` core modules you'll get a version that works in browsers:\n\n``` js\nvar resolve = require('browser-resolve');\nresolve('fs', null, 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## custom\n\nand you can use the\n[browser field](https://gist.github.com/shtylman/4339901) to load\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}\n```\n\n``` js\nvar resolve = require('browser-resolve');\nvar parent = { filename: __dirname + '/custom/file.js' };\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/shtylman/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", "readmeFilename": "README.md", "bugs": { "url": "https://github.com/shtylman/node-browser-resolve/issues" }, "_id": "browser-resolve@0.1.1", "dist": { "shasum": "31dadaf32164905ff142eebb8ced14e7d5fe6baf" }, "_from": "browser-resolve@~0.1.1", "_resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-0.1.1.tgz" }