jmdobry / angular-cache

angular-cache is a very useful replacement for the Angular 1 $cacheFactory.
http://jmdobry.github.io/angular-cache
MIT License
1.39k stars 156 forks source link

Does not work with Angular 1.3 and browserify #204

Closed jukkasi closed 8 years ago

jukkasi commented 9 years ago

I'm using Angular 1.3.20 which is now CommonJS compatible (since 1.3.14).

When I use browserify require('angular-cache') var angular is undefined in your module. This leads to error "angular.module is undefined"

Similar issue has been discussed here https://github.com/likeastore/ngDialog/pull/168 but please note that discussion started BEFORE Angular 1.3.14 and CommonJS changes.

Changing angular-cache.js

if(typeof exports === 'object' && typeof module === 'object') 
    module.exports = factory(require("angular"));

to

if(typeof exports === 'object' && typeof module === 'object')
    module.exports = require("angular");

fixes the issue.

Working example is probably https://github.com/likeastore/ngDialog/blob/master/js/ngDialog.js

jukkasi commented 8 years ago

Any ideas? Would be actually nice to use this library.

Otherwise I'm forced to fork and remove the UMD stuff

mchambaud commented 8 years ago

@jukkasi can you create a pull-request with this fix?

mchambaud commented 8 years ago

Can we get this into angular-cache?!

SatadruBhattacharjee commented 8 years ago

+1

jmdobry commented 8 years ago

Fixed by b491ed83