From 3564f51fb56120a92a2d5ecf134a52e2b6d92394 Mon Sep 17 00:00:00 2001 From: Sam Day Date: Sat, 5 Nov 2011 20:04:53 +1000 Subject: [PATCH] Added AMD support. --- Cakefile | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Cakefile b/Cakefile index d598666d..17cb1dfa 100644 --- a/Cakefile +++ b/Cakefile @@ -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'