Added AMD support.

This commit is contained in:
Sam Day 2011-11-05 20:04:53 +10:00
parent a6081caf50
commit 3564f51fb5
1 changed files with 11 additions and 5 deletions

View File

@ -104,11 +104,17 @@ task 'build:browser', 'rebuild the merged script for inclusion in the browser',
};
"""
code = """
this.CoffeeScript = function() {
function require(path){ return require[path]; }
#{code}
return require['./coffee-script']
}()
(function(root) {
var CoffeeScript = function() {
function require(path){ return require[path]; }
#{code}
return require['./coffee-script']
}();
if(typeof define === 'function' && define.amd) {
define(function() { return CoffeeScript });
} else { root.CoffeeScript = CoffeeScript }
}(this));
"""
unless process.env.MINIFY is 'false'
{parser, uglify} = require 'uglify-js'