@sveltejs/kit 1.0.0-next.335 → 1.0.0-next.338
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/app/env.js +1 -5
- package/assets/client/start.js +53 -4
- package/assets/server/index.js +50 -69
- package/dist/chunks/filesystem.js +1 -1
- package/dist/chunks/index.js +35 -31
- package/dist/chunks/index2.js +11 -14
- package/dist/chunks/index4.js +1 -0
- package/dist/chunks/index6.js +1 -1
- package/dist/chunks/sync.js +8 -2
- package/dist/chunks/write_tsconfig.js +13 -11
- package/dist/cli.js +58 -10
- package/package.json +4 -5
- package/types/ambient.d.ts +1 -5
- package/types/index.d.ts +15 -3
- package/types/internal.d.ts +2 -3
- package/types/private.d.ts +0 -15
- package/dist/chunks/amp_hook.js +0 -56
- package/dist/chunks/index7.js +0 -4207
package/assets/app/env.js
CHANGED
|
@@ -12,9 +12,5 @@ const dev = !!import.meta.env.DEV;
|
|
|
12
12
|
* @type {import('$app/env').mode}
|
|
13
13
|
*/
|
|
14
14
|
const mode = import.meta.env.MODE;
|
|
15
|
-
/**
|
|
16
|
-
* @type {import('$app/env').amp}
|
|
17
|
-
*/
|
|
18
|
-
const amp = !!import.meta.env.VITE_SVELTEKIT_AMP;
|
|
19
15
|
|
|
20
|
-
export {
|
|
16
|
+
export { browser, dev, mode };
|
package/assets/client/start.js
CHANGED
|
@@ -432,6 +432,33 @@ function update_scroll_positions(index) {
|
|
|
432
432
|
scroll_positions[index] = scroll_state();
|
|
433
433
|
}
|
|
434
434
|
|
|
435
|
+
const fetch$1 = window.fetch;
|
|
436
|
+
let loading = 0;
|
|
437
|
+
|
|
438
|
+
if (import.meta.env.DEV) {
|
|
439
|
+
let can_inspect_stack_trace = false;
|
|
440
|
+
|
|
441
|
+
const check_stack_trace = async () => {
|
|
442
|
+
const stack = /** @type {string} */ (new Error().stack);
|
|
443
|
+
can_inspect_stack_trace = stack.includes('check_stack_trace');
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
check_stack_trace();
|
|
447
|
+
|
|
448
|
+
window.fetch = (input, init) => {
|
|
449
|
+
const url = input instanceof Request ? input.url : input.toString();
|
|
450
|
+
const stack = /** @type {string} */ (new Error().stack);
|
|
451
|
+
|
|
452
|
+
const heuristic = can_inspect_stack_trace ? stack.includes('load_node') : loading;
|
|
453
|
+
if (heuristic) {
|
|
454
|
+
console.warn(
|
|
455
|
+
`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`
|
|
456
|
+
);
|
|
457
|
+
}
|
|
458
|
+
return fetch$1(input, init);
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
|
|
435
462
|
/**
|
|
436
463
|
* @param {{
|
|
437
464
|
* target: Element;
|
|
@@ -914,7 +941,18 @@ function create_client({ target, session, base, trailing_slash }) {
|
|
|
914
941
|
props: props || {},
|
|
915
942
|
get url() {
|
|
916
943
|
node.uses.url = true;
|
|
917
|
-
|
|
944
|
+
|
|
945
|
+
return new Proxy(url, {
|
|
946
|
+
get: (target, property) => {
|
|
947
|
+
if (property === 'hash') {
|
|
948
|
+
throw new Error(
|
|
949
|
+
'url.hash is inaccessible from load. Consider accessing hash from the page store within the script tag of your component.'
|
|
950
|
+
);
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
return Reflect.get(target, property, target);
|
|
954
|
+
}
|
|
955
|
+
});
|
|
918
956
|
},
|
|
919
957
|
get session() {
|
|
920
958
|
node.uses.session = true;
|
|
@@ -928,7 +966,7 @@ function create_client({ target, session, base, trailing_slash }) {
|
|
|
928
966
|
const requested = typeof resource === 'string' ? resource : resource.url;
|
|
929
967
|
add_dependency(requested);
|
|
930
968
|
|
|
931
|
-
return started ? fetch(resource, info) : initial_fetch(resource, info);
|
|
969
|
+
return started ? fetch$1(resource, info) : initial_fetch(resource, info);
|
|
932
970
|
},
|
|
933
971
|
status: status ?? null,
|
|
934
972
|
error: error ?? null
|
|
@@ -943,7 +981,18 @@ function create_client({ target, session, base, trailing_slash }) {
|
|
|
943
981
|
});
|
|
944
982
|
}
|
|
945
983
|
|
|
946
|
-
|
|
984
|
+
let loaded;
|
|
985
|
+
|
|
986
|
+
if (import.meta.env.DEV) {
|
|
987
|
+
try {
|
|
988
|
+
loading += 1;
|
|
989
|
+
loaded = await module.load.call(null, load_input);
|
|
990
|
+
} finally {
|
|
991
|
+
loading -= 1;
|
|
992
|
+
}
|
|
993
|
+
} else {
|
|
994
|
+
loaded = await module.load.call(null, load_input);
|
|
995
|
+
}
|
|
947
996
|
|
|
948
997
|
if (!loaded) {
|
|
949
998
|
throw new Error('load function must return a value');
|
|
@@ -1027,7 +1076,7 @@ function create_client({ target, session, base, trailing_slash }) {
|
|
|
1027
1076
|
const is_shadow_page = has_shadow && i === a.length - 1;
|
|
1028
1077
|
|
|
1029
1078
|
if (is_shadow_page) {
|
|
1030
|
-
const res = await fetch(
|
|
1079
|
+
const res = await fetch$1(
|
|
1031
1080
|
`${url.pathname}${url.pathname.endsWith('/') ? '' : '/'}__data.json${url.search}`,
|
|
1032
1081
|
{
|
|
1033
1082
|
headers: {
|
package/assets/server/index.js
CHANGED
|
@@ -1272,95 +1272,76 @@ async function render_response({
|
|
|
1272
1272
|
}
|
|
1273
1273
|
`;
|
|
1274
1274
|
|
|
1275
|
-
if (
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
head += `
|
|
1280
|
-
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style>
|
|
1281
|
-
<noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
|
|
1282
|
-
<script async src="https://cdn.ampproject.org/v0.js"></script>
|
|
1283
|
-
|
|
1284
|
-
<style amp-custom>${styles}</style>`;
|
|
1285
|
-
|
|
1286
|
-
if (options.service_worker) {
|
|
1287
|
-
head +=
|
|
1288
|
-
'<script async custom-element="amp-install-serviceworker" src="https://cdn.ampproject.org/v0/amp-install-serviceworker-0.1.js"></script>';
|
|
1275
|
+
if (inlined_style) {
|
|
1276
|
+
const attributes = [];
|
|
1277
|
+
if (options.dev) attributes.push(' data-sveltekit');
|
|
1278
|
+
if (csp.style_needs_nonce) attributes.push(` nonce="${csp.nonce}"`);
|
|
1289
1279
|
|
|
1290
|
-
|
|
1291
|
-
}
|
|
1292
|
-
} else {
|
|
1293
|
-
if (inlined_style) {
|
|
1294
|
-
const attributes = [];
|
|
1295
|
-
if (options.dev) attributes.push(' data-sveltekit');
|
|
1296
|
-
if (csp.style_needs_nonce) attributes.push(` nonce="${csp.nonce}"`);
|
|
1280
|
+
csp.add_style(inlined_style);
|
|
1297
1281
|
|
|
1298
|
-
|
|
1282
|
+
head += `\n\t<style${attributes.join('')}>${inlined_style}</style>`;
|
|
1283
|
+
}
|
|
1299
1284
|
|
|
1300
|
-
|
|
1301
|
-
|
|
1285
|
+
// prettier-ignore
|
|
1286
|
+
head += Array.from(stylesheets)
|
|
1287
|
+
.map((dep) => {
|
|
1288
|
+
const attributes = [
|
|
1289
|
+
'rel="stylesheet"',
|
|
1290
|
+
`href="${options.prefix + dep}"`
|
|
1291
|
+
];
|
|
1302
1292
|
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
const attributes = [
|
|
1307
|
-
'rel="stylesheet"',
|
|
1308
|
-
`href="${options.prefix + dep}"`
|
|
1309
|
-
];
|
|
1293
|
+
if (csp.style_needs_nonce) {
|
|
1294
|
+
attributes.push(`nonce="${csp.nonce}"`);
|
|
1295
|
+
}
|
|
1310
1296
|
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1297
|
+
if (styles.has(dep)) {
|
|
1298
|
+
// don't load stylesheets that are already inlined
|
|
1299
|
+
// include them in disabled state so that Vite can detect them and doesn't try to add them
|
|
1300
|
+
attributes.push('disabled', 'media="(max-width: 0)"');
|
|
1301
|
+
}
|
|
1314
1302
|
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
attributes.push('disabled', 'media="(max-width: 0)"');
|
|
1319
|
-
}
|
|
1303
|
+
return `\n\t<link ${attributes.join(' ')}>`;
|
|
1304
|
+
})
|
|
1305
|
+
.join('');
|
|
1320
1306
|
|
|
1321
|
-
|
|
1322
|
-
|
|
1307
|
+
if (page_config.router || page_config.hydrate) {
|
|
1308
|
+
head += Array.from(modulepreloads)
|
|
1309
|
+
.map((dep) => `\n\t<link rel="modulepreload" href="${options.prefix + dep}">`)
|
|
1323
1310
|
.join('');
|
|
1324
1311
|
|
|
1325
|
-
|
|
1326
|
-
head += Array.from(modulepreloads)
|
|
1327
|
-
.map((dep) => `\n\t<link rel="modulepreload" href="${options.prefix + dep}">`)
|
|
1328
|
-
.join('');
|
|
1312
|
+
const attributes = ['type="module"', `data-sveltekit-hydrate="${target}"`];
|
|
1329
1313
|
|
|
1330
|
-
|
|
1314
|
+
csp.add_script(init_app);
|
|
1331
1315
|
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
attributes.push(`nonce="${csp.nonce}"`);
|
|
1336
|
-
}
|
|
1316
|
+
if (csp.script_needs_nonce) {
|
|
1317
|
+
attributes.push(`nonce="${csp.nonce}"`);
|
|
1318
|
+
}
|
|
1337
1319
|
|
|
1338
|
-
|
|
1320
|
+
body += `\n\t\t<script ${attributes.join(' ')}>${init_app}</script>`;
|
|
1339
1321
|
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
)
|
|
1322
|
+
body += serialized_data
|
|
1323
|
+
.map(({ url, body, response }) =>
|
|
1324
|
+
render_json_payload_script(
|
|
1325
|
+
{ type: 'data', url, body: typeof body === 'string' ? hash(body) : undefined },
|
|
1326
|
+
response
|
|
1346
1327
|
)
|
|
1347
|
-
|
|
1328
|
+
)
|
|
1329
|
+
.join('\n\t');
|
|
1348
1330
|
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
}
|
|
1331
|
+
if (shadow_props) {
|
|
1332
|
+
body += render_json_payload_script({ type: 'props' }, shadow_props);
|
|
1352
1333
|
}
|
|
1334
|
+
}
|
|
1353
1335
|
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1336
|
+
if (options.service_worker) {
|
|
1337
|
+
// always include service worker unless it's turned off explicitly
|
|
1338
|
+
csp.add_script(init_service_worker);
|
|
1357
1339
|
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
}
|
|
1340
|
+
head += `
|
|
1341
|
+
<script${csp.script_needs_nonce ? ` nonce="${csp.nonce}"` : ''}>${init_service_worker}</script>`;
|
|
1361
1342
|
}
|
|
1362
1343
|
|
|
1363
|
-
if (state.prerender
|
|
1344
|
+
if (state.prerender) {
|
|
1364
1345
|
const http_equiv = [];
|
|
1365
1346
|
|
|
1366
1347
|
const csp_headers = csp.get_meta();
|
package/dist/chunks/index.js
CHANGED
|
@@ -9,12 +9,12 @@ import { S as SVELTE_KIT_ASSETS, s as sirv } from './constants.js';
|
|
|
9
9
|
import { installFetch } from '../install-fetch.js';
|
|
10
10
|
import { update, init } from './sync.js';
|
|
11
11
|
import { getRequest, setResponse } from '../node.js';
|
|
12
|
-
import { sequence } from '../hooks.js';
|
|
13
12
|
import { p as posixify } from './filesystem.js';
|
|
14
13
|
import { p as parse_route_id } from './misc.js';
|
|
15
14
|
import 'sade';
|
|
16
15
|
import 'child_process';
|
|
17
16
|
import 'net';
|
|
17
|
+
import 'chokidar';
|
|
18
18
|
import 'os';
|
|
19
19
|
import 'querystring';
|
|
20
20
|
import 'node:http';
|
|
@@ -38,14 +38,6 @@ const style_pattern = /\.(css|less|sass|scss|styl|stylus|pcss|postcss)$/;
|
|
|
38
38
|
async function create_plugin(config, cwd) {
|
|
39
39
|
const runtime = get_runtime_path(config);
|
|
40
40
|
|
|
41
|
-
/** @type {import('types').Handle} */
|
|
42
|
-
let amp;
|
|
43
|
-
|
|
44
|
-
if (config.kit.amp) {
|
|
45
|
-
process.env.VITE_SVELTEKIT_AMP = 'true';
|
|
46
|
-
amp = (await import('./amp_hook.js')).handle;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
41
|
process.env.VITE_SVELTEKIT_APP_VERSION_POLL_INTERVAL = '0';
|
|
50
42
|
|
|
51
43
|
/** @type {import('types').Respond} */
|
|
@@ -193,6 +185,11 @@ async function create_plugin(config, cwd) {
|
|
|
193
185
|
});
|
|
194
186
|
|
|
195
187
|
return () => {
|
|
188
|
+
const serve_static_middleware = vite.middlewares.stack.find(
|
|
189
|
+
(middleware) =>
|
|
190
|
+
/** @type {function} */ (middleware.handle).name === 'viteServeStaticMiddleware'
|
|
191
|
+
);
|
|
192
|
+
|
|
196
193
|
remove_html_middlewares(vite.middlewares);
|
|
197
194
|
|
|
198
195
|
vite.middlewares.use(async (req, res) => {
|
|
@@ -232,7 +229,7 @@ async function create_plugin(config, cwd) {
|
|
|
232
229
|
/** @type {import('types').Hooks} */
|
|
233
230
|
const hooks = {
|
|
234
231
|
getSession: user_hooks.getSession || (() => ({})),
|
|
235
|
-
handle
|
|
232
|
+
handle,
|
|
236
233
|
handleError:
|
|
237
234
|
user_hooks.handleError ||
|
|
238
235
|
(({ /** @type {Error & { frame?: string }} */ error }) => {
|
|
@@ -294,7 +291,6 @@ async function create_plugin(config, cwd) {
|
|
|
294
291
|
const rendered = await respond(
|
|
295
292
|
request,
|
|
296
293
|
{
|
|
297
|
-
amp: config.kit.amp,
|
|
298
294
|
csp: config.kit.csp,
|
|
299
295
|
dev: true,
|
|
300
296
|
floc: config.kit.floc,
|
|
@@ -358,10 +354,13 @@ async function create_plugin(config, cwd) {
|
|
|
358
354
|
}
|
|
359
355
|
);
|
|
360
356
|
|
|
361
|
-
if (rendered) {
|
|
362
|
-
|
|
357
|
+
if (rendered.status === 404) {
|
|
358
|
+
// @ts-expect-error
|
|
359
|
+
serve_static_middleware.handle(req, res, () => {
|
|
360
|
+
setResponse(res, rendered);
|
|
361
|
+
});
|
|
363
362
|
} else {
|
|
364
|
-
|
|
363
|
+
setResponse(res, rendered);
|
|
365
364
|
}
|
|
366
365
|
} catch (e) {
|
|
367
366
|
const error = coalesce_to_error(e);
|
|
@@ -388,7 +387,8 @@ function remove_html_middlewares(server) {
|
|
|
388
387
|
const html_middlewares = [
|
|
389
388
|
'viteIndexHtmlMiddleware',
|
|
390
389
|
'vite404Middleware',
|
|
391
|
-
'viteSpaFallbackMiddleware'
|
|
390
|
+
'viteSpaFallbackMiddleware',
|
|
391
|
+
'viteServeStaticMiddleware'
|
|
392
392
|
];
|
|
393
393
|
for (let i = server.stack.length - 1; i > 0; i--) {
|
|
394
394
|
// @ts-expect-error using internals until https://github.com/vitejs/vite/pull/4640 is merged
|
|
@@ -403,34 +403,38 @@ function remove_html_middlewares(server) {
|
|
|
403
403
|
* @param {import('vite').ModuleNode} node
|
|
404
404
|
* @param {Set<import('vite').ModuleNode>} deps
|
|
405
405
|
*/
|
|
406
|
-
function find_deps(vite, node, deps) {
|
|
406
|
+
async function find_deps(vite, node, deps) {
|
|
407
407
|
// since `ssrTransformResult.deps` contains URLs instead of `ModuleNode`s, this process is asynchronous.
|
|
408
408
|
// instead of using `await`, we resolve all branches in parallel.
|
|
409
409
|
/** @type {Promise<void>[]} */
|
|
410
410
|
const branches = [];
|
|
411
411
|
|
|
412
412
|
/** @param {import('vite').ModuleNode} node */
|
|
413
|
-
function add(node) {
|
|
413
|
+
async function add(node) {
|
|
414
414
|
if (!deps.has(node)) {
|
|
415
415
|
deps.add(node);
|
|
416
|
-
|
|
416
|
+
await find_deps(vite, node, deps);
|
|
417
417
|
}
|
|
418
418
|
}
|
|
419
419
|
|
|
420
420
|
/** @param {string} url */
|
|
421
421
|
async function add_by_url(url) {
|
|
422
|
-
|
|
422
|
+
const node = await vite.moduleGraph.getModuleByUrl(url);
|
|
423
|
+
|
|
424
|
+
if (node) {
|
|
425
|
+
await add(node);
|
|
426
|
+
}
|
|
423
427
|
}
|
|
424
428
|
|
|
425
429
|
if (node.ssrTransformResult) {
|
|
426
430
|
if (node.ssrTransformResult.deps) {
|
|
427
|
-
node.ssrTransformResult.deps.forEach(add_by_url);
|
|
431
|
+
node.ssrTransformResult.deps.forEach((url) => branches.push(add_by_url(url)));
|
|
428
432
|
}
|
|
429
433
|
} else {
|
|
430
|
-
node.importedModules.forEach(add);
|
|
434
|
+
node.importedModules.forEach((node) => branches.push(add(node)));
|
|
431
435
|
}
|
|
432
436
|
|
|
433
|
-
|
|
437
|
+
await Promise.all(branches);
|
|
434
438
|
}
|
|
435
439
|
|
|
436
440
|
/**
|
|
@@ -464,7 +468,10 @@ async function dev({ cwd, port, host, https, config }) {
|
|
|
464
468
|
]
|
|
465
469
|
},
|
|
466
470
|
port: 3000,
|
|
467
|
-
strictPort: true
|
|
471
|
+
strictPort: true,
|
|
472
|
+
watch: {
|
|
473
|
+
ignored: [`${config.kit.outDir}/**`, `!${config.kit.outDir}/generated/**`]
|
|
474
|
+
}
|
|
468
475
|
}
|
|
469
476
|
},
|
|
470
477
|
await config.kit.vite()
|
|
@@ -486,16 +493,13 @@ async function dev({ cwd, port, host, https, config }) {
|
|
|
486
493
|
},
|
|
487
494
|
plugins: [
|
|
488
495
|
svelte({
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
// don't need to include CSS for components that are imported but unused, so we can just
|
|
492
|
-
// include rendered CSS.
|
|
493
|
-
// This would also apply if hydrate and router are both false, but we don't know if one
|
|
494
|
-
// has been enabled at the page level, so we don't do anything there.
|
|
495
|
-
emitCss: !config.kit.amp,
|
|
496
|
+
...config,
|
|
497
|
+
emitCss: true,
|
|
496
498
|
compilerOptions: {
|
|
499
|
+
...config.compilerOptions,
|
|
497
500
|
hydratable: !!config.kit.browser.hydrate
|
|
498
|
-
}
|
|
501
|
+
},
|
|
502
|
+
configFile: false
|
|
499
503
|
}),
|
|
500
504
|
await create_plugin(config, cwd)
|
|
501
505
|
],
|
package/dist/chunks/index2.js
CHANGED
|
@@ -14,6 +14,7 @@ import './write_tsconfig.js';
|
|
|
14
14
|
import 'sade';
|
|
15
15
|
import 'child_process';
|
|
16
16
|
import 'net';
|
|
17
|
+
import 'chokidar';
|
|
17
18
|
import 'os';
|
|
18
19
|
import 'node:http';
|
|
19
20
|
import 'node:https';
|
|
@@ -237,8 +238,6 @@ async function build_client({
|
|
|
237
238
|
process.env.VITE_SVELTEKIT_APP_VERSION_FILE = `${config.kit.appDir}/version.json`;
|
|
238
239
|
process.env.VITE_SVELTEKIT_APP_VERSION_POLL_INTERVAL = `${config.kit.version.pollInterval}`;
|
|
239
240
|
|
|
240
|
-
process.env.VITE_SVELTEKIT_AMP = config.kit.amp ? 'true' : '';
|
|
241
|
-
|
|
242
241
|
const client_out_dir = `${output_dir}/client/${config.kit.appDir}`;
|
|
243
242
|
|
|
244
243
|
/** @type {Record<string, string>} */
|
|
@@ -284,16 +283,13 @@ async function build_client({
|
|
|
284
283
|
},
|
|
285
284
|
plugins: [
|
|
286
285
|
svelte({
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
// don't need to include CSS for components that are imported but unused, so we can just
|
|
290
|
-
// include rendered CSS.
|
|
291
|
-
// This would also apply if hydrate and router are both false, but we don't know if one
|
|
292
|
-
// has been enabled at the page level, so we don't do anything there.
|
|
293
|
-
emitCss: !config.kit.amp,
|
|
286
|
+
...config,
|
|
287
|
+
emitCss: true,
|
|
294
288
|
compilerOptions: {
|
|
289
|
+
...config.compilerOptions,
|
|
295
290
|
hydratable: !!config.kit.browser.hydrate
|
|
296
|
-
}
|
|
291
|
+
},
|
|
292
|
+
configFile: false
|
|
297
293
|
})
|
|
298
294
|
],
|
|
299
295
|
// prevent Vite copying the contents of `config.kit.files.assets`,
|
|
@@ -369,7 +365,6 @@ export function override(settings) {
|
|
|
369
365
|
export class Server {
|
|
370
366
|
constructor(manifest) {
|
|
371
367
|
this.options = {
|
|
372
|
-
amp: ${config.kit.amp},
|
|
373
368
|
csp: ${s(config.kit.csp)},
|
|
374
369
|
dev: false,
|
|
375
370
|
floc: ${config.kit.floc},
|
|
@@ -549,10 +544,12 @@ async function build_server(
|
|
|
549
544
|
},
|
|
550
545
|
plugins: [
|
|
551
546
|
svelte({
|
|
552
|
-
|
|
547
|
+
...config,
|
|
553
548
|
compilerOptions: {
|
|
549
|
+
...config.compilerOptions,
|
|
554
550
|
hydratable: !!config.kit.browser.hydrate
|
|
555
|
-
}
|
|
551
|
+
},
|
|
552
|
+
configFile: false
|
|
556
553
|
})
|
|
557
554
|
],
|
|
558
555
|
resolve: {
|
|
@@ -576,7 +573,7 @@ async function build_server(
|
|
|
576
573
|
|
|
577
574
|
client.assets.forEach((asset) => {
|
|
578
575
|
if (asset.fileName.endsWith('.css')) {
|
|
579
|
-
if (
|
|
576
|
+
if (asset.source.length < config.kit.inlineStyleThreshold) {
|
|
580
577
|
const index = stylesheet_lookup.size;
|
|
581
578
|
const file = `${output_dir}/server/stylesheets/${index}.js`;
|
|
582
579
|
|
package/dist/chunks/index4.js
CHANGED
package/dist/chunks/index6.js
CHANGED
|
@@ -15549,7 +15549,7 @@ async function build(config, cwd = process.cwd()) {
|
|
|
15549
15549
|
mkdirp(dir);
|
|
15550
15550
|
|
|
15551
15551
|
// Make sure generated tsconfig is up-to-date
|
|
15552
|
-
write_tsconfig(config);
|
|
15552
|
+
write_tsconfig(config, cwd);
|
|
15553
15553
|
|
|
15554
15554
|
const files = scan(config);
|
|
15555
15555
|
|
package/dist/chunks/sync.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import path__default from 'path';
|
|
2
2
|
import fs__default from 'fs';
|
|
3
3
|
import { g as get_runtime_path } from '../cli.js';
|
|
4
|
-
import { p as posixify, c as copy } from './filesystem.js';
|
|
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
7
|
import { w as write_if_changed, t as trim, a as write_tsconfig } from './write_tsconfig.js';
|
|
8
8
|
import 'sade';
|
|
9
9
|
import 'child_process';
|
|
10
10
|
import 'net';
|
|
11
|
+
import 'chokidar';
|
|
11
12
|
import 'os';
|
|
12
13
|
|
|
13
14
|
/**
|
|
@@ -763,6 +764,8 @@ export type Load<
|
|
|
763
764
|
* @param {import('types').ManifestData} manifest_data
|
|
764
765
|
*/
|
|
765
766
|
function write_types(config, manifest_data) {
|
|
767
|
+
rimraf(`${config.kit.outDir}/types`);
|
|
768
|
+
|
|
766
769
|
/** @type {Map<string, { params: string[], type: 'page' | 'endpoint' | 'both' }>} */
|
|
767
770
|
const shadow_types = new Map();
|
|
768
771
|
|
|
@@ -811,8 +814,11 @@ function write_types(config, manifest_data) {
|
|
|
811
814
|
|
|
812
815
|
content.unshift(header(imports.join(', ')));
|
|
813
816
|
|
|
817
|
+
const parts = (key || 'index').split('/');
|
|
818
|
+
parts.push('__types', /** @type {string} */ (parts.pop()));
|
|
819
|
+
|
|
814
820
|
write_if_changed(
|
|
815
|
-
`${config.kit.outDir}/types/${
|
|
821
|
+
`${config.kit.outDir}/types/${parts.join('/')}.d.ts`,
|
|
816
822
|
content.join('\n').trim()
|
|
817
823
|
);
|
|
818
824
|
});
|
|
@@ -29,11 +29,12 @@ function trim(str) {
|
|
|
29
29
|
const exists = (file) => fs__default.existsSync(file) && file;
|
|
30
30
|
|
|
31
31
|
/** @param {import('types').ValidatedConfig} config */
|
|
32
|
-
function write_tsconfig(config) {
|
|
32
|
+
function write_tsconfig(config, cwd = process.cwd()) {
|
|
33
33
|
const out = path__default.join(config.kit.outDir, 'tsconfig.json');
|
|
34
|
-
const user_file =
|
|
34
|
+
const user_file =
|
|
35
|
+
exists(path__default.resolve(cwd, 'tsconfig.json')) || exists(path__default.resolve(cwd, 'jsconfig.json'));
|
|
35
36
|
|
|
36
|
-
if (user_file) validate(config, out, user_file);
|
|
37
|
+
if (user_file) validate(config, cwd, out, user_file);
|
|
37
38
|
|
|
38
39
|
/** @param {string} file */
|
|
39
40
|
const project_relative = (file) => posixify(path__default.relative('.', file));
|
|
@@ -97,17 +98,20 @@ function write_tsconfig(config) {
|
|
|
97
98
|
|
|
98
99
|
/**
|
|
99
100
|
* @param {import('types').ValidatedConfig} config
|
|
101
|
+
* @param {string} cwd
|
|
100
102
|
* @param {string} out
|
|
101
103
|
* @param {string} user_file
|
|
102
104
|
*/
|
|
103
|
-
function validate(config, out, user_file) {
|
|
105
|
+
function validate(config, cwd, out, user_file) {
|
|
104
106
|
// we have to eval the file, since it's not parseable as JSON (contains comments)
|
|
105
107
|
const user_tsconfig_json = fs__default.readFileSync(user_file, 'utf-8');
|
|
106
108
|
const user_tsconfig = (0, eval)(`(${user_tsconfig_json})`);
|
|
107
109
|
|
|
108
110
|
// we need to check that the user's tsconfig extends the framework config
|
|
109
111
|
const extend = user_tsconfig.extends;
|
|
110
|
-
const extends_framework_config = extend && path__default.resolve(
|
|
112
|
+
const extends_framework_config = extend && path__default.resolve(cwd, extend) === out;
|
|
113
|
+
|
|
114
|
+
const kind = path__default.basename(user_file);
|
|
111
115
|
|
|
112
116
|
if (extends_framework_config) {
|
|
113
117
|
const { paths: user_paths } = user_tsconfig.compilerOptions || {};
|
|
@@ -119,16 +123,16 @@ function validate(config, out, user_file) {
|
|
|
119
123
|
const lib_ = user_paths['$lib/*'] || [];
|
|
120
124
|
|
|
121
125
|
const missing_lib_paths =
|
|
122
|
-
!lib.some((relative) => path__default.resolve(
|
|
126
|
+
!lib.some((relative) => path__default.resolve(cwd, relative) === config.kit.files.lib) ||
|
|
123
127
|
!lib_.some(
|
|
124
|
-
(relative) => path__default.resolve(
|
|
128
|
+
(relative) => path__default.resolve(cwd, relative) === path__default.join(config.kit.files.lib, '/*')
|
|
125
129
|
);
|
|
126
130
|
|
|
127
131
|
if (missing_lib_paths) {
|
|
128
132
|
console.warn(
|
|
129
133
|
$
|
|
130
134
|
.bold()
|
|
131
|
-
.yellow(`Your compilerOptions.paths in ${
|
|
135
|
+
.yellow(`Your compilerOptions.paths in ${kind} should include the following:`)
|
|
132
136
|
);
|
|
133
137
|
const relative = posixify(path__default.relative('.', config.kit.files.lib));
|
|
134
138
|
console.warn(`{\n "$lib":["${relative}"],\n "$lib/*":["${relative}/*"]\n}`);
|
|
@@ -139,9 +143,7 @@ function validate(config, out, user_file) {
|
|
|
139
143
|
if (!relative.startsWith('./')) relative = './' + relative;
|
|
140
144
|
|
|
141
145
|
console.warn(
|
|
142
|
-
$
|
|
143
|
-
.bold()
|
|
144
|
-
.yellow(`Your ${user_file} should extend the configuration generated by SvelteKit:`)
|
|
146
|
+
$.bold().yellow(`Your ${kind} should extend the configuration generated by SvelteKit:`)
|
|
145
147
|
);
|
|
146
148
|
console.warn(`{\n "extends": "${relative}"\n}`);
|
|
147
149
|
}
|