Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Converts node.js code to amd style modules, so it can be used in a browser.
JavaScript CoffeeScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.


This is yet another library that converts nodejs code to browser supported code. Actually, node-amdify doesn't know how to extract package dependencies, which makes it less usefull than However, it serves to one more general purpose. It can convert CommonJS module definition style to AMD

I wrote it despite the fact that there is already, because r.js is very slow, not flexible and doesn't allow you to inject any code, that somehow modifies converter behaviour.

This library has only two methods:


amdify = require('node-amdify');

var pipe ='dir', 'result', 'output')

Here dir is a directory from where all .js and .coffee file will be converted to AMD, result is a file where convert result will be stored and output is a directory where just compiled from coffee but not converted files will be stored. Result value is Pipe class wich will be define later.


amdify = require('node-amdify');

var pipe ='dir', 'result', 'output')

The same as build but it also watches dir for changes and recompiles changed files. Since all compiled files are stored in memory and watch compiles only changed files, after initial compilation, every change compiles very fast.


constructor(dir, pack, output)

Just constructor, but since you have no access to a class, it doesn't matter.

launchPipe(userPipe, cb)

node-amdify has 3 steps:

  1. Compile .coffee to .js if it's .coffee
  2. userPipe
  3. Extracting all CommonJS dependencies, normalizing paths and adding define statements
  4. Building single pack

userPipe allows you to interact with this scheme and somehow modify code after it's compiled, but before convert started, cb is just a callback that fires every time when pack is built.

through = require('through')

mypipe = through (data) ->
  if data.code
    code = 'var I18n = require("common/i18n");\n' + data.code
    @queue file: data.file, code: code
    @queue data

module.exports =

  watch: ->
    converter = './src', './pack.js', './lib'
    converter.launchPipe mypipe, -> console.log 'compiled'
Something went wrong with that request. Please try again.