From 3455dd03ffe090cd04e26137d0825f9ceb2043da Mon Sep 17 00:00:00 2001 From: Mike Bostock Date: Wed, 15 Aug 2018 08:45:46 -0700 Subject: [PATCH] Fix #16. --- index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 9019793..9af716b 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,4 @@ const metas = new Map; -const modules = new Map; const queue = []; const map = queue.map; const some = queue.some; @@ -49,12 +48,13 @@ async function resolve(name, base) { export const require = requireFrom(resolve); export function requireFrom(resolver) { + const cache = new Map; const requireBase = requireRelative(null); function requireAbsolute(url) { if (typeof url !== "string") return url; - let module = modules.get(url); - if (!module) modules.set(url, module = new Promise((resolve, reject) => { + let module = cache.get(url); + if (!module) cache.set(url, module = new Promise((resolve, reject) => { const script = document.createElement("script"); script.onload = () => { try { resolve(queue.pop()(requireRelative(url))); }