Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including decomponentify with all npm packages installed. Try it out:

var decomponentify = require("decomponentify")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

decomponentify v0.1.0

Use component.js build files with browserify.


A browserify transform to enable the use of component.js components in browserify client javascript projects.


Installation is via npm:

$ npm install decomponentify

How to use.

Install some components:

# creates files in component/component-moment/
$ component install component/moment

Build out your component file into a place where you can require it from browserify:

# Builds all the components into public/scripts/vendor/component/index.js
$ component build -o public/scripts/vendor/component -n index

Require the build file in your browserify code and access the component modules by their fully qualified name (eg. 'component-moment'):

// File: public/scripts/app.js
var domready = require('domready')
  , component = require('./vendor/component')
  , moment = component('component-moment');

domready(function () {
  console.log(moment.format('dddd')); // prints "Monday"

Build out your browserify bundle using the decomponentify transform:

$ browserify -t decomponentify  public/scripts/app.js -o public/scripts/build/bundle.js

Then include your bundle.js in your HTML file and you're done!


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free