react / react-0.13.3 / examples / basic-commonjs / node_modules / browserify / doc / changelog / 5_0.markdown
81146 viewsVersion 5 is a big rearranging of browserify internals with more places for external code to hook into the build pipeline. These changes are mostly aligned around the theme of making it easier for external code to interface with browserify internals in a less hacky way. # pipeline Now the core of browserify is organized into a [labeled-stream-splicer](https://npmjs.org/package/labeled-stream-splicer) pipeline. This means that user code and plugins can hook into browserify by pushing themselves onto the pipeline at a label: ``` js var browserify = require('browserify'); var through = require('through2'); var bundle = browserify(); bundle.pipeline.get('deps').push(through.obj(function (row, enc, next) { console.log('DEP:', row.id); this.push(row); next(); })); ``` User code can remove existing transforms or add its own hooks. These are the labeled sections you can get a handle on with `bundle.pipeline.get()` * `'record'` - save inputs to play back later on subsequent `bundle()` calls * `'deps'` - [module-deps](https://npmjs.org/package/module-deps) * `'unbom'` - remove byte-order markers * `'syntax'` - check for syntax errors * `'sort'` - sort the dependencies for deterministic bundles * `'dedupe'` - remove duplicate source contents * `'label'` - apply integer labels to files * `'emit-deps'` - emit `'dep'` event * `'debug'` - apply source maps * `'pack'` - [browser-pack](https://npmjs.org/package/browser-pack) * `'wrap'` - apply final wrapping, `require=` and a newline and semicolon Because there is now a proper pipeline, `opts.pack`, `opts.deps`, `b.deps()`, and `b.pack()` are removed. # bundle() Big changes have been made to the `bundle()` function. All options have been moved out of the `bundle(opts)` form and into the browserify constructor. Before there was an unclear split between which arguments went into which function. You can now call `bundle()` multiple times on the same instance, even in parallel. This will greatly simplify the caching system under watchify and will fix many long-standing bugs. The callback to `bundle(cb)` is now called with `cb(err, buf)` instead of `cb(err, string)` as before. # labeling The former hashing system is removed, in favor of file paths rooted at the `opts.basedir`, or the cwd. This removal means that browserify can be much more consistent about applying integer ids, which avoids exposing system paths in bundle output. Hashes are used internally for deduping purposes, but they operate on the source content only. # others The matching logic in the `--noparse` feature is greatly improved. derequire has been taken out of core, which should speed up `--standalone`.