@sveltejs/kit 1.0.0-next.449 → 1.0.0-next.451
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/src/exports/vite/index.js +135 -125
- package/src/runtime/server/index.js +1 -1
- package/types/index.d.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltejs/kit",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.451",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sveltejs/kit",
|
|
@@ -33,16 +33,16 @@
|
|
|
33
33
|
"@types/sade": "^1.7.4",
|
|
34
34
|
"@types/set-cookie-parser": "^2.4.2",
|
|
35
35
|
"marked": "^4.0.16",
|
|
36
|
-
"rollup": "^2.
|
|
36
|
+
"rollup": "^2.78.1",
|
|
37
37
|
"svelte": "^3.48.0",
|
|
38
38
|
"svelte-preprocess": "^4.10.6",
|
|
39
39
|
"typescript": "^4.7.4",
|
|
40
40
|
"uvu": "^0.5.3",
|
|
41
|
-
"vite": "^3.0.
|
|
41
|
+
"vite": "^3.1.0-beta.1"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"svelte": "^3.44.0",
|
|
45
|
-
"vite": "^3.0.
|
|
45
|
+
"vite": "^3.1.0-beta.1"
|
|
46
46
|
},
|
|
47
47
|
"bin": {
|
|
48
48
|
"svelte-kit": "svelte-kit.js"
|
|
@@ -333,152 +333,162 @@ function kit() {
|
|
|
333
333
|
* The user's package.json scripts will invoke the Vite CLI to execute the client build. We
|
|
334
334
|
* then use this hook to kick off builds for the server and service worker.
|
|
335
335
|
*/
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
336
|
+
writeBundle: {
|
|
337
|
+
sequential: true,
|
|
338
|
+
async handler(_options, bundle) {
|
|
339
|
+
if (vite_config.build.ssr) {
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
manifest_data.nodes.forEach((_node, i) => {
|
|
344
|
+
const id = vite.normalizePath(
|
|
345
|
+
path.resolve(svelte_config.kit.outDir, `generated/nodes/${i}.js`)
|
|
346
|
+
);
|
|
347
|
+
|
|
348
|
+
const module_node = this.getModuleInfo(id);
|
|
349
|
+
|
|
350
|
+
if (module_node) {
|
|
351
|
+
prevent_illegal_rollup_imports(
|
|
352
|
+
this.getModuleInfo.bind(this),
|
|
353
|
+
module_node,
|
|
354
|
+
illegal_imports
|
|
355
|
+
);
|
|
356
|
+
}
|
|
357
|
+
});
|
|
340
358
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
359
|
+
const verbose = vite_config.logLevel === 'info';
|
|
360
|
+
log = logger({
|
|
361
|
+
verbose
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
fs.writeFileSync(
|
|
365
|
+
`${paths.client_out_dir}/${svelte_config.kit.appDir}/version.json`,
|
|
366
|
+
JSON.stringify({ version: svelte_config.kit.version.name })
|
|
367
|
+
);
|
|
368
|
+
|
|
369
|
+
const { assets, chunks } = collect_output(bundle);
|
|
370
|
+
log.info(
|
|
371
|
+
`Client build completed. Wrote ${chunks.length} chunks and ${assets.length} assets`
|
|
372
|
+
);
|
|
373
|
+
|
|
374
|
+
log.info('Building server');
|
|
375
|
+
const options = {
|
|
376
|
+
cwd,
|
|
377
|
+
config: svelte_config,
|
|
378
|
+
vite_config,
|
|
379
|
+
vite_config_env,
|
|
380
|
+
build_dir: paths.build_dir, // TODO just pass `paths`
|
|
381
|
+
manifest_data,
|
|
382
|
+
output_dir: paths.output_dir,
|
|
383
|
+
service_worker_entry_file: resolve_entry(svelte_config.kit.files.serviceWorker)
|
|
384
|
+
};
|
|
385
|
+
const client = client_build_info(assets, chunks);
|
|
386
|
+
const server = await build_server(options, client);
|
|
387
|
+
|
|
388
|
+
/** @type {import('types').BuildData} */
|
|
389
|
+
build_data = {
|
|
390
|
+
app_dir: svelte_config.kit.appDir,
|
|
391
|
+
manifest_data,
|
|
392
|
+
service_worker: options.service_worker_entry_file ? 'service-worker.js' : null, // TODO make file configurable?
|
|
393
|
+
client,
|
|
394
|
+
server
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
const manifest_path = `${paths.output_dir}/server/manifest.js`;
|
|
398
|
+
fs.writeFileSync(
|
|
399
|
+
manifest_path,
|
|
400
|
+
`export const manifest = ${generate_manifest({
|
|
401
|
+
build_data,
|
|
402
|
+
relative_path: '.',
|
|
403
|
+
routes: manifest_data.routes
|
|
404
|
+
})};\n`
|
|
344
405
|
);
|
|
345
406
|
|
|
346
|
-
|
|
407
|
+
log.info('Prerendering');
|
|
408
|
+
await new Promise((fulfil, reject) => {
|
|
409
|
+
const results_path = `${svelte_config.kit.outDir}/generated/prerendered.json`;
|
|
347
410
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
module_node,
|
|
352
|
-
illegal_imports
|
|
411
|
+
// do prerendering in a subprocess so any dangling stuff gets killed upon completion
|
|
412
|
+
const script = fileURLToPath(
|
|
413
|
+
new URL('../../core/prerender/prerender.js', import.meta.url)
|
|
353
414
|
);
|
|
354
|
-
}
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
const verbose = vite_config.logLevel === 'info';
|
|
358
|
-
log = logger({
|
|
359
|
-
verbose
|
|
360
|
-
});
|
|
361
|
-
|
|
362
|
-
fs.writeFileSync(
|
|
363
|
-
`${paths.client_out_dir}/${svelte_config.kit.appDir}/version.json`,
|
|
364
|
-
JSON.stringify({ version: svelte_config.kit.version.name })
|
|
365
|
-
);
|
|
366
|
-
|
|
367
|
-
const { assets, chunks } = collect_output(bundle);
|
|
368
|
-
log.info(`Client build completed. Wrote ${chunks.length} chunks and ${assets.length} assets`);
|
|
369
|
-
|
|
370
|
-
log.info('Building server');
|
|
371
|
-
const options = {
|
|
372
|
-
cwd,
|
|
373
|
-
config: svelte_config,
|
|
374
|
-
vite_config,
|
|
375
|
-
vite_config_env,
|
|
376
|
-
build_dir: paths.build_dir, // TODO just pass `paths`
|
|
377
|
-
manifest_data,
|
|
378
|
-
output_dir: paths.output_dir,
|
|
379
|
-
service_worker_entry_file: resolve_entry(svelte_config.kit.files.serviceWorker)
|
|
380
|
-
};
|
|
381
|
-
const client = client_build_info(assets, chunks);
|
|
382
|
-
const server = await build_server(options, client);
|
|
383
|
-
|
|
384
|
-
/** @type {import('types').BuildData} */
|
|
385
|
-
build_data = {
|
|
386
|
-
app_dir: svelte_config.kit.appDir,
|
|
387
|
-
manifest_data,
|
|
388
|
-
service_worker: options.service_worker_entry_file ? 'service-worker.js' : null, // TODO make file configurable?
|
|
389
|
-
client,
|
|
390
|
-
server
|
|
391
|
-
};
|
|
392
415
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
// do prerendering in a subprocess so any dangling stuff gets killed upon completion
|
|
408
|
-
const script = fileURLToPath(new URL('../../core/prerender/prerender.js', import.meta.url));
|
|
409
|
-
|
|
410
|
-
const child = fork(
|
|
411
|
-
script,
|
|
412
|
-
[
|
|
413
|
-
vite_config.build.outDir,
|
|
414
|
-
results_path,
|
|
415
|
-
manifest_path,
|
|
416
|
-
'' + verbose,
|
|
417
|
-
JSON.stringify({ ...env.private, ...env.public })
|
|
418
|
-
],
|
|
419
|
-
{
|
|
420
|
-
stdio: 'inherit'
|
|
421
|
-
}
|
|
422
|
-
);
|
|
416
|
+
const child = fork(
|
|
417
|
+
script,
|
|
418
|
+
[
|
|
419
|
+
vite_config.build.outDir,
|
|
420
|
+
results_path,
|
|
421
|
+
manifest_path,
|
|
422
|
+
'' + verbose,
|
|
423
|
+
JSON.stringify({ ...env.private, ...env.public })
|
|
424
|
+
],
|
|
425
|
+
{
|
|
426
|
+
stdio: 'inherit'
|
|
427
|
+
}
|
|
428
|
+
);
|
|
423
429
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
430
|
+
child.on('exit', (code) => {
|
|
431
|
+
if (code) {
|
|
432
|
+
reject(new Error(`Prerendering failed with code ${code}`));
|
|
433
|
+
} else {
|
|
434
|
+
prerendered = JSON.parse(fs.readFileSync(results_path, 'utf8'), (key, value) => {
|
|
435
|
+
if (key === 'pages' || key === 'assets' || key === 'redirects') {
|
|
436
|
+
return new Map(value);
|
|
437
|
+
}
|
|
438
|
+
return value;
|
|
439
|
+
});
|
|
440
|
+
fulfil(undefined);
|
|
441
|
+
}
|
|
442
|
+
});
|
|
436
443
|
});
|
|
437
|
-
});
|
|
438
444
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
445
|
+
if (options.service_worker_entry_file) {
|
|
446
|
+
if (svelte_config.kit.paths.assets) {
|
|
447
|
+
throw new Error('Cannot use service worker alongside config.kit.paths.assets');
|
|
448
|
+
}
|
|
443
449
|
|
|
444
|
-
|
|
450
|
+
log.info('Building service worker');
|
|
445
451
|
|
|
446
|
-
|
|
447
|
-
|
|
452
|
+
await build_service_worker(options, prerendered, client.vite_manifest);
|
|
453
|
+
}
|
|
448
454
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
455
|
+
console.log(
|
|
456
|
+
`\nRun ${colors.bold().cyan('npm run preview')} to preview your production build locally.`
|
|
457
|
+
);
|
|
452
458
|
|
|
453
|
-
|
|
459
|
+
completed_build = true;
|
|
460
|
+
}
|
|
454
461
|
},
|
|
455
462
|
|
|
456
463
|
/**
|
|
457
464
|
* Runs the adapter.
|
|
458
465
|
*/
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
+
closeBundle: {
|
|
467
|
+
sequential: true,
|
|
468
|
+
async handler() {
|
|
469
|
+
// vite calls closeBundle when dev-server restarts, ignore that,
|
|
470
|
+
// and only adapt when build successfully completes.
|
|
471
|
+
const is_restart = !completed_build;
|
|
472
|
+
if (vite_config.build.ssr || is_restart) {
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
466
475
|
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
476
|
+
if (svelte_config.kit.adapter) {
|
|
477
|
+
const { adapt } = await import('../../core/adapt/index.js');
|
|
478
|
+
await adapt(svelte_config, build_data, prerendered, { log });
|
|
479
|
+
} else {
|
|
480
|
+
console.log(colors.bold().yellow('\nNo adapter specified'));
|
|
472
481
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
482
|
+
const link = colors.bold().cyan('https://kit.svelte.dev/docs/adapters');
|
|
483
|
+
console.log(
|
|
484
|
+
`See ${link} to learn how to configure your app to run on the platform of your choosing`
|
|
485
|
+
);
|
|
486
|
+
}
|
|
478
487
|
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
488
|
+
// avoid making the manifest available to users
|
|
489
|
+
fs.unlinkSync(`${paths.output_dir}/client/${vite_config.build.manifest}`);
|
|
490
|
+
fs.unlinkSync(`${paths.output_dir}/server/${vite_config.build.manifest}`);
|
|
491
|
+
}
|
|
482
492
|
},
|
|
483
493
|
|
|
484
494
|
/**
|
|
@@ -65,7 +65,7 @@ export async function respond(request, options, state) {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
const is_data_request = decoded.endsWith(DATA_SUFFIX);
|
|
68
|
-
if (is_data_request) decoded = decoded.slice(0, -DATA_SUFFIX.length);
|
|
68
|
+
if (is_data_request) decoded = decoded.slice(0, -DATA_SUFFIX.length) || '/';
|
|
69
69
|
|
|
70
70
|
if (!state.prerendering?.fallback) {
|
|
71
71
|
const matchers = await options.manifest._.matchers();
|
package/types/index.d.ts
CHANGED
|
@@ -99,7 +99,7 @@ export interface Builder {
|
|
|
99
99
|
/**
|
|
100
100
|
* @param {string} directory Path to the directory containing the files to be compressed
|
|
101
101
|
*/
|
|
102
|
-
compress(directory: string): void
|
|
102
|
+
compress(directory: string): Promise<void>;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
export interface Config {
|