Converts AMD/RequireJS modules to CommonJS. Supports CoffeeScript.
As you know, AMD handles path differently than CommonJS. Commonify automatically finds correct path using fuzzy search.
define ['underscore', 'models/user'], (_, User) ->
initialize: (app) ->
_ = require('underscore')
User = require('./models/user')
module.exports =
initialize: (app) ->
$ npm install -g commonify
$ commonify app/*.coffee
$ commonify [--dry] files
While this project lacks unit tests (yet), it has workflow focused on fixing bugs in the wild.
So, if you encounter the bug, please:
- Clone the repo, install deps in
npm install
. - Run Commonify in development mode (see below).
- You will likely want to fix grammar file coffee.pegjs. Use PEG.js docs for that. When you change any source file, Commonify re-runs the convertation.
- Do few quickly iterations.
- When you're done with the file, re-run Commonify on the whole project and review diffs.
$ git clone https://github.com/Lendar/commonify; cd commonify
$ npm start --files=../existing-project/file.coffee
Inspired by Bret Victor - Inventing on Principle talk
Copyright (c) 2015 Denis Elistratov