@sveltejs/kit 1.0.13 → 1.1.1
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltejs/kit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sveltejs/kit",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"@sveltejs/vite-plugin-svelte": "^2.0.0",
|
|
14
14
|
"@types/cookie": "^0.5.1",
|
|
15
15
|
"cookie": "^0.5.0",
|
|
16
|
-
"devalue": "^4.2.
|
|
16
|
+
"devalue": "^4.2.2",
|
|
17
17
|
"esm-env": "^1.0.0",
|
|
18
18
|
"kleur": "^4.1.5",
|
|
19
19
|
"magic-string": "^0.27.0",
|
|
@@ -60,6 +60,15 @@ export function write_tsconfig(config, cwd = process.cwd()) {
|
|
|
60
60
|
include.push(config_relative(`${test_folder}/**/*.ts`));
|
|
61
61
|
include.push(config_relative(`${test_folder}/**/*.svelte`));
|
|
62
62
|
|
|
63
|
+
const exclude = [config_relative('node_modules/**'), './[!ambient.d.ts]**'];
|
|
64
|
+
if (path.extname(config.files.serviceWorker)) {
|
|
65
|
+
exclude.push(config_relative(config.files.serviceWorker));
|
|
66
|
+
} else {
|
|
67
|
+
exclude.push(config_relative(`${config.files.serviceWorker}.js`));
|
|
68
|
+
exclude.push(config_relative(`${config.files.serviceWorker}.ts`));
|
|
69
|
+
exclude.push(config_relative(`${config.files.serviceWorker}.d.ts`));
|
|
70
|
+
}
|
|
71
|
+
|
|
63
72
|
write_if_changed(
|
|
64
73
|
out,
|
|
65
74
|
JSON.stringify(
|
|
@@ -88,7 +97,7 @@ export function write_tsconfig(config, cwd = process.cwd()) {
|
|
|
88
97
|
target: 'esnext'
|
|
89
98
|
},
|
|
90
99
|
include,
|
|
91
|
-
exclude
|
|
100
|
+
exclude
|
|
92
101
|
},
|
|
93
102
|
null,
|
|
94
103
|
'\t'
|
|
@@ -64,15 +64,69 @@ const enforced_config = {
|
|
|
64
64
|
root: true
|
|
65
65
|
};
|
|
66
66
|
|
|
67
|
+
const options_regex = /(export\s+const\s+(prerender|csr|ssr|trailingSlash))\s*=/s;
|
|
68
|
+
|
|
69
|
+
/** @type {Set<string>} */
|
|
70
|
+
const warned = new Set();
|
|
71
|
+
|
|
72
|
+
/** @type {import('@sveltejs/vite-plugin-svelte').PreprocessorGroup} */
|
|
73
|
+
const warning_preprocessor = {
|
|
74
|
+
script: ({ content, filename }) => {
|
|
75
|
+
if (!filename) return;
|
|
76
|
+
|
|
77
|
+
const basename = path.basename(filename);
|
|
78
|
+
if (basename.startsWith('+page.') || basename.startsWith('+layout.')) {
|
|
79
|
+
const match = content.match(options_regex);
|
|
80
|
+
if (match) {
|
|
81
|
+
const fixed = basename.replace('.svelte', '(.server).js/ts');
|
|
82
|
+
|
|
83
|
+
const message =
|
|
84
|
+
`\n${colors.bold().red(path.relative('.', filename))}\n` +
|
|
85
|
+
`\`${match[1]}\` will be ignored — move it to ${fixed} instead. See https://kit.svelte.dev/docs/page-options for more information.`;
|
|
86
|
+
|
|
87
|
+
if (!warned.has(message)) {
|
|
88
|
+
console.log(message);
|
|
89
|
+
warned.add(message);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
markup: ({ content, filename }) => {
|
|
95
|
+
if (!filename) return;
|
|
96
|
+
|
|
97
|
+
const basename = path.basename(filename);
|
|
98
|
+
if (basename.startsWith('+layout.') && !content.includes('<slot')) {
|
|
99
|
+
const message =
|
|
100
|
+
`\n${colors.bold().red(path.relative('.', filename))}\n` +
|
|
101
|
+
`\`<slot />\` missing — inner content will not be rendered`;
|
|
102
|
+
|
|
103
|
+
if (!warned.has(message)) {
|
|
104
|
+
console.log(message);
|
|
105
|
+
warned.add(message);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
|
|
67
111
|
/** @return {Promise<import('vite').Plugin[]>} */
|
|
68
112
|
export async function sveltekit() {
|
|
69
113
|
const svelte_config = await load_config();
|
|
70
114
|
|
|
115
|
+
/** @type {import('@sveltejs/vite-plugin-svelte').Options['preprocess']} */
|
|
116
|
+
let preprocess = svelte_config.preprocess;
|
|
117
|
+
if (Array.isArray(preprocess)) {
|
|
118
|
+
preprocess = [...preprocess, warning_preprocessor];
|
|
119
|
+
} else if (preprocess) {
|
|
120
|
+
preprocess = [preprocess, warning_preprocessor];
|
|
121
|
+
} else {
|
|
122
|
+
preprocess = warning_preprocessor;
|
|
123
|
+
}
|
|
124
|
+
|
|
71
125
|
/** @type {import('@sveltejs/vite-plugin-svelte').Options} */
|
|
72
126
|
const vite_plugin_svelte_options = {
|
|
73
127
|
configFile: false,
|
|
74
128
|
extensions: svelte_config.extensions,
|
|
75
|
-
preprocess
|
|
129
|
+
preprocess,
|
|
76
130
|
onwarn: svelte_config.onwarn,
|
|
77
131
|
compilerOptions: {
|
|
78
132
|
// @ts-expect-error SvelteKit requires hydratable true by default
|
package/src/runtime/app/forms.js
CHANGED
|
@@ -26,7 +26,11 @@ export function deserialize(result) {
|
|
|
26
26
|
|
|
27
27
|
/** @type {import('$app/forms').enhance} */
|
|
28
28
|
export function enhance(form, submit = () => {}) {
|
|
29
|
-
if (
|
|
29
|
+
if (
|
|
30
|
+
DEV &&
|
|
31
|
+
/** @type {HTMLFormElement} */ (HTMLFormElement.prototype.cloneNode.call(form)).method !==
|
|
32
|
+
'post'
|
|
33
|
+
) {
|
|
30
34
|
throw new Error('use:enhance can only be used on <form> fields with method="POST"');
|
|
31
35
|
}
|
|
32
36
|
|
|
@@ -77,6 +77,11 @@ export async function render_response({
|
|
|
77
77
|
: null;
|
|
78
78
|
|
|
79
79
|
if (page_config.ssr) {
|
|
80
|
+
if (__SVELTEKIT_DEV__ && !branch.at(-1)?.node.component) {
|
|
81
|
+
// Can only be the leaf, layouts have a fallback component generated
|
|
82
|
+
throw new Error(`Missing +page.svelte component for route ${event.route.id}`);
|
|
83
|
+
}
|
|
84
|
+
|
|
80
85
|
/** @type {Record<string, any>} */
|
|
81
86
|
const props = {
|
|
82
87
|
stores: {
|
package/types/ambient.d.ts
CHANGED
|
@@ -2,41 +2,19 @@
|
|
|
2
2
|
* It's possible to tell SvelteKit how to type objects inside your app by declaring the `App` namespace. By default, a new project will have a file called `src/app.d.ts` containing the following:
|
|
3
3
|
*
|
|
4
4
|
* ```ts
|
|
5
|
-
* /// <reference types="@sveltejs/kit" />
|
|
6
|
-
*
|
|
7
|
-
* declare namespace App {
|
|
8
|
-
* interface Error {}
|
|
9
|
-
* interface Locals {}
|
|
10
|
-
* interface PageData {}
|
|
11
|
-
* interface Platform {}
|
|
12
|
-
* }
|
|
13
|
-
* ```
|
|
14
|
-
*
|
|
15
|
-
* By populating these interfaces, you will gain type safety when using `event.locals`, `event.platform`, and `data` from `load` functions.
|
|
16
|
-
*
|
|
17
|
-
* Note that since it's an ambient declaration file, you have to be careful when using `import` statements. Once you add an `import`
|
|
18
|
-
* at the top level, the declaration file is no longer considered ambient and you lose access to these typings in other files.
|
|
19
|
-
* To avoid this, either use the `import(...)` function:
|
|
20
|
-
*
|
|
21
|
-
* ```ts
|
|
22
|
-
* interface Locals {
|
|
23
|
-
* user: import('$lib/types').User;
|
|
24
|
-
* }
|
|
25
|
-
* ```
|
|
26
|
-
* Or wrap the namespace with `declare global`:
|
|
27
|
-
* ```ts
|
|
28
|
-
* import { User } from '$lib/types';
|
|
29
|
-
*
|
|
30
5
|
* declare global {
|
|
31
6
|
* namespace App {
|
|
32
|
-
* interface
|
|
33
|
-
*
|
|
34
|
-
* }
|
|
35
|
-
* //
|
|
7
|
+
* // interface Error {}
|
|
8
|
+
* // interface Locals {}
|
|
9
|
+
* // interface PageData {}
|
|
10
|
+
* // interface Platform {}
|
|
36
11
|
* }
|
|
37
12
|
* }
|
|
13
|
+
*
|
|
14
|
+
* export default undefined;
|
|
38
15
|
* ```
|
|
39
16
|
*
|
|
17
|
+
* By populating these interfaces, you will gain type safety when using `event.locals`, `event.platform`, and `data` from `load` functions.
|
|
40
18
|
*/
|
|
41
19
|
declare namespace App {
|
|
42
20
|
/**
|