diff --git a/Gruntfile.js b/Gruntfile.js index 2abe02b11d26..8596b0f5c2c9 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -70,7 +70,7 @@ module.exports = function(grunt) { }, core: { src: coreFiles.concat(plugins), - dest: 'build/<%= pkg.name %>.js' + dest: 'build/raven.js' }, all: { files: pluginConcatFiles diff --git a/src/raven.js b/src/raven.js index 32570b8aa1a6..e3f5e321b6e1 100644 --- a/src/raven.js +++ b/src/raven.js @@ -4,7 +4,7 @@ // If there is no JSON, we no-op the core features of Raven // since JSON is required to encode the payload var _Raven = window.Raven, - hasJSON = !!(window.JSON && window.JSON.stringify), + hasJSON = !!(isObject(JSON) && JSON.stringify), lastCapturedException, lastEventId, globalServer, diff --git a/template/_footer.js b/template/_footer.js index 0a9efcc022a6..2f97062899af 100644 --- a/template/_footer.js +++ b/template/_footer.js @@ -1,9 +1,18 @@ // Expose Raven to the world -window.Raven = Raven; - -// AMD if (typeof define === 'function' && define.amd) { - define('raven', [], function() { return Raven; }); + // AMD + define('raven', function(Raven) { + return (window.Raven = Raven); + }); +} else if (isObject(module)) { + // browserify + module.exports = Raven; +} else if (isObject(exports)) { + // CommonJS + exports = Raven; +} else { + // Everything else + window.Raven = Raven; } })(window);