Golden mole
Golden mole

Reputation: 503

meteor 1.3.1 imports not lazy loading

The new ES6 module support for 1.3 was supposed to include "lazy-loading" support of code stored in the /imports directory, however all imported code is still bundled into an app.js file and sent to the client. Where is the benefit of a non-eager loading system when all the code is pushed to the client on initial load anyways?

Is there a way to dynamically load modules? What if I have hundreds or thousands of components to load depending on the user's interaction? What if the user is on a mobile phone using our web app that requires them to download megabytes of template code to their phone's memory? What if a user never visits certain sections of the app? Why would I give them the code for those sections? Why must we use the module import programming style when the benefit is exactly the same without?

If I'm mistaken, please let me know. Thank you!

Upvotes: 1

Views: 308

Answers (2)

Lope
Lope

Reputation: 42

Vote and follow progress on Meteor's Trello future feature board

Follow FlowRouter's support for this future feature

I can confirm that Lazy Loading of SCSS is still not working for me in the now-current Meteor 1.3.4.1.

Upvotes: 0

David Weldon
David Weldon

Reputation: 64312

Note to readers: the following answer applies to meteor 1.3. This answer will (hopefully) become outdated with future releases.

Module support in 1.3 gives you the ability to control your file load order. E.g. no more prepending numbers to file names, adding nested lib directories, and using packages where you otherwise wouldn't.

What module support doesn't do is give you lazy loading, tree shaking, or any other fancy build/runtime optimizations. These are, however, on the roadmap and all require use of imports. So adding them now, will help you in the future. Sorry I don't have better news.

In the case where you have a bunch of functionality that is specific to one class of user (an admin interface for example), you can, as the guide suggests, split your app into smaller apps. Not ideal, but thought I'd include it for completeness.


Also note that much of this is talked about in transmission episode 4. The whole thing is worth watching, but if you skip to ~11:00 they start talking about this question specifically.

Upvotes: 3

Related Questions