Ben is on a roll (asynchronous imports/code splitting)

In case you’ve not paid attention to GH:

Go man go! The new release constraint scheme for core packages looks cool too. :fire:

32 Likes

This is going to be absolutely epic. Can’t wait to see some content explaining the details of this project, it’s actually a huge step forward not only for Meteor but for JavaScript overall.

7 Likes

Great news. You are our hero, Ben! Thank you.

4 Likes

Awesome, I have been hanging for an update :slight_smile:

That’s awesome! I would love to hear more about how code splitting works with regards to routing? Is it completely independent, or does it need to talk to the router somehow?

2 Likes

Can you elaborate or provide a link please?

That will finally make using imports in Meteor meaningful. Can’t wait.

It’s completely router independent. I think we have had a pretty consistent position that nether data loading nor other stuff like module loading should be coupled to routes.

6 Likes
2 Likes

Thanks a lot. :slight_smile:

That’s great! While we’re on the topic:

  • Will there also be a hook to show a loader when modules are being loaded?
  • Will this work with package-based apps (i.e. all the app’s code is in local Meteor packages), too?

Based on what I know:

Following the spec for async module loading, you get a promise. So you can show a loading thingy while the promise is not yet resolved.

I think it will work with anything module-based, as long as you use import(...) to ask for the module.

2 Likes

This is very promising, we’re seeing the fruits of the refactoring we had to do along with Meteor toward ES2015 and the Node.js ecosystem.

It’s also nice to see very smart and talented people solving leading edge industry wide problems in the platform we grew to love :slight_smile:

4 Likes

Great work! Can’t wait to test it!!

With this new feature, we have to replace all of our import {foo} from 'bar' to import('bar') or it will just work?

1 Like

Ben is a genius. Nice hire by Meteor.

5 Likes

latest update!, working beta.2 available for Linux and macOS instructions

1 Like

So how would that work in the context of react? can we import react components dynamically as the user navigate the routes?

Yes you can! Better yet it’s a standard so routers can safely add support for it and it will work with a variety of module systems.

1 Like

Only if you want that module loaded on demand

Will this also include further optimizations such as finally getting rid of jQuery and maybe even underscore as mandatory dependencies?

This is really exciting. Just speculating here, but would love to see this integrated in the build system and have some kind of dynamic pre-loading as well. I can see so many uses !!

  • building multiple bundles - a small one which loads things dynamically. Big ones which are precompiled with more modules.
  • Have server detect user-agent/headers/speed and serve proper module size as needed
  • allow dynamic switching of modules with debug versions - e.g. you have a production app and one page has a bug - you just swap it with a debug version with one switch and you have lots more logs etc
  • have a module catalaog sort of like atmosphere/npm but with readymade modules that can be served from the cloud on demand
1 Like