Fixes #604 - using single queue for export.

This commit is contained in:
Benjamin W. Broersma
2019-03-12 02:11:09 +01:00
parent 7be7e1eb9f
commit bf50392df5
3 changed files with 8 additions and 5 deletions

View File

@@ -19,6 +19,7 @@ type Opts = {
static?: string,
basepath?: string,
timeout?: number | false,
concurrent?: number,
oninfo?: ({ message }: { message: string }) => void;
onfile?: ({ file, size, status }: { file: string, size: number, status: number }) => void;
};
@@ -44,6 +45,7 @@ async function _export({
export_dir = '__sapper__/export',
basepath = '',
timeout = 5000,
concurrent = 8,
oninfo = noop,
onfile = noop
}: Opts = {}) {
@@ -87,6 +89,7 @@ async function _export({
const seen = new Set();
const saved = new Set();
const q = yootils.queue(concurrent);
function save(url: string, status: number, type: string, body: string) {
const { pathname } = resolve(origin, url);
@@ -162,8 +165,6 @@ async function _export({
if (pathname !== '/service-worker-index.html') {
const cleaned = clean_html(body);
const q = yootils.queue(8);
const base_match = /<base ([\s\S]+?)>/m.exec(cleaned);
const base_href = base_match && get_href(base_match[1]);
const base = resolve(url.href, base_href);
@@ -183,8 +184,6 @@ async function _export({
}
}
}
await q.close();
}
}
}
@@ -203,6 +202,7 @@ async function _export({
return ports.wait(port)
.then(() => handle(root))
.then(() => q.close())
.then(() => handle(resolve(root.href, 'service-worker-index.html')))
.then(() => proc.kill())
.catch(err => {