{ "name": "browserify", "version": "2.7.2", "description": "browser-side require() the node way", "main": "index.js", "bin": { "browserify": "bin/cmd.js" }, "repository": { "type": "git", "url": "http://github.com/substack/node-browserify.git" }, "keywords": [ "browser", "require", "commonjs", "commonj-esque", "bundle", "npm", "javascript" ], "dependencies": { "module-deps": "~0.5.0", "browser-pack": "~0.5.0", "shell-quote": "~0.0.1", "through": "~2.2.0", "duplexer": "~0.0.2", "concat-stream": "~0.1.1", "insert-module-globals": "~0.2.0", "syntax-error": "~0.0.0", "browser-resolve": "~0.0.3", "inherits": "~1.0.0", "optimist": "~0.3.5", "JSONStream": "~0.4.3" }, "devDependencies": { "tap": "~0.4.0", "mkdirp": "~0.3.3", "backbone": "~0.9.2", "dnode": "~1.0.3", "seq": "0.3.3", "coffee-script": "~1.5.0" }, "author": { "name": "James Halliday", "email": "mail@substack.net", "url": "http://substack.net" }, "scripts": { "test": "tap test/*.js" }, "license": "MIT", "readme": "# browserify\n\n`require('modules')` in the browser\n\nUse a [node](http://nodejs.org)-style `require()` to organize your browser code\nand load modules installed by [npm](https://npmjs.org).\n\nbrowserify will recursively analyze all the `require()` calls in your app in\norder to build a bundle you can serve up to the browser in a single `` into your\nhtml!\n\n## external requires\n\nYou can just as easily create bundle that will export a `require()` function so\nyou can `require()` modules from another script tag. Here we'll create a\n`bundle.js` with the [through](https://npmjs.org/package/through)\nand [duplexer](https://npmjs.org/package/duplexer) modules.\n\n```\n$ browserify -r through -r duplexer > bundle.js\n```\n\nThen in your page you can do:\n\n``` js\n\n\n```\n\n## multiple bundles\n\nIf browserify finds a `require` function already defined in the page scope, it\nwill fall back to that function if it didn't find any matches in its own set of\nbundled modules.\n\nIn this way you can use browserify to split up bundles among multiple pages to\nget the benefit of caching for shared, infrequently-changing modules, while\nstill being able to use `require()`. Just use a combination of `--external` and\n`--require` to factor out common dependencies.\n\nFor example, if a website with 2 pages, `beep.js`:\n\n``` js\nvar robot = require('./robot');\nconsole.log(robot('beep'));\n```\n\nand `boop.js`:\n\n``` js\nvar robot = require('./robot');\nconsole.log(robot('boop'));\n```\n\nboth depend on `robot.js`:\n\n``` js\nmodule.exports = function (s) { return s.toUpperCase() + '!' };\n```\n\n```\n$ browserify -r ./robot > static/common.js\n$ browserify -x ./robot.js beep.js > static/beep.js\n$ browserify -x ./robot.js boop.js > static/boop.js\n```\n\nThen on the beep page you can have:\n\n``` html\n\n\n```\n\nwhile the boop page can have:\n\n``` html\n\n\n```\n\n# usage\n\n```\nUsage: browserify [entry files] {OPTIONS}\n\nStandard Options:\n\n --outfile, -o Write the browserify bundle to this file.\n If unspecified, browserify prints to stdout.\n\n --require, -r A module name or file to bundle.require()\n Optionally use a colon separator to set the target.\n\n --entry, -e An entry point of your app\n \n --ignore, -i Omit a file from the output bundle.\n\n --external, -x Reference a file from another bundle.\n \n --transform, -t Use a transform module on top-level files.\n \n --command, -c Use a transform command on top-level files.\n\n --help, -h Show this message\n\nAdvanced Options:\n\n --insert-globals, --ig, --fast [default: false]\n\n Skip detection and always insert definitions for process, global,\n __filename, and __dirname.\n \n benefit: faster builds\n cost: extra bytes\n \n --detect-globals, --dg [default: true]\n\n Detect the presence of process, global, __filename, and __dirname and define\n these values when present.\n\n benefit: npm modules more likely to work\n cost: slower builds\n\n --ignore-missing, --im [default: false]\n\n Ignore `require()` statements that don't resolve to anything.\n\n --debug -d [default: false]\n \n Enable source maps that allow you to debug your files separately.\n \nSpecify a parameter.\n```\n\n# compatibility\n\nMany [npm](http://npmjs.org) modules that don't do IO will just work after being\nbrowserified. Others take more work.\n\nMany node built-in modules have been wrapped to work in the browser, but only\nwhen you explicitly `require()` or use their functionality.\n\nWhen you `require()` any of these modules, you will get a browser-specific shim:\n\n* events\n* stream\n* path\n* assert\n* url\n* util\n* querystring\n* buffer\n* buffer_ieee754\n* console\n* [vm](https://github.com/substack/vm-browserify)\n* [http](https://github.com/substack/http-browserify)\n* [crypto](https://github.com/dominictarr/crypto-browserify)\n* [zlib](https://github.com/brianloveswords/zlib-browserify)\n\nAdditionally if you use any of these variables, they\n[will be defined](https://github.com/substack/insert-module-globals)\nin the bundled output in a browser-appropriate way:\n\n* [process](https://github.com/shtylman/node-process)\n* [Buffer](https://github.com/toots/buffer-browserify)\n* global - top-level scope object (window)\n* __filename - file path of the currently executing file\n* __dirname - directory path of the currently executing file\n\n# methods\n\n``` js\nvar browserify = require('browserify')\n```\n\n## var b = browserify(files=[])\n\nCreate a browserify instance `b` from the entry main `files`.\n`files` can be an array of files or a single file.\n\n## b.add(file)\n\nAdd an entry file from `file` that will be executed when the bundle loads.\n\n## b.require(name)\n\nMake `name` available from outside the bundle with `require(name)`.\n\nThe package `name` is anything that can be resolved by `require.resolve()`.\n\n## b.bundle(opts, cb)\n\nBundle the files and their dependencies into a single javascript file.\n\nReturn a readable stream with the javascript file contents or\noptionally specify a `cb(err, src)` to get the buffered results.\n\nWhen `opts.insertGlobals` is true, always insert `process`, `global`,\n`__filename`, and `__dirname` without analyzing the AST for faster builds but\nlarger output bundles. Default false.\n\nWhen `opts.detectGlobals` is true, scan all files for `process`, `global`,\n`__filename`, and `__dirname`, defining as necessary. With this option npm\nmodules are more likely to work but bundling takes longer. Default true.\n\nWhen `opts.debug` is true, add a source map inline to the end of the bundle.\nThis makes debugging easier because you can see all the original files if\nyou are in a modern enough browser.\n\n## b.external(file)\n\nPrevent `file` from being loaded into the current bundle, instead referencing\nfrom another bundle.\n\n## b.ignore(file)\n\nPrevent the module name or file at `file` from showing up in the output bundle.\n\n## b.transform(tr)\n\nTransform source code before parsing it for `require()` calls with the transform\nfunction or module name `tr`.\n\nIf `tr` is a function, it will be called with `tr(file)` and it should return a\n[through-stream](https://github.com/substack/stream-handbook#through)\nthat takes the raw file contents and produces the transformed source.\n\nIf `tr` is a string, it should be a module name or file path of a\n[transform module](https://github.com/substack/module-deps#transforms)\nwith a signature of:\n\n``` js\nvar through = require('through');\nmodule.exports = function (file) { return through() };\n```\n\nYou don't need to necessarily use the\n[through](https://npmjs.org/package/through) module, this is just a simple\nexample.\n\nHere's how you might compile coffee script on the fly using `.transform()`:\n\n```\nvar coffee = require('coffee-script');\nvar through = require('through');\n\nb.transform(function (file) {\n var data = '';\n return through(write, end);\n \n function write (buf) { data += buf }\n function end () {\n this.queue(coffee.compile(data));\n this.queue(null);\n }\n});\n```\n\nNote that on the command-line with the `-c` flag you can just do:\n\n```\n$ browserify -c 'coffee -sc' main.coffee > bundle.js\n```\n\nOr better still, use the [coffeeify](https://github.com/substack/coffeeify)\nmodule:\n\n```\n$ npm install coffeeify\n$ browserify -t coffeeify main.coffee > bundle.js\n```\n\n# package.json\n\nbrowserify uses the `package.json` in its module resolution algorithm just like\nnode, but there is a special\n\"[browsers](https://gist.github.com/4339901)\" field you can set to override file\nresolution for browser-specific versions.\n\nYou can specify source transforms in the package.json in the\nbrowserify.transforms field. There is more information about how source\ntransforms work in package.json on the\n[module-deps readme](https://github.com/substack/module-deps#transforms).\n\n# list of source transforms\n\nHere is a list of known source transforms:\n\n* [brfs](https://github.com/substack/brfs) - inline\n`fs.readFileSync()` calls with file contents\n\n* [coffeeify](https://github.com/substack/coffeeify) - compile\n`.coffee` files to javascript automatically\n\n# install\n\nWith [npm](http://npmjs.org) do:\n\n```\nnpm install -g browserify\n```\n\n# license\n\nMIT\n", "_id": "browserify@2.7.2", "dist": { "shasum": "2be290d43e4523c6b494df6a5fda96e34ccce16f" }, "_from": "browserify" }