index : btroops | |
Virtual board game-aid for BattleTroops, an infantry combat simulator wargame published by FASA in 1989. |
aboutsummaryrefslogtreecommitdiff |
diff options
author | Catalin Mititiuc <webdevcat@proton.me> | 2024-05-30 22:51:56 -0700 |
---|---|---|
committer | Catalin Mititiuc <webdevcat@proton.me> | 2024-05-30 22:51:56 -0700 |
commit | cf5e8a34fe586aa1c3af1b25e96d7d4e76e0458d (patch) | |
tree | af8056b6160c6fb1a019fdd4bbeb675e3be29c85 | |
parent | 921351bfb69dbf95d134bd78266d71b0a00f9835 (diff) |
Handle resolving JSDOM promises better
-rw-r--r-- | esbuild-server.mjs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/esbuild-server.mjs b/esbuild-server.mjs index 51d953d..b897a09 100644 --- a/esbuild-server.mjs +++ b/esbuild-server.mjs @@ -125,17 +125,17 @@ const resolveImportedSvg = { build.onLoad({ filter: /\.svg$/ }, async (args) => { const document = (await JSDOM.fromFile(args.path)).window.document; const externalResourceUseEls = Array.from(document.querySelectorAll('use[href*=".svg"')); - const readFiles = {}; const files = [...new Set([...externalResourceUseEls.map(el => el.getAttributeNS(null, 'href').match(/.+\.svg/).at(0) )])]; - await Promise.all(files.map((filename) => - JSDOM - .fromFile(path.join(path.dirname(args.path), filename)) - .then(dom => readFiles[filename] = dom.window.document) - )); + const readFiles = await Promise.all( + files.map(filename => JSDOM.fromFile(path.join(path.dirname(args.path), filename))) + ).then(result => result.reduce((acc, dom, index) => { + acc[files[index]] = dom.window.document; + return acc; + }, {})); const refs = {}; |