gsklee / ngStorage

localStorage and sessionStorage done right for AngularJS.
MIT License
2.34k stars 461 forks source link

Error using Webpack #250

Open mcblum opened 7 years ago

mcblum commented 7 years ago

I'm getting a strange error. It also could be because I'm a bit new to ES6 + true modules.

Argument 'module' is not a function, got Object

Does this package work out of the box with Webpack or do I need to do something different?

ArthurianX commented 7 years ago

I'm having the same issue, did you manage to fix it ?

mcblum commented 7 years ago

@ArthurianX try: import ngStorage from 'ngstorage'; angular.module('app', [ ngStorage.name ]);

poloagustin commented 7 years ago

Can this method be added to the docs?

mcblum commented 7 years ago

@poloagustin did it work for you?

poloagustin commented 7 years ago

@mcblum yes! 👍 Although, it'd be nice to be able to just do angular.module('app', ['ngstorage']);

poloagustin commented 7 years ago

Sorry, i meant angular.module('app', [require('ngstorage')]);

mcblum commented 7 years ago

@poloagustin I need you to know I'm not the best at this and it's my first time using Webpack / ES6 so I'm probably not the right person to speak authoritatively on it.

poloagustin commented 7 years ago

I'll try to make a PR when I have time then 😊

AldoMX commented 7 years ago

This is a workaround:

const angular = require('angular');
const ngStorage = (() => 'ngStorage')(require('ngstorage'));
angular.module('app', [ngStorage]);
PerfectionVR commented 6 years ago

I guess angular 1 isn't really relevant anymore but can something be done about this? At least put @AldoMX 's workaround in the readme.

mcblum commented 6 years ago

@PerfectionCSGO move to Angular 5 :) I resisted for 100 years and our project was "too big to migrate". We ended up doing it anyway and I was kicking myself for not doing it sooner.