-
Notifications
You must be signed in to change notification settings - Fork 45
Async loading of bundles #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It is certainly possible to implement something like this via the loader hooks. SystemJS has exactly this kind of an implementation in https://github.com/systemjs/systemjs/blob/master/docs/config-api.md#bundle. |
@guybedford great totally missed that systemjs supported this. |
Bundling is not part of this specification. I do believe that a common bundling format needs to emerge to accommodate the needs of ES2015 modules (and Guy's System.register could very well be that format but it needs to be discussed as an independent proposal outside of Systemjs). Sadly http2 and ES2015 module format does not solve the need for bundling even in a development environment. But the loader spec might not be the place for that discussion. |
Bundling and folding mechanism will emerge for sure, but not in this repo. |
@caridy I've noticed you use the term "folding" a bit but I'm not familiar with what you mean by that, can you explain? |
main.js
foo.js
If you application only relies on
and everything will continue to work as expected, because the public interface of advantages of this over bundling:
these are, from the top of my head, some of the stuff related to what I call folding of modules. |
Nice, I also really like the name |
Super Lazy :) |
Hi, I want to propose async loading of bundles. I don't know if the spec already cover this or if you already have discussed this. Though cannot find similar discussion anywhere. Just some heads up, I'm having some difficulty understanding the current spec. So I use my own code example below.
Problem
Because of load time sometimes it is not suitable to bundle everything into one file. One solution is to bundle your application into multiple bundles instead. Another solution is to use http2 with server push. But you can still use server push and bundle at the same time(since you already need to uglify your application code, adding another build step for the bundling won't be that big). Also bundling saves the client from decoding a lot of http2 headers. But also cache-aware server push might need SW support to know which files to be pushed(Here is one discussion in h2o/h2o#421 (comment)), so setting up server push correctly isn't the most trivial task.
Proposal
One solution to above problems is to let the loader being able to load bundles. Since bundles need at least one root file(not necessarily) to traverse all files and bundle them — we can add a map to the loader, that maps root files to bundle files.
In example code(sorry, don't know the whole loader spec and have some difficult to understand it):
All root files defines(not necessarily) an API interface to interact with so we can use the same code for dev and production environment.
The text was updated successfully, but these errors were encountered: