Skip to content

Commit

Permalink
Fix #16.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Aug 15, 2018
1 parent 7ad6cd6 commit 3455dd0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const metas = new Map;
const modules = new Map;
const queue = [];
const map = queue.map;
const some = queue.some;
Expand Down Expand Up @@ -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))); }
Expand Down

0 comments on commit 3455dd0

Please sign in to comment.