sstephenson/sprockets — Issue #298: CommonJS proposal
Author: maccman
Created: 2012-02-23 01:12:26+00:00
State: open

I think it would be awesome if Sprockets supported CommonJS, and I think you could implement it in a backwards compatible approach.

I've been spiking CommonJS support for Sprockets in a branch:
https://github.com/maccman/sprockets/commit/9e0e82dd662e2a57b1a9e62e1ef816fc1867dfb5

For developers, the end result is:

1. Signify a file is a CommonJS module with the '.module' extension, i.e. 'myfile.module.js'
2. Include the 'commonjs' lib somewhere, i.e. #= require commonjs
3. Start requiring modules, i.e. require('my_module');

There's a number of issues with my initial approach - such as not parsing out requires, having no dependency tree etc. I'm planning on resolving all this on the weekend.

However, my question is - if I did this work, is it likely to get accepted?