mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-22 15:15:19 +00:00
wait inside handle function when exporting
This commit is contained in:
@@ -58,7 +58,7 @@
|
|||||||
"svelte-loader": "^2.13.3",
|
"svelte-loader": "^2.13.3",
|
||||||
"webpack": "^4.29.0",
|
"webpack": "^4.29.0",
|
||||||
"webpack-format-messages": "^2.0.5",
|
"webpack-format-messages": "^2.0.5",
|
||||||
"yootils": "bwbroersma/yootils#gh-3"
|
"yootils": "0.0.15"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"svelte": "^3.0.0"
|
"svelte": "^3.0.0"
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ async function _export({
|
|||||||
async function handle(url: URL) {
|
async function handle(url: URL) {
|
||||||
let pathname = url.pathname;
|
let pathname = url.pathname;
|
||||||
if (pathname !== '/service-worker-index.html') {
|
if (pathname !== '/service-worker-index.html') {
|
||||||
pathname = pathname.replace(root.pathname, '') || '/'
|
pathname = pathname.replace(root.pathname, '') || '/'
|
||||||
}
|
}
|
||||||
|
|
||||||
if (seen.has(pathname)) return;
|
if (seen.has(pathname)) return;
|
||||||
@@ -162,6 +162,7 @@ async function _export({
|
|||||||
`<link rel="preload" as=${JSON.stringify(ref.as)} href=${JSON.stringify(ref.uri)}></head>`)
|
`<link rel="preload" as=${JSON.stringify(ref.as)} href=${JSON.stringify(ref.uri)}></head>`)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (pathname !== '/service-worker-index.html') {
|
if (pathname !== '/service-worker-index.html') {
|
||||||
const cleaned = clean_html(body);
|
const cleaned = clean_html(body);
|
||||||
|
|
||||||
@@ -172,6 +173,8 @@ async function _export({
|
|||||||
let match;
|
let match;
|
||||||
let pattern = /<a ([\s\S]+?)>/gm;
|
let pattern = /<a ([\s\S]+?)>/gm;
|
||||||
|
|
||||||
|
let promise;
|
||||||
|
|
||||||
while (match = pattern.exec(cleaned)) {
|
while (match = pattern.exec(cleaned)) {
|
||||||
const attrs = match[1];
|
const attrs = match[1];
|
||||||
const href = get_href(attrs);
|
const href = get_href(attrs);
|
||||||
@@ -180,10 +183,12 @@ async function _export({
|
|||||||
const url = resolve(base.href, href);
|
const url = resolve(base.href, href);
|
||||||
|
|
||||||
if (url.protocol === protocol && url.host === host) {
|
if (url.protocol === protocol && url.host === host) {
|
||||||
q.add(() => handle(url));
|
promise = q.add(() => handle(url));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await promise;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -202,8 +207,8 @@ async function _export({
|
|||||||
|
|
||||||
return ports.wait(port)
|
return ports.wait(port)
|
||||||
.then(() => handle(root))
|
.then(() => handle(root))
|
||||||
.then(() => q.close())
|
|
||||||
.then(() => handle(resolve(root.href, 'service-worker-index.html')))
|
.then(() => handle(resolve(root.href, 'service-worker-index.html')))
|
||||||
|
.then(() => q.close())
|
||||||
.then(() => proc.kill())
|
.then(() => proc.kill())
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
proc.kill();
|
proc.kill();
|
||||||
|
|||||||
Reference in New Issue
Block a user