From 3eae70dd604b585a79ec4f99b58b26be61ba1681 Mon Sep 17 00:00:00 2001 From: Jacob Marshall Date: Thu, 2 Oct 2014 11:26:00 +1300 Subject: [PATCH] Add support for almond.js [Fixes #81] --- Gruntfile.coffee | 1 + src/bugsnag.js | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Gruntfile.coffee b/Gruntfile.coffee index a1eb400cb9..f13edd8bc6 100644 --- a/Gruntfile.coffee +++ b/Gruntfile.coffee @@ -14,6 +14,7 @@ module.exports = (grunt) -> global: true module: true define: true + require: true # The Good Parts eqeqeq: true diff --git a/src/bugsnag.js b/src/bugsnag.js index 2a74eb410e..066f0c1ebb 100644 --- a/src/bugsnag.js +++ b/src/bugsnag.js @@ -12,10 +12,18 @@ // The `Bugsnag` object is the only globally exported variable (function(definition) { if (typeof define === "function" && define.amd) { - // AMD/Require.js - define(function () { - return definition(window); - }); + // AMD + if (typeof require === "object" && require.load) { + // Require.js + define(function () { + return definition(window); + }); + } else { + // Almond.js + define("Bugsnag", function () { + return definition(window); + }); + } } else if (typeof module === "object" && typeof module.exports === "object") { // CommonJS/Browserify module.exports = definition(global);