@sveltejs/kit 1.0.0-next.341 → 1.0.0-next.344
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/client/start.js +59 -49
- package/assets/server/index.js +1 -1
- package/dist/chunks/index.js +24 -25
- package/dist/chunks/index2.js +17 -12
- package/dist/chunks/index5.js +14 -5
- package/dist/chunks/index6.js +1 -1
- package/dist/chunks/sync.js +2 -5
- package/dist/chunks/write_tsconfig.js +12 -4
- package/dist/cli.js +20 -19
- package/package.json +2 -2
package/assets/client/start.js
CHANGED
|
@@ -110,23 +110,6 @@ function normalize_path(path, trailing_slash) {
|
|
|
110
110
|
return path;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
/**
|
|
114
|
-
* Hash using djb2
|
|
115
|
-
* @param {import('types').StrictBody} value
|
|
116
|
-
*/
|
|
117
|
-
function hash(value) {
|
|
118
|
-
let hash = 5381;
|
|
119
|
-
let i = value.length;
|
|
120
|
-
|
|
121
|
-
if (typeof value === 'string') {
|
|
122
|
-
while (i) hash = (hash * 33) ^ value.charCodeAt(--i);
|
|
123
|
-
} else {
|
|
124
|
-
while (i) hash = (hash * 33) ^ value[--i];
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return (hash >>> 0).toString(36);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
113
|
/** @param {HTMLDocument} doc */
|
|
131
114
|
function get_base_uri(doc) {
|
|
132
115
|
let baseURI = doc.baseURI;
|
|
@@ -241,6 +224,60 @@ function create_updated_store() {
|
|
|
241
224
|
};
|
|
242
225
|
}
|
|
243
226
|
|
|
227
|
+
/**
|
|
228
|
+
* Hash using djb2
|
|
229
|
+
* @param {import('types').StrictBody} value
|
|
230
|
+
*/
|
|
231
|
+
function hash(value) {
|
|
232
|
+
let hash = 5381;
|
|
233
|
+
let i = value.length;
|
|
234
|
+
|
|
235
|
+
if (typeof value === 'string') {
|
|
236
|
+
while (i) hash = (hash * 33) ^ value.charCodeAt(--i);
|
|
237
|
+
} else {
|
|
238
|
+
while (i) hash = (hash * 33) ^ value[--i];
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return (hash >>> 0).toString(36);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
let loading = 0;
|
|
245
|
+
|
|
246
|
+
const native_fetch = window.fetch;
|
|
247
|
+
|
|
248
|
+
function lock_fetch() {
|
|
249
|
+
loading += 1;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function unlock_fetch() {
|
|
253
|
+
loading -= 1;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (import.meta.env.DEV) {
|
|
257
|
+
let can_inspect_stack_trace = false;
|
|
258
|
+
|
|
259
|
+
const check_stack_trace = async () => {
|
|
260
|
+
const stack = /** @type {string} */ (new Error().stack);
|
|
261
|
+
can_inspect_stack_trace = stack.includes('check_stack_trace');
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
check_stack_trace();
|
|
265
|
+
|
|
266
|
+
window.fetch = (input, init) => {
|
|
267
|
+
const url = input instanceof Request ? input.url : input.toString();
|
|
268
|
+
const stack = /** @type {string} */ (new Error().stack);
|
|
269
|
+
|
|
270
|
+
const heuristic = can_inspect_stack_trace ? stack.includes('load_node') : loading;
|
|
271
|
+
if (heuristic) {
|
|
272
|
+
console.warn(
|
|
273
|
+
`Loading ${url} using \`window.fetch\`. For best results, use the \`fetch\` that is passed to your \`load\` function: https://kit.svelte.dev/docs/loading#input-fetch`
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
return native_fetch(input, init);
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
|
|
244
281
|
/**
|
|
245
282
|
* @param {RequestInfo} resource
|
|
246
283
|
* @param {RequestInit} [opts]
|
|
@@ -260,7 +297,7 @@ function initial_fetch(resource, opts) {
|
|
|
260
297
|
return Promise.resolve(new Response(body, init));
|
|
261
298
|
}
|
|
262
299
|
|
|
263
|
-
return
|
|
300
|
+
return native_fetch(resource, opts);
|
|
264
301
|
}
|
|
265
302
|
|
|
266
303
|
const param_pattern = /^(\.\.\.)?(\w+)(?:=(\w+))?$/;
|
|
@@ -423,33 +460,6 @@ function update_scroll_positions(index) {
|
|
|
423
460
|
scroll_positions[index] = scroll_state();
|
|
424
461
|
}
|
|
425
462
|
|
|
426
|
-
const fetch$1 = window.fetch;
|
|
427
|
-
let loading = 0;
|
|
428
|
-
|
|
429
|
-
if (import.meta.env.DEV) {
|
|
430
|
-
let can_inspect_stack_trace = false;
|
|
431
|
-
|
|
432
|
-
const check_stack_trace = async () => {
|
|
433
|
-
const stack = /** @type {string} */ (new Error().stack);
|
|
434
|
-
can_inspect_stack_trace = stack.includes('check_stack_trace');
|
|
435
|
-
};
|
|
436
|
-
|
|
437
|
-
check_stack_trace();
|
|
438
|
-
|
|
439
|
-
window.fetch = (input, init) => {
|
|
440
|
-
const url = input instanceof Request ? input.url : input.toString();
|
|
441
|
-
const stack = /** @type {string} */ (new Error().stack);
|
|
442
|
-
|
|
443
|
-
const heuristic = can_inspect_stack_trace ? stack.includes('load_node') : loading;
|
|
444
|
-
if (heuristic) {
|
|
445
|
-
console.warn(
|
|
446
|
-
`Loading ${url} using \`window.fetch\`. For best results, use the \`fetch\` that is passed to your \`load\` function: https://kit.svelte.dev/docs/loading#input-fetch`
|
|
447
|
-
);
|
|
448
|
-
}
|
|
449
|
-
return fetch$1(input, init);
|
|
450
|
-
};
|
|
451
|
-
}
|
|
452
|
-
|
|
453
463
|
/**
|
|
454
464
|
* @param {{
|
|
455
465
|
* target: Element;
|
|
@@ -996,7 +1006,7 @@ function create_client({ target, session, base, trailing_slash }) {
|
|
|
996
1006
|
add_dependency(normalized);
|
|
997
1007
|
|
|
998
1008
|
// prerendered pages may be served from any origin, so `initial_fetch` urls shouldn't be normalized
|
|
999
|
-
return started ?
|
|
1009
|
+
return started ? native_fetch(normalized, init) : initial_fetch(requested, init);
|
|
1000
1010
|
},
|
|
1001
1011
|
status: status ?? null,
|
|
1002
1012
|
error: error ?? null
|
|
@@ -1015,10 +1025,10 @@ function create_client({ target, session, base, trailing_slash }) {
|
|
|
1015
1025
|
|
|
1016
1026
|
if (import.meta.env.DEV) {
|
|
1017
1027
|
try {
|
|
1018
|
-
|
|
1028
|
+
lock_fetch();
|
|
1019
1029
|
loaded = await module.load.call(null, load_input);
|
|
1020
1030
|
} finally {
|
|
1021
|
-
|
|
1031
|
+
unlock_fetch();
|
|
1022
1032
|
}
|
|
1023
1033
|
} else {
|
|
1024
1034
|
loaded = await module.load.call(null, load_input);
|
|
@@ -1106,7 +1116,7 @@ function create_client({ target, session, base, trailing_slash }) {
|
|
|
1106
1116
|
const is_shadow_page = has_shadow && i === a.length - 1;
|
|
1107
1117
|
|
|
1108
1118
|
if (is_shadow_page) {
|
|
1109
|
-
const res = await
|
|
1119
|
+
const res = await native_fetch(
|
|
1110
1120
|
`${url.pathname}${url.pathname.endsWith('/') ? '' : '/'}__data.json${url.search}`,
|
|
1111
1121
|
{
|
|
1112
1122
|
headers: {
|
package/assets/server/index.js
CHANGED
|
@@ -115,7 +115,7 @@ const text_types = new Set([
|
|
|
115
115
|
]);
|
|
116
116
|
|
|
117
117
|
/**
|
|
118
|
-
* Decides how the body should be parsed based on its mime type
|
|
118
|
+
* Decides how the body should be parsed based on its mime type
|
|
119
119
|
*
|
|
120
120
|
* @param {string | undefined | null} content_type The `content-type` header of a request/response.
|
|
121
121
|
* @returns {boolean}
|
package/dist/chunks/index.js
CHANGED
|
@@ -2,12 +2,12 @@ import path__default from 'path';
|
|
|
2
2
|
import { svelte } from '@sveltejs/vite-plugin-svelte';
|
|
3
3
|
import * as vite from 'vite';
|
|
4
4
|
import { d as deep_merge } from './object.js';
|
|
5
|
-
import { g as get_runtime_path, r as resolve_entry, $, l as load_template, c as coalesce_to_error, a as get_mime_lookup, b as get_aliases, p as print_config_conflicts } from '../cli.js';
|
|
5
|
+
import { g as get_runtime_path, r as resolve_entry, $, l as load_template, c as coalesce_to_error, a as get_mime_lookup, b as load_config, d as get_aliases, p as print_config_conflicts } from '../cli.js';
|
|
6
6
|
import fs__default from 'fs';
|
|
7
7
|
import { URL } from 'url';
|
|
8
8
|
import { S as SVELTE_KIT_ASSETS, s as sirv } from './constants.js';
|
|
9
9
|
import { installPolyfills } from '../node/polyfills.js';
|
|
10
|
-
import {
|
|
10
|
+
import { init, update } from './sync.js';
|
|
11
11
|
import { getRequest, setResponse } from '../node.js';
|
|
12
12
|
import { p as posixify } from './filesystem.js';
|
|
13
13
|
import { p as parse_route_id } from './misc.js';
|
|
@@ -38,19 +38,21 @@ const cwd$1 = process.cwd();
|
|
|
38
38
|
* @returns {Promise<import('vite').Plugin>}
|
|
39
39
|
*/
|
|
40
40
|
async function create_plugin(config) {
|
|
41
|
-
const runtime = get_runtime_path(config);
|
|
42
|
-
|
|
43
|
-
process.env.VITE_SVELTEKIT_APP_VERSION_POLL_INTERVAL = '0';
|
|
44
|
-
|
|
45
|
-
/** @type {import('types').Respond} */
|
|
46
|
-
const respond = (await import(`${runtime}/server/index.js`)).respond;
|
|
47
|
-
|
|
48
41
|
return {
|
|
49
42
|
name: 'vite-plugin-svelte-kit',
|
|
50
43
|
|
|
51
|
-
configureServer(vite) {
|
|
44
|
+
async configureServer(vite) {
|
|
52
45
|
installPolyfills();
|
|
53
46
|
|
|
47
|
+
init(config);
|
|
48
|
+
|
|
49
|
+
const runtime = get_runtime_path(config);
|
|
50
|
+
|
|
51
|
+
process.env.VITE_SVELTEKIT_APP_VERSION_POLL_INTERVAL = '0';
|
|
52
|
+
|
|
53
|
+
/** @type {import('types').Respond} */
|
|
54
|
+
const respond = (await import(`${runtime}/server/index.js`)).respond;
|
|
55
|
+
|
|
54
56
|
/** @type {import('types').SSRManifest} */
|
|
55
57
|
let manifest;
|
|
56
58
|
|
|
@@ -209,14 +211,16 @@ async function create_plugin(config) {
|
|
|
209
211
|
const file = config.kit.files.assets + pathname;
|
|
210
212
|
|
|
211
213
|
if (fs__default.existsSync(file) && !fs__default.statSync(file).isDirectory()) {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
214
|
+
const has_correct_case = fs__default.realpathSync.native(file) === path__default.resolve(file);
|
|
215
|
+
|
|
216
|
+
if (has_correct_case) {
|
|
217
|
+
req.url = encodeURI(pathname); // don't need query/hash
|
|
218
|
+
asset_server(req, res);
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
215
221
|
}
|
|
216
222
|
}
|
|
217
223
|
|
|
218
|
-
if (req.url === '/favicon.ico') return not_found(res);
|
|
219
|
-
|
|
220
224
|
if (!decoded.startsWith(config.kit.paths.base)) {
|
|
221
225
|
return not_found(res, `Not found (did you mean ${config.kit.paths.base + req.url}?)`);
|
|
222
226
|
}
|
|
@@ -449,14 +453,14 @@ const cwd = process.cwd();
|
|
|
449
453
|
* port: number,
|
|
450
454
|
* host?: string,
|
|
451
455
|
* https: boolean,
|
|
452
|
-
* config: import('types').ValidatedConfig
|
|
453
456
|
* }} Options
|
|
454
457
|
* @typedef {import('types').SSRComponent} SSRComponent
|
|
455
458
|
*/
|
|
456
459
|
|
|
457
460
|
/** @param {Options} opts */
|
|
458
|
-
async function dev({ port, host, https
|
|
459
|
-
|
|
461
|
+
async function dev({ port, host, https }) {
|
|
462
|
+
/** @type {import('types').ValidatedConfig} */
|
|
463
|
+
const config = await load_config();
|
|
460
464
|
|
|
461
465
|
const [vite_config] = deep_merge(
|
|
462
466
|
{
|
|
@@ -533,14 +537,9 @@ async function dev({ port, host, https, config }) {
|
|
|
533
537
|
const server = await vite.createServer(merged_config);
|
|
534
538
|
await server.listen(port);
|
|
535
539
|
|
|
536
|
-
const address_info = /** @type {import('net').AddressInfo} */ (
|
|
537
|
-
/** @type {import('http').Server} */ (server.httpServer).address()
|
|
538
|
-
);
|
|
539
|
-
|
|
540
540
|
return {
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
close: () => server.close()
|
|
541
|
+
server,
|
|
542
|
+
config
|
|
544
543
|
};
|
|
545
544
|
}
|
|
546
545
|
|
package/dist/chunks/index2.js
CHANGED
|
@@ -2,7 +2,7 @@ import fs__default, { readFileSync, writeFileSync } from 'fs';
|
|
|
2
2
|
import path__default, { join, dirname } from 'path';
|
|
3
3
|
import { p as posixify, m as mkdirp, r as rimraf } from './filesystem.js';
|
|
4
4
|
import { all } from './sync.js';
|
|
5
|
-
import { p as print_config_conflicts,
|
|
5
|
+
import { p as print_config_conflicts, d as get_aliases, r as resolve_entry, g as get_runtime_path, l as load_template } from '../cli.js';
|
|
6
6
|
import { g as generate_manifest } from './index3.js';
|
|
7
7
|
import * as vite from 'vite';
|
|
8
8
|
import { s } from './misc.js';
|
|
@@ -118,7 +118,7 @@ async function build_service_worker(
|
|
|
118
118
|
|
|
119
119
|
export const build = [
|
|
120
120
|
${Array.from(build)
|
|
121
|
-
.map((file) => `${s(`${config.kit.paths.base}/${config.kit.appDir}/${file}`)}`)
|
|
121
|
+
.map((file) => `${s(`${config.kit.paths.base}/${config.kit.appDir}/immutable/${file}`)}`)
|
|
122
122
|
.join(',\n\t\t\t\t')}
|
|
123
123
|
];
|
|
124
124
|
|
|
@@ -267,7 +267,7 @@ async function build_client({
|
|
|
267
267
|
build: {
|
|
268
268
|
cssCodeSplit: true,
|
|
269
269
|
manifest: true,
|
|
270
|
-
outDir: client_out_dir
|
|
270
|
+
outDir: `${client_out_dir}/immutable`,
|
|
271
271
|
polyfillDynamicImport: false,
|
|
272
272
|
rollupOptions: {
|
|
273
273
|
input,
|
|
@@ -303,7 +303,9 @@ async function build_client({
|
|
|
303
303
|
const { chunks, assets } = await create_build(merged_config);
|
|
304
304
|
|
|
305
305
|
/** @type {import('vite').Manifest} */
|
|
306
|
-
const vite_manifest = JSON.parse(
|
|
306
|
+
const vite_manifest = JSON.parse(
|
|
307
|
+
fs__default.readFileSync(`${client_out_dir}/immutable/manifest.json`, 'utf-8')
|
|
308
|
+
);
|
|
307
309
|
|
|
308
310
|
const entry = posixify(client_entry_file);
|
|
309
311
|
const entry_js = new Set();
|
|
@@ -388,7 +390,7 @@ export class Server {
|
|
|
388
390
|
manifest,
|
|
389
391
|
method_override: ${s(config.kit.methodOverride)},
|
|
390
392
|
paths: { base, assets },
|
|
391
|
-
prefix: assets + '/${config.kit.appDir}/',
|
|
393
|
+
prefix: assets + '/${config.kit.appDir}/immutable/',
|
|
392
394
|
prerender: {
|
|
393
395
|
default: ${config.kit.prerender.default},
|
|
394
396
|
enabled: ${config.kit.prerender.enabled}
|
|
@@ -1312,15 +1314,18 @@ async function build(config, { log }) {
|
|
|
1312
1314
|
|
|
1313
1315
|
const { manifest_data } = all(config);
|
|
1314
1316
|
|
|
1317
|
+
// TODO this is so that Vite's preloading works. Unfortunately, it fails
|
|
1318
|
+
// during `svelte-kit preview`, because we use a local asset path. If Vite
|
|
1319
|
+
// used relative paths, I _think_ this could get fixed. Issue here:
|
|
1320
|
+
// https://github.com/vitejs/vite/issues/2009
|
|
1321
|
+
const { base, assets } = config.kit.paths;
|
|
1322
|
+
const assets_base = `${assets || base}/${config.kit.appDir}/immutable/`;
|
|
1323
|
+
|
|
1315
1324
|
const options = {
|
|
1316
1325
|
cwd,
|
|
1317
1326
|
config,
|
|
1318
1327
|
build_dir,
|
|
1319
|
-
|
|
1320
|
-
// during `svelte-kit preview`, because we use a local asset path. If Vite
|
|
1321
|
-
// used relative paths, I _think_ this could get fixed. Issue here:
|
|
1322
|
-
// https://github.com/vitejs/vite/issues/2009
|
|
1323
|
-
assets_base: `${config.kit.paths.assets || config.kit.paths.base}/${config.kit.appDir}/`,
|
|
1328
|
+
assets_base,
|
|
1324
1329
|
manifest_data,
|
|
1325
1330
|
output_dir,
|
|
1326
1331
|
client_entry_file: path__default.relative(cwd, `${get_runtime_path(config)}/client/start.js`),
|
|
@@ -1351,8 +1356,8 @@ async function build(config, { log }) {
|
|
|
1351
1356
|
|
|
1352
1357
|
const files = new Set([
|
|
1353
1358
|
...static_files,
|
|
1354
|
-
...client.chunks.map((chunk) => `${config.kit.appDir}/${chunk.fileName}`),
|
|
1355
|
-
...client.assets.map((chunk) => `${config.kit.appDir}/${chunk.fileName}`)
|
|
1359
|
+
...client.chunks.map((chunk) => `${config.kit.appDir}/immutable/${chunk.fileName}`),
|
|
1360
|
+
...client.assets.map((chunk) => `${config.kit.appDir}/immutable/${chunk.fileName}`)
|
|
1356
1361
|
]);
|
|
1357
1362
|
|
|
1358
1363
|
// TODO is this right?
|
package/dist/chunks/index5.js
CHANGED
|
@@ -6,6 +6,7 @@ import { S as SVELTE_KIT_ASSETS, s as sirv } from './constants.js';
|
|
|
6
6
|
import { pathToFileURL } from 'url';
|
|
7
7
|
import { getRequest, setResponse } from '../node.js';
|
|
8
8
|
import { installPolyfills } from '../node/polyfills.js';
|
|
9
|
+
import { b as load_config } from '../cli.js';
|
|
9
10
|
import 'querystring';
|
|
10
11
|
import 'stream';
|
|
11
12
|
import 'node:http';
|
|
@@ -16,6 +17,10 @@ import 'node:util';
|
|
|
16
17
|
import 'node:url';
|
|
17
18
|
import 'net';
|
|
18
19
|
import 'crypto';
|
|
20
|
+
import 'sade';
|
|
21
|
+
import 'child_process';
|
|
22
|
+
import 'chokidar';
|
|
23
|
+
import 'os';
|
|
19
24
|
|
|
20
25
|
/** @typedef {import('http').IncomingMessage} Req */
|
|
21
26
|
/** @typedef {import('http').ServerResponse} Res */
|
|
@@ -37,14 +42,14 @@ const mutable = (dir) =>
|
|
|
37
42
|
* @param {{
|
|
38
43
|
* port: number;
|
|
39
44
|
* host?: string;
|
|
40
|
-
* config: import('types').ValidatedConfig;
|
|
41
45
|
* https?: boolean;
|
|
42
46
|
* cwd?: string;
|
|
43
47
|
* }} opts
|
|
44
48
|
*/
|
|
45
|
-
async function preview({ port, host,
|
|
49
|
+
async function preview({ port, host, https: use_https = false }) {
|
|
46
50
|
installPolyfills();
|
|
47
51
|
|
|
52
|
+
const config = await load_config();
|
|
48
53
|
const { paths } = config.kit;
|
|
49
54
|
const base = paths.base;
|
|
50
55
|
const assets = paths.assets ? SVELTE_KIT_ASSETS : paths.base;
|
|
@@ -75,8 +80,12 @@ async function preview({ port, host, config, https: use_https = false }) {
|
|
|
75
80
|
scoped(
|
|
76
81
|
assets,
|
|
77
82
|
sirv(join(config.kit.outDir, 'output/client'), {
|
|
78
|
-
|
|
79
|
-
|
|
83
|
+
setHeaders: (res, pathname) => {
|
|
84
|
+
// only apply to build directory, not e.g. version.json
|
|
85
|
+
if (pathname.startsWith(`/${config.kit.appDir}/immutable`)) {
|
|
86
|
+
res.setHeader('cache-control', 'public,max-age=31536000,immutable');
|
|
87
|
+
}
|
|
88
|
+
}
|
|
80
89
|
})
|
|
81
90
|
),
|
|
82
91
|
|
|
@@ -172,7 +181,7 @@ async function preview({ port, host, config, https: use_https = false }) {
|
|
|
172
181
|
|
|
173
182
|
return new Promise((fulfil) => {
|
|
174
183
|
http_server.listen(port, host, () => {
|
|
175
|
-
fulfil(http_server);
|
|
184
|
+
fulfil({ server: http_server, config });
|
|
176
185
|
});
|
|
177
186
|
});
|
|
178
187
|
}
|
package/dist/chunks/index6.js
CHANGED
|
@@ -5,7 +5,7 @@ import { $ } from '../cli.js';
|
|
|
5
5
|
import chokidar from 'chokidar';
|
|
6
6
|
import { w as walk$1, m as mkdirp, p as posixify, r as rimraf, c as copy } from './filesystem.js';
|
|
7
7
|
import { createRequire } from 'module';
|
|
8
|
-
import {
|
|
8
|
+
import { b as write_tsconfig } from './write_tsconfig.js';
|
|
9
9
|
import 'sade';
|
|
10
10
|
import 'child_process';
|
|
11
11
|
import 'net';
|
package/dist/chunks/sync.js
CHANGED
|
@@ -4,7 +4,7 @@ import { g as get_runtime_path } from '../cli.js';
|
|
|
4
4
|
import { p as posixify, c as copy, r as rimraf } from './filesystem.js';
|
|
5
5
|
import { p as parse_route_id, s } from './misc.js';
|
|
6
6
|
import { fileURLToPath } from 'url';
|
|
7
|
-
import { w as write_if_changed, t as trim, a as write_tsconfig } from './write_tsconfig.js';
|
|
7
|
+
import { w as write_if_changed, t as trim, a as write, b as write_tsconfig } from './write_tsconfig.js';
|
|
8
8
|
import 'sade';
|
|
9
9
|
import 'child_process';
|
|
10
10
|
import 'net';
|
|
@@ -821,10 +821,7 @@ function write_types(config, manifest_data) {
|
|
|
821
821
|
const parts = (key || 'index').split('/');
|
|
822
822
|
parts.push('__types', /** @type {string} */ (parts.pop()));
|
|
823
823
|
|
|
824
|
-
|
|
825
|
-
`${config.kit.outDir}/types/${parts.join('/')}.d.ts`,
|
|
826
|
-
content.join('\n').trim()
|
|
827
|
-
);
|
|
824
|
+
write(`${config.kit.outDir}/types/${parts.join('/')}.d.ts`, content.join('\n').trim());
|
|
828
825
|
});
|
|
829
826
|
}
|
|
830
827
|
|
|
@@ -12,12 +12,20 @@ const previous_contents = new Map();
|
|
|
12
12
|
*/
|
|
13
13
|
function write_if_changed(file, code) {
|
|
14
14
|
if (code !== previous_contents.get(file)) {
|
|
15
|
-
|
|
16
|
-
mkdirp(path__default.dirname(file));
|
|
17
|
-
fs__default.writeFileSync(file, code);
|
|
15
|
+
write(file, code);
|
|
18
16
|
}
|
|
19
17
|
}
|
|
20
18
|
|
|
19
|
+
/**
|
|
20
|
+
* @param {string} file
|
|
21
|
+
* @param {string} code
|
|
22
|
+
*/
|
|
23
|
+
function write(file, code) {
|
|
24
|
+
previous_contents.set(file, code);
|
|
25
|
+
mkdirp(path__default.dirname(file));
|
|
26
|
+
fs__default.writeFileSync(file, code);
|
|
27
|
+
}
|
|
28
|
+
|
|
21
29
|
/** @param {string} str */
|
|
22
30
|
function trim(str) {
|
|
23
31
|
const indentation = /** @type {RegExpExecArray} */ (/\n?(\s*)/.exec(str))[1];
|
|
@@ -157,4 +165,4 @@ function validate(config, cwd, out, user_file) {
|
|
|
157
165
|
}
|
|
158
166
|
}
|
|
159
167
|
|
|
160
|
-
export {
|
|
168
|
+
export { write as a, write_tsconfig as b, trim as t, write_if_changed as w };
|
package/dist/cli.js
CHANGED
|
@@ -904,7 +904,7 @@ async function launch(port, https, base) {
|
|
|
904
904
|
exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}${base}`);
|
|
905
905
|
}
|
|
906
906
|
|
|
907
|
-
const prog = sade('svelte-kit').version('1.0.0-next.
|
|
907
|
+
const prog = sade('svelte-kit').version('1.0.0-next.344');
|
|
908
908
|
|
|
909
909
|
prog
|
|
910
910
|
.command('dev')
|
|
@@ -922,30 +922,34 @@ prog
|
|
|
922
922
|
/** @type {() => Promise<void>} */
|
|
923
923
|
let close;
|
|
924
924
|
|
|
925
|
-
|
|
926
|
-
async function start(config) {
|
|
925
|
+
async function start() {
|
|
927
926
|
const { dev } = await import('./chunks/index.js');
|
|
928
927
|
|
|
929
|
-
const {
|
|
928
|
+
const { server, config } = await dev({
|
|
930
929
|
port,
|
|
931
930
|
host,
|
|
932
|
-
https
|
|
933
|
-
config
|
|
931
|
+
https
|
|
934
932
|
});
|
|
935
933
|
|
|
934
|
+
const address_info = /** @type {import('net').AddressInfo} */ (
|
|
935
|
+
/** @type {import('http').Server} */ (server.httpServer).address()
|
|
936
|
+
);
|
|
937
|
+
|
|
938
|
+
const vite_config = server.config;
|
|
939
|
+
|
|
936
940
|
welcome({
|
|
937
941
|
port: address_info.port,
|
|
938
942
|
host: address_info.address,
|
|
939
|
-
https: !!(https ||
|
|
940
|
-
open: first && (open || !!
|
|
943
|
+
https: !!(https || vite_config.server.https),
|
|
944
|
+
open: first && (open || !!vite_config.server.open),
|
|
941
945
|
base: config.kit.paths.base,
|
|
942
|
-
loose:
|
|
943
|
-
allow:
|
|
946
|
+
loose: vite_config.server.fs.strict === false,
|
|
947
|
+
allow: vite_config.server.fs.allow
|
|
944
948
|
});
|
|
945
949
|
|
|
946
950
|
first = false;
|
|
947
951
|
|
|
948
|
-
return close;
|
|
952
|
+
return server.close;
|
|
949
953
|
}
|
|
950
954
|
|
|
951
955
|
async function relaunch() {
|
|
@@ -953,9 +957,8 @@ prog
|
|
|
953
957
|
relaunching = true;
|
|
954
958
|
|
|
955
959
|
try {
|
|
956
|
-
const updated_config = await load_config();
|
|
957
960
|
await close();
|
|
958
|
-
close = await start(
|
|
961
|
+
close = await start();
|
|
959
962
|
|
|
960
963
|
if (id !== uid) relaunch();
|
|
961
964
|
} catch (e) {
|
|
@@ -975,8 +978,7 @@ prog
|
|
|
975
978
|
|
|
976
979
|
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
|
977
980
|
|
|
978
|
-
|
|
979
|
-
close = await start(config);
|
|
981
|
+
close = await start();
|
|
980
982
|
|
|
981
983
|
chokidar.watch('svelte.config.js', { ignoreInitial: true }).on('change', () => {
|
|
982
984
|
if (relaunching) uid += 1;
|
|
@@ -1039,11 +1041,10 @@ prog
|
|
|
1039
1041
|
await check_port(port);
|
|
1040
1042
|
|
|
1041
1043
|
process.env.NODE_ENV = process.env.NODE_ENV || 'production';
|
|
1042
|
-
const config = await load_config();
|
|
1043
1044
|
|
|
1044
1045
|
const { preview } = await import('./chunks/index5.js');
|
|
1045
1046
|
|
|
1046
|
-
await preview({ port, host,
|
|
1047
|
+
const { config } = await preview({ port, host, https });
|
|
1047
1048
|
|
|
1048
1049
|
welcome({ port, host, https, open, base: config.kit.paths.base });
|
|
1049
1050
|
} catch (error) {
|
|
@@ -1122,7 +1123,7 @@ async function check_port(port) {
|
|
|
1122
1123
|
function welcome({ port, host, https, open, base, loose, allow, cwd }) {
|
|
1123
1124
|
if (open) launch(port, https, base);
|
|
1124
1125
|
|
|
1125
|
-
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.
|
|
1126
|
+
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.344'}\n`));
|
|
1126
1127
|
|
|
1127
1128
|
const protocol = https ? 'https:' : 'http:';
|
|
1128
1129
|
const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
|
|
@@ -1160,4 +1161,4 @@ function welcome({ port, host, https, open, base, loose, allow, cwd }) {
|
|
|
1160
1161
|
console.log('\n');
|
|
1161
1162
|
}
|
|
1162
1163
|
|
|
1163
|
-
export { $, get_mime_lookup as a,
|
|
1164
|
+
export { $, get_mime_lookup as a, load_config as b, coalesce_to_error as c, get_aliases as d, get_runtime_path as g, load_template as l, print_config_conflicts as p, resolve_entry as r };
|
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.344",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sveltejs/kit",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
},
|
|
62
62
|
"types": "types/index.d.ts",
|
|
63
63
|
"engines": {
|
|
64
|
-
"node": ">=16"
|
|
64
|
+
"node": ">=16.7"
|
|
65
65
|
},
|
|
66
66
|
"scripts": {
|
|
67
67
|
"build": "rollup -c && node scripts/cp.js src/runtime/components assets/components && npm run types",
|