Skip to content

Commit 4366e00

Browse files
Thomas Graingerbenvinegar
authored andcommitted
support CJS use of angular module
1 parent 5785911 commit 4366e00

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

docs/integrations/angularjs.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,26 @@ Inside your main AngularJS application module, you need to declare `ngRaven` as
110110
'myAppControllers',
111111
'myAppFilters'
112112
]);
113+
114+
Module loaders (CommonJS)
115+
~~~~~~~~~~~~~~~~~~~~~~~~~
116+
117+
The raven angular module can be loaded using a module loader like Browserify or Webpack.
118+
119+
.. code-block:: javascript
120+
var angular = require('angular');
121+
var ngRaven = require('raven-js/plugins/angular').moduleName;
122+
var ngRoute = require('angular-route');
123+
124+
var myAppFilters = require('./myAppFilters');
125+
var myAppControllers = require('./myAppControllers');
126+
var moduleName = 'myApp';
127+
128+
angular.module(moduleName, [
129+
ngRaven,
130+
ngRoute,
131+
myAppControllers,
132+
myAppFilters,
133+
]);
134+
135+
module.exports = moduleName;

plugins/angular.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
// See https://github.com/angular/angular.js/blob/v1.4.7/src/minErr.js
99
var angularPattern = /^\[((?:[$a-zA-Z0-9]+:)?(?:[$a-zA-Z0-9]+))\] (.*?)\n?(\S+)$/;
10+
var moduleName = 'ngRaven';
1011

1112

1213
function angularPlugin(Raven, angular) {
@@ -34,7 +35,7 @@ function angularPlugin(Raven, angular) {
3435
};
3536
}
3637

37-
angular.module('ngRaven', [])
38+
angular.module(moduleName, [])
3839
.provider('Raven', RavenProvider)
3940
.config(['$provide', ExceptionHandlerProvider]);
4041

@@ -64,4 +65,6 @@ angularPlugin._normalizeData = function (data) {
6465
}
6566
};
6667

68+
angularPlugin.moduleName = moduleName;
69+
6770
module.exports = angularPlugin;

0 commit comments

Comments
 (0)