Yet another require() bundler
Last updated 3 years ago by mwiencek .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install yarb 
SYNC missed versions from official npm registry.


Build Status

yarb performs mostly the same task as browserify, and shares a lot of the same internals (browser-pack, node-detective, insert-module-globals).

yarb is much less flexible than browserify, but better at defining dependencies between bundles. In browserify, sharing files between bundles tends to require a lot of manual expose and external settings on each file. A yarbundle’s external function only accepts other bundles as input, and the bundling process knows exactly which files are common to both.

While yarb shares API similarities with browserify and is even compatible with browserify transforms, it currently does not handle the full array of core modules (only events, fs, module, net, path, stream, util), and lacks most of the settings and behaviors that browserify has.


Internally, yarb stores files as vinyl objects, and even accepts these as input wherever a path is accepted. This allows passing in existing buffers/streams by just wrapping them in vinyl objects beforehand.

The catch is that all vinyls must have a path property that is both unique to the bundle and absolute (though it doesn't have to exist on disk). Paths are how modules reference each other, after all.

The expose method could theoretically support exposing a vinyl buffer/stream as an arbitrary ID, since those always take precedence over paths. That’d be a rare case, since the vast majority of things will be sourced from disk. Giving a fake but unique path where one doesn't exist will otherwise suffice.


var bundle = yarb([files[, options]])

Returns a new bundle with files as entry points, i.e. modules executed when the bundle is loaded. files can be a single file or an array of files consisting of paths or vinyl objects.

Current options are:

Option Purpose
debug Enables source maps.
basedir Sets the starting point for resolving relative paths.


Adds additional entry files to bundle. See above for accepted inputs for files.

Returns bundle.


Adds non-entry files to be included in bundle. Only necessary if you want to include files that aren’t referenced by any entry files, or are referenced dynamically (e.g. require('foo' + bar));

Returns bundle.


Looks to externalBundle when resolving required paths/IDs, excluding all modules that exist in it from bundle. Obviously, externalBundle must be loaded on the page before anything that references it in bundle executes. Note that externalBundle’s externals will also be recursively checked, allowing a chain of dependencies to form.

Returns bundle.

bundle.expose(file, id)

Calls bundle.require on file and aliases it as id for the current bundle and external bundles. require(id) will always takes precedence over normal path-resolution and always resolve to file.

Returns bundle.

bundle.transform(transform[, options])

Adds browserify-compatible transform to execute on all file contents before being parsed for require calls.

By default, transforms are not run on any code contained within a node_modules/ directory relative to any of the bundle’s entry files. yarb supports a global flag in options which serves the same purpose as the one in browserify and forces the transform to run on all code.

Returns bundle.


Bundles everything together for the browser.

Returns a readable stream that can be piped to disk or elsewhere. If a node-style callback is given, it’ll execute on completion with the arguments (error, buffer).


Returns true if the bundle includes the file located at path in its output, otherwise false. Will only give accurate results after bundle() is called.



Current Tags

  • 0.8.0                                ...           latest (3 years ago)

16 Versions

  • 0.8.0                                ...           3 years ago
  • 0.7.0                                ...           3 years ago
  • 0.6.1                                ...           4 years ago
  • 0.6.0                                ...           4 years ago
  • 0.5.1                                ...           4 years ago
  • 0.5.0                                ...           4 years ago
  • 0.4.5                                ...           4 years ago
  • 0.4.4                                ...           4 years ago
  • 0.4.3                                ...           4 years ago
  • 0.4.2                                ...           4 years ago
  • 0.4.1                                ...           4 years ago
  • 0.4.0                                ...           4 years ago
  • 0.3.0                                ...           4 years ago
  • 0.2.0                                ...           4 years ago
  • 0.1.1                                ...           4 years ago
  • 0.1.0                                ...           4 years ago
Maintainers (1)
Today 0
This Week 0
This Month 27
Last Day 0
Last Week 1
Last Month 1
Dependencies (17)
Dev Dependencies (3)
Dependents (0)

Copyright 2014 - 2016 © taobao.org |