Files
meteor/packages/modules-runtime/package.js
Ben Newman 305abbefb8 Upgrade install to allow batching of dynamic import() requests.
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.
2017-11-16 19:49:06 -05:00

33 lines
678 B
JavaScript

Package.describe({
name: "modules-runtime",
version: "0.9.1",
summary: "CommonJS module system",
git: "https://github.com/benjamn/install",
documentation: "README.md"
});
Npm.depends({
install: "0.10.2"
});
Package.onUse(function(api) {
api.addFiles(".npm/package/node_modules/install/install.js", [
"client",
"server"
], {
bare: true
});
api.addFiles("options.js");
api.addFiles("client.js", "client");
api.addFiles("server.js", "server");
api.export("meteorInstall");
});
Package.onTest(function(api) {
api.use("tinytest");
api.use("modules"); // Test modules-runtime via modules.
api.addFiles("modules-runtime-tests.js");
});