From 305abbefb8e357a8512f4b062078093318e8a3ad Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Thu, 16 Nov 2017 17:28:50 -0500 Subject: [PATCH] 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. --- packages/modules-runtime/.npm/package/npm-shrinkwrap.json | 6 +++--- packages/modules-runtime/package.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/modules-runtime/.npm/package/npm-shrinkwrap.json b/packages/modules-runtime/.npm/package/npm-shrinkwrap.json index 903b8384bb..03646c32b5 100644 --- a/packages/modules-runtime/.npm/package/npm-shrinkwrap.json +++ b/packages/modules-runtime/.npm/package/npm-shrinkwrap.json @@ -2,9 +2,9 @@ "lockfileVersion": 1, "dependencies": { "install": { - "version": "0.10.1", - "resolved": "https://registry.npmjs.org/install/-/install-0.10.1.tgz", - "integrity": "sha1-HHtTyN1zNe9TTCZI3ij1md8b3Zc=" + "version": "0.10.2", + "resolved": "https://registry.npmjs.org/install/-/install-0.10.2.tgz", + "integrity": "sha512-CcH+s/Z1Eir84zHRe5S2Hw/UWsTrgtQHdootbrjVopShGOcPe+aCfLq9Yyw1sEq8dZbeLWxXAqm2QwDx4hrE0w==" } } } diff --git a/packages/modules-runtime/package.js b/packages/modules-runtime/package.js index 443be82aa7..c76becb417 100644 --- a/packages/modules-runtime/package.js +++ b/packages/modules-runtime/package.js @@ -1,13 +1,13 @@ Package.describe({ name: "modules-runtime", - version: "0.9.0", + version: "0.9.1", summary: "CommonJS module system", git: "https://github.com/benjamn/install", documentation: "README.md" }); Npm.depends({ - install: "0.10.1" + install: "0.10.2" }); Package.onUse(function(api) {