mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-17 05:04:55 +00:00
Fixes #604 - using single queue for export.
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": "0.0.14"
|
"yootils": "bwbroersma/yootils#gh-3"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"svelte": "^3.0.0"
|
"svelte": "^3.0.0"
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ type Opts = {
|
|||||||
static?: string,
|
static?: string,
|
||||||
basepath?: string,
|
basepath?: string,
|
||||||
timeout?: number | false,
|
timeout?: number | false,
|
||||||
|
concurrent?: number,
|
||||||
oninfo?: ({ message }: { message: string }) => void;
|
oninfo?: ({ message }: { message: string }) => void;
|
||||||
onfile?: ({ file, size, status }: { file: string, size: number, status: number }) => void;
|
onfile?: ({ file, size, status }: { file: string, size: number, status: number }) => void;
|
||||||
};
|
};
|
||||||
@@ -44,6 +45,7 @@ async function _export({
|
|||||||
export_dir = '__sapper__/export',
|
export_dir = '__sapper__/export',
|
||||||
basepath = '',
|
basepath = '',
|
||||||
timeout = 5000,
|
timeout = 5000,
|
||||||
|
concurrent = 8,
|
||||||
oninfo = noop,
|
oninfo = noop,
|
||||||
onfile = noop
|
onfile = noop
|
||||||
}: Opts = {}) {
|
}: Opts = {}) {
|
||||||
@@ -87,6 +89,7 @@ async function _export({
|
|||||||
|
|
||||||
const seen = new Set();
|
const seen = new Set();
|
||||||
const saved = new Set();
|
const saved = new Set();
|
||||||
|
const q = yootils.queue(concurrent);
|
||||||
|
|
||||||
function save(url: string, status: number, type: string, body: string) {
|
function save(url: string, status: number, type: string, body: string) {
|
||||||
const { pathname } = resolve(origin, url);
|
const { pathname } = resolve(origin, url);
|
||||||
@@ -162,8 +165,6 @@ async function _export({
|
|||||||
if (pathname !== '/service-worker-index.html') {
|
if (pathname !== '/service-worker-index.html') {
|
||||||
const cleaned = clean_html(body);
|
const cleaned = clean_html(body);
|
||||||
|
|
||||||
const q = yootils.queue(8);
|
|
||||||
|
|
||||||
const base_match = /<base ([\s\S]+?)>/m.exec(cleaned);
|
const base_match = /<base ([\s\S]+?)>/m.exec(cleaned);
|
||||||
const base_href = base_match && get_href(base_match[1]);
|
const base_href = base_match && get_href(base_match[1]);
|
||||||
const base = resolve(url.href, base_href);
|
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)
|
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(() => proc.kill())
|
.then(() => proc.kill())
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
|
|||||||
@@ -189,6 +189,7 @@ prog.command('export [dest]')
|
|||||||
.describe('Export your app as static files (if possible)')
|
.describe('Export your app as static files (if possible)')
|
||||||
.option('--build', '(Re)build app before exporting', true)
|
.option('--build', '(Re)build app before exporting', true)
|
||||||
.option('--basepath', 'Specify a base path')
|
.option('--basepath', 'Specify a base path')
|
||||||
|
.option('--concurrent', 'Concurrent requests', 8)
|
||||||
.option('--timeout', 'Milliseconds to wait for a page (--no-timeout to disable)', 5000)
|
.option('--timeout', 'Milliseconds to wait for a page (--no-timeout to disable)', 5000)
|
||||||
.option('--legacy', 'Create separate legacy build')
|
.option('--legacy', 'Create separate legacy build')
|
||||||
.option('--bundler', 'Specify a bundler (rollup or webpack, blank for auto)')
|
.option('--bundler', 'Specify a bundler (rollup or webpack, blank for auto)')
|
||||||
@@ -203,6 +204,7 @@ prog.command('export [dest]')
|
|||||||
legacy: boolean,
|
legacy: boolean,
|
||||||
bundler?: 'rollup' | 'webpack',
|
bundler?: 'rollup' | 'webpack',
|
||||||
basepath?: string,
|
basepath?: string,
|
||||||
|
concurrent: number,
|
||||||
timeout: number | false,
|
timeout: number | false,
|
||||||
cwd: string,
|
cwd: string,
|
||||||
src: string,
|
src: string,
|
||||||
@@ -228,6 +230,7 @@ prog.command('export [dest]')
|
|||||||
export_dir: dest,
|
export_dir: dest,
|
||||||
basepath: opts.basepath,
|
basepath: opts.basepath,
|
||||||
timeout: opts.timeout,
|
timeout: opts.timeout,
|
||||||
|
concurrent: opts.concurrent,
|
||||||
|
|
||||||
oninfo: event => {
|
oninfo: event => {
|
||||||
console.log(colors.bold().cyan(`> ${event.message}`));
|
console.log(colors.bold().cyan(`> ${event.message}`));
|
||||||
|
|||||||
Reference in New Issue
Block a user