btford / angular-socket-io

Socket.IO component for AngularJS
1.51k stars 233 forks source link

adding support for AMD/Webpack #155

Closed mavrick closed 3 years ago

mavrick commented 7 years ago

Hey there,

I'm currently rebuilding my site to use webpack because I'm wrapping it up for use within Electron however I run across this error when including angular-socket-io library:

Uncaught Error: [$injector:modulerr] Failed to instantiate module website due to:
Error: [$injector:modulerr] Failed to instantiate module {} due to:
Error: [ng:areq] Argument 'module' is not a function, got Object
http://errors.angularjs.org/1.6.3/ng/areq?p0=module&p1=not%20a%20function%2C%20got%20Object

code:

import socketIo from 'angular-socket-io';

var app = angular.module("website", [socketIo]);

I'm using ES6 with Babel and Webpack. Any help would be appreciated.

mavrick commented 7 years ago

So, to answer my own question. It can be done like this:

import 'angular-socket-io';

var app = angular.module("website", ["btford.socket-io"]);
afeish commented 7 years ago

+1. I come with this question too. I have to set the literal of the module manually, which is not consistent with my ES6 import style.

casterfile commented 7 years ago

mport 'angular-socket-io';

var app = angular.module("website", ["btford.socket-io"]);

I am having the same problem.... if i try to add ", ["btford.socket-io"]" nothing is loaded....