mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Now that we're using HTTP POST requests to fetch dynamic modules, it's
more important to make fewer requests when possible, given the higher
latency of HTTP requests compared to WebSocket messages.
The trick is to wait until the next tick of the event loop before actually
sending the request, so that multiple dynamic import() calls in quick
succession are treated as a single request, and all the modules they
require can be returned in a single response object.
For example, we want code like this
const [
React,
ReactDOM
] = await Promise.all([
import("react"),
import("react-dom")
]);
to result in one HTTP POST request for both `react` and `react-dom`, as
well as all their dependencies, rather than two separate requests.
Indeed, that is what happens, since both import() calls take place in the
same tick of the event loop.
modules-runtime
Source code of released version | Source code of development version
This package implements the meteorInstall function that is used and
re-exported by the modules package. Do not depend directly on this
package (unless you know what you're doing); depend instead on the
modules package.