0

I am dying here on lazily loading modules into angular-meteor 1.5. So the Meteor Version is 1.4.2.3, meaning with ES2015, import, ui-router etc. So far I've tried ocLazyLoad, angularAMD has a completely different syntax (with define(function()...) which I don't know how to "merge" with the Boilerplate App of Urigo's angular-meteor. So in ocLazyLoad, I went by this https://github.com/alo/oclazyload-uirouter-component-routing-tests github example, since it is the only one I've found that has the ng 1.5 components and submodules instead of just lazily adding controllers to the main apps module.

When I try to implement this, ocLazyLoad logs that the js-file is loaded, but in the Sources-tab instead of the actual file, the js-file contains the whole meteor app.

Any idea on why that is or whether angularAMD works with angular-meteor or in general, how to make lazyLoading modules work?

1
  • Have you looked at Meteor 1.5 beta? github.com/meteor/meteor/pull/8327 We are introducing dynamic imports which will let you very easily lazy load modules. I'm not familiar with ocLazyLoad but if it can handle dynamic imports syntax it should be fine. maybe you can create a repo and play with the beta and I can chime in?
    – Urigo
    Feb 20, 2017 at 21:32

1 Answer 1

0

It's not as natural as it should be because meteor doesn't support lazy loading yet. But here is a working solution:

If your are trying to use lazy loading on routes like this:

{ path: "myPath", loadChildren: "app/myModule/myModule.module#MyModule"}

You should use instead a callback to get the module using ES5 callbacks.

{path: "myPath", loadChildren: ()=> require('./myModule/myModule.module')["MyModule"] }

Hopefully will work for you as well. :)

Question answered on my post

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.