Closed Zomis closed 6 years ago
If I had to guess, this is because CardshifterServerAPI
has no $inject
property but expects one argument, debug
:
When the code is uglified, debug
is changed to e
and Angular attempts to resolve a dependency with the name e
. It doesn't find that, so it looks for eProvider
, which doesn't exist, so Angular throws a runtime error.
debug
shouldn't be a dependency here anyway - debug
is a library in package.json
and is never registered with Angular.
The PR I've created imports the debug
library and consumes it directly, but if you'd prefer you could always register debug
with the Angular dependency injector:
var debug = require('debug')
angular.module('....')
// using a constant because service will result in angular trying to `new debug`.
.constant('debug', debug)
function CardshifterServerAPI(debug) {
..
}
// prevents minification breaking things
CardshifterServerAPI.$inject = ['debug'];
Alternatively, one could use $log
which is the included dependency for this.
function CardshifterServerAPI($log) {
$log.debug('hello, world')
}
CardshifterServerAPI.$inject = ['$log'];
debug
is mostly used by Node CLIs applications, I'm not sure it makes sense in an Angular one
Woops, my bad, debug
is already registered in the injector, so all that's required is an $inject
property
Closing as no longer needed #144
Perhaps this question on Stack Overflow can help? https://stackoverflow.com/q/12339272/1310566