diff --git a/package-lock.json b/package-lock.json index da5816a..9cea209 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5530,9 +5530,8 @@ } }, "yootils": { - "version": "0.0.14", - "resolved": "https://registry.npmjs.org/yootils/-/yootils-0.0.14.tgz", - "integrity": "sha512-yWoA/a/4aVUp5nqfqdjbTdyXcR8d0OAbRQ8Ktu3ZsfQnArwLpS81oqZl3adIszX3p8NEhT0aNHARPsaTwBH/Qw==", + "version": "0.0.15", + "resolved": "github:bwbroersma/yootils#77a0949b90387af0bff8081cf596a752a1a3e08e", "dev": true } } diff --git a/src/api/export.ts b/src/api/export.ts index 6e32f3a..1d6a718 100644 --- a/src/api/export.ts +++ b/src/api/export.ts @@ -138,9 +138,9 @@ async function _export({ }, timeout); const r = await Promise.race([ - fetch(url.href, { + q.add(() => fetch(url.href, { redirect: 'manual' - }), + })), timeout_deferred.promise ]); @@ -183,7 +183,7 @@ async function _export({ const url = resolve(base.href, href); if (url.protocol === protocol && url.host === host) { - promise = q.add(() => handle(url)); + promise = handle(url); } } } @@ -205,15 +205,17 @@ async function _export({ save(pathname, r.status, type, body); } - return ports.wait(port) - .then(() => handle(root)) - .then(() => handle(resolve(root.href, 'service-worker-index.html'))) - .then(() => q.close()) - .then(() => proc.kill()) - .catch(err => { - proc.kill(); - throw err; - }); + try { + await ports.wait(port); + await handle(root); + await handle(resolve(root.href, 'service-worker-index.html')); + await q.close(); + + proc.kill() + } catch (err) { + proc.kill(); + throw err; + } } function get_href(attrs: string) { diff --git a/test/apps/export/src/routes/boom/[a]/[b].svelte b/test/apps/export/src/routes/boom/[a]/[b].svelte new file mode 100644 index 0000000..9b7b9b4 --- /dev/null +++ b/test/apps/export/src/routes/boom/[a]/[b].svelte @@ -0,0 +1,12 @@ + + + + +

{a}/{b}

\ No newline at end of file diff --git a/test/apps/export/src/routes/boom/[a]/index.svelte b/test/apps/export/src/routes/boom/[a]/index.svelte new file mode 100644 index 0000000..5c18250 --- /dev/null +++ b/test/apps/export/src/routes/boom/[a]/index.svelte @@ -0,0 +1,15 @@ + + + + +{#each list as b} + {a}/{b} +{/each} \ No newline at end of file diff --git a/test/apps/export/src/routes/boom/index.svelte b/test/apps/export/src/routes/boom/index.svelte new file mode 100644 index 0000000..84ed158 --- /dev/null +++ b/test/apps/export/src/routes/boom/index.svelte @@ -0,0 +1,7 @@ + + +{#each list as a} + {a} +{/each} \ No newline at end of file diff --git a/test/apps/export/src/routes/index.svelte b/test/apps/export/src/routes/index.svelte index 1928902..630e2aa 100644 --- a/test/apps/export/src/routes/index.svelte +++ b/test/apps/export/src/routes/index.svelte @@ -7,3 +7,4 @@ empty anchor #4 empty anchor #5 empty anchor #6 +boom \ No newline at end of file diff --git a/test/apps/export/test.ts b/test/apps/export/test.ts index 897bc5f..98e7601 100644 --- a/test/apps/export/test.ts +++ b/test/apps/export/test.ts @@ -19,7 +19,15 @@ describe('export', function() { assert.ok(client_assets.length > 0); - assert.deepEqual(non_client_assets, [ + const boom = ['boom/index.html']; + for (let a = 1; a <= 20; a += 1) { + boom.push(`boom/${a}/index.html`); + for (let b = 1; b <= 20; b += 1) { + boom.push(`boom/${a}/${b}/index.html`); + } + } + + assert.deepEqual(non_client_assets.sort(), [ 'blog.json', 'blog/bar.json', 'blog/bar/index.html', @@ -31,8 +39,9 @@ describe('export', function() { 'global.css', 'index.html', 'service-worker-index.html', - 'service-worker.js' - ]); + 'service-worker.js', + ...boom + ].sort()); }); // TODO test timeout, basepath