mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-11 19:04:30 +00:00
Merge branch 'gh-604-alpha' of https://github.com/bwbroersma/sapper into bwbroersma-gh-604-alpha
This commit is contained in:
@@ -58,7 +58,7 @@
|
||||
"svelte-loader": "^2.13.3",
|
||||
"webpack": "^4.29.0",
|
||||
"webpack-format-messages": "^2.0.5",
|
||||
"yootils": "0.0.14"
|
||||
"yootils": "bwbroersma/yootils#gh-3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"svelte": "^3.0.0"
|
||||
|
||||
@@ -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 => {
|
||||
|
||||
@@ -189,6 +189,7 @@ prog.command('export [dest]')
|
||||
.describe('Export your app as static files (if possible)')
|
||||
.option('--build', '(Re)build app before exporting', true)
|
||||
.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('--legacy', 'Create separate legacy build')
|
||||
.option('--bundler', 'Specify a bundler (rollup or webpack, blank for auto)')
|
||||
@@ -203,6 +204,7 @@ prog.command('export [dest]')
|
||||
legacy: boolean,
|
||||
bundler?: 'rollup' | 'webpack',
|
||||
basepath?: string,
|
||||
concurrent: number,
|
||||
timeout: number | false,
|
||||
cwd: string,
|
||||
src: string,
|
||||
@@ -228,6 +230,7 @@ prog.command('export [dest]')
|
||||
export_dir: dest,
|
||||
basepath: opts.basepath,
|
||||
timeout: opts.timeout,
|
||||
concurrent: opts.concurrent,
|
||||
|
||||
oninfo: event => {
|
||||
console.log(colors.bold().cyan(`> ${event.message}`));
|
||||
|
||||
Reference in New Issue
Block a user