@sveltejs/kit 1.0.0-next.331 → 1.0.0-next.334
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/assets/server/index.js +3 -1
- package/dist/chunks/index.js +31 -8
- package/dist/cli.js +6 -6
- package/package.json +1 -1
package/assets/server/index.js
CHANGED
|
@@ -1266,7 +1266,9 @@ async function render_response({
|
|
|
1266
1266
|
|
|
1267
1267
|
const init_service_worker = `
|
|
1268
1268
|
if ('serviceWorker' in navigator) {
|
|
1269
|
-
|
|
1269
|
+
addEventListener('load', () => {
|
|
1270
|
+
navigator.serviceWorker.register('${options.service_worker}');
|
|
1271
|
+
});
|
|
1270
1272
|
}
|
|
1271
1273
|
`;
|
|
1272
1274
|
|
package/dist/chunks/index.js
CHANGED
|
@@ -85,7 +85,7 @@ async function create_plugin(config, cwd) {
|
|
|
85
85
|
if (!node) throw new Error(`Could not find node for ${url}`);
|
|
86
86
|
|
|
87
87
|
const deps = new Set();
|
|
88
|
-
find_deps(node, deps);
|
|
88
|
+
await find_deps(vite, node, deps);
|
|
89
89
|
|
|
90
90
|
/** @type {Record<string, string>} */
|
|
91
91
|
const styles = {};
|
|
@@ -399,23 +399,45 @@ function remove_html_middlewares(server) {
|
|
|
399
399
|
}
|
|
400
400
|
|
|
401
401
|
/**
|
|
402
|
+
* @param {import('vite').ViteDevServer} vite
|
|
402
403
|
* @param {import('vite').ModuleNode} node
|
|
403
404
|
* @param {Set<import('vite').ModuleNode>} deps
|
|
404
405
|
*/
|
|
405
|
-
function find_deps(node, deps) {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
406
|
+
function find_deps(vite, node, deps) {
|
|
407
|
+
// since `ssrTransformResult.deps` contains URLs instead of `ModuleNode`s, this process is asynchronous.
|
|
408
|
+
// instead of using `await`, we resolve all branches in parallel.
|
|
409
|
+
/** @type {Promise<void>[]} */
|
|
410
|
+
const branches = [];
|
|
411
|
+
|
|
412
|
+
/** @param {import('vite').ModuleNode} node */
|
|
413
|
+
function add(node) {
|
|
414
|
+
if (!deps.has(node)) {
|
|
415
|
+
deps.add(node);
|
|
416
|
+
branches.push(find_deps(vite, node, deps));
|
|
410
417
|
}
|
|
411
418
|
}
|
|
419
|
+
|
|
420
|
+
/** @param {string} url */
|
|
421
|
+
async function add_by_url(url) {
|
|
422
|
+
branches.push(vite.moduleGraph.getModuleByUrl(url).then((node) => node && add(node)));
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
if (node.ssrTransformResult) {
|
|
426
|
+
if (node.ssrTransformResult.deps) {
|
|
427
|
+
node.ssrTransformResult.deps.forEach(add_by_url);
|
|
428
|
+
}
|
|
429
|
+
} else {
|
|
430
|
+
node.importedModules.forEach(add);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
return Promise.all(branches).then(() => {});
|
|
412
434
|
}
|
|
413
435
|
|
|
414
436
|
/**
|
|
415
437
|
* @typedef {{
|
|
416
438
|
* cwd: string,
|
|
417
439
|
* port: number,
|
|
418
|
-
* host
|
|
440
|
+
* host?: string,
|
|
419
441
|
* https: boolean,
|
|
420
442
|
* config: import('types').ValidatedConfig
|
|
421
443
|
* }} Options
|
|
@@ -439,7 +461,8 @@ async function dev({ cwd, port, host, https, config }) {
|
|
|
439
461
|
path__default.resolve(cwd, 'node_modules'),
|
|
440
462
|
path__default.resolve(vite.searchForWorkspaceRoot(cwd), 'node_modules')
|
|
441
463
|
])
|
|
442
|
-
]
|
|
464
|
+
],
|
|
465
|
+
port: 3000
|
|
443
466
|
},
|
|
444
467
|
strictPort: true
|
|
445
468
|
}
|
package/dist/cli.js
CHANGED
|
@@ -870,15 +870,15 @@ async function launch(port, https, base) {
|
|
|
870
870
|
exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}${base}`);
|
|
871
871
|
}
|
|
872
872
|
|
|
873
|
-
const prog = sade('svelte-kit').version('1.0.0-next.
|
|
873
|
+
const prog = sade('svelte-kit').version('1.0.0-next.334');
|
|
874
874
|
|
|
875
875
|
prog
|
|
876
876
|
.command('dev')
|
|
877
877
|
.describe('Start a development server')
|
|
878
|
-
.option('-p, --port', 'Port'
|
|
879
|
-
.option('-o, --open', 'Open a browser tab'
|
|
880
|
-
.option('--host', 'Host (only use this on trusted networks)'
|
|
881
|
-
.option('--https', 'Use self-signed HTTPS certificate'
|
|
878
|
+
.option('-p, --port', 'Port')
|
|
879
|
+
.option('-o, --open', 'Open a browser tab')
|
|
880
|
+
.option('--host', 'Host (only use this on trusted networks)')
|
|
881
|
+
.option('--https', 'Use self-signed HTTPS certificate')
|
|
882
882
|
.option('-H', 'no longer supported, use --https instead') // TODO remove for 1.0
|
|
883
883
|
.action(async ({ port, host, https, open, H }) => {
|
|
884
884
|
try {
|
|
@@ -1049,7 +1049,7 @@ async function check_port(port) {
|
|
|
1049
1049
|
function welcome({ port, host, https, open, base, loose, allow, cwd }) {
|
|
1050
1050
|
if (open) launch(port, https, base);
|
|
1051
1051
|
|
|
1052
|
-
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.
|
|
1052
|
+
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.334'}\n`));
|
|
1053
1053
|
|
|
1054
1054
|
const protocol = https ? 'https:' : 'http:';
|
|
1055
1055
|
const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
|