swimlane / angular1-systemjs-seed

AngularJS 1.x + SystemJS Seed
MIT License
210 stars 40 forks source link

Module not loading when included in app.js directly #53

Closed juristr closed 8 years ago

juristr commented 8 years ago

Hi,

I'm having a closer look at your setup and encountered a strange issue. I fear it's something really stupid and I'm just missing something, but anyway :smile:

I forked your seed project and added a new module messages, just for playing around. When I reference the module from the dashboard module

...
import messagesModule from 'app/messages/module';
...
export default angular
  .module('dashboard', [
    ...
    messagesModule.name
  ])
  .config(ConfigureModule);

..everything works as expected. I'm able to load the MessageController from within the dashboards.tpl.html and use it just as you would expect. I also see it in the Chrome devtools:

image

However, when I directly reference the messages module from the app.js file like here: https://github.com/juristr/angular-systemjs-seed/blob/adding-module/src/app/app.js#L9

..the app breaks. Often it doesn't even load properly and if it does, I don't get any error but the MessageController doesn't seem to be loaded. At least I cannot for instance use it in the index.html as I would expect.

To reproduce it easily, I pushed my adding-module branch up on my GitHub account: https://github.com/juristr/angular-systemjs-seed/tree/adding-module

Any hints? I'm quite sure I am just missing something here...

amcdnl commented 8 years ago

your doing export default MessagesController but then you reference it as if it were a named module. If you export default you don't import as a named module.

juristr commented 8 years ago

your doing export default MessagesController but then you reference it as if it were a named module. If you export default you don't import as a named module.

:+1: That was definitely not correct, thx.

Still...I'm not getting it :disappointed: . As soon as I reference a module directly in the app.js (in this case the dashboard module), the app doesn't load properly any more (note the red screen doesn't come out). It's this line: https://github.com/juristr/angular-systemjs-seed/blob/adding-module/src/app/app.js#L9.

If I comment this line it works as expected...