@sveltejs/kit 1.5.0 → 1.5.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.5.0",
3
+ "version": "1.5.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -89,6 +89,8 @@ async function analyse({ manifest_path, env }) {
89
89
  if (mod.PUT) methods.add('PUT');
90
90
  if (mod.PATCH) methods.add('PATCH');
91
91
  if (mod.DELETE) methods.add('DELETE');
92
+
93
+ config = mod.config;
92
94
  }
93
95
 
94
96
  if (route.page) {
@@ -85,19 +85,29 @@ export function get_tsconfig(kit, include_base_url) {
85
85
  /** @param {string} file */
86
86
  const config_relative = (file) => posixify(path.relative(kit.outDir, file));
87
87
 
88
- const include = ['ambient.d.ts', './types/**/$types.d.ts', config_relative('vite.config.ts')];
89
- for (const dir of [kit.files.routes, kit.files.lib]) {
90
- const relative = project_relative(path.dirname(dir));
91
- include.push(config_relative(`${relative}/**/*.js`));
92
- include.push(config_relative(`${relative}/**/*.ts`));
93
- include.push(config_relative(`${relative}/**/*.svelte`));
88
+ const include = new Set([
89
+ 'ambient.d.ts',
90
+ './types/**/$types.d.ts',
91
+ config_relative('vite.config.ts')
92
+ ]);
93
+ // TODO(v2): find a better way to include all src files. We can't just use routes/lib only because
94
+ // people might have other folders/files in src that they want included.
95
+ const src_includes = [kit.files.routes, kit.files.lib, path.resolve('src')].filter((dir) => {
96
+ const relative = path.relative(path.resolve('src'), dir);
97
+ return !relative || relative.startsWith('..');
98
+ });
99
+ for (const dir of src_includes) {
100
+ include.add(config_relative(`${dir}/**/*.js`));
101
+ include.add(config_relative(`${dir}/**/*.ts`));
102
+ include.add(config_relative(`${dir}/**/*.svelte`));
94
103
  }
104
+
95
105
  // Test folder is a special case - we advocate putting tests in a top-level test folder
96
106
  // and it's not configurable (should we make it?)
97
107
  const test_folder = project_relative('tests');
98
- include.push(config_relative(`${test_folder}/**/*.js`));
99
- include.push(config_relative(`${test_folder}/**/*.ts`));
100
- include.push(config_relative(`${test_folder}/**/*.svelte`));
108
+ include.add(config_relative(`${test_folder}/**/*.js`));
109
+ include.add(config_relative(`${test_folder}/**/*.ts`));
110
+ include.add(config_relative(`${test_folder}/**/*.svelte`));
101
111
 
102
112
  const exclude = [config_relative('node_modules/**'), './[!ambient.d.ts]**'];
103
113
  if (path.extname(kit.files.serviceWorker)) {
@@ -135,7 +145,7 @@ export function get_tsconfig(kit, include_base_url) {
135
145
  // TODO(v2): use the new flag verbatimModuleSyntax instead (requires support by Vite/Esbuild)
136
146
  ignoreDeprecations: ts && Number(ts.version.split('.')[0]) >= 5 ? '5.0' : undefined
137
147
  },
138
- include,
148
+ include: [...include],
139
149
  exclude
140
150
  };
141
151
 
@@ -853,7 +853,7 @@ export function create_client({ target }) {
853
853
  // server_data_node is undefined if it wasn't reloaded from the server;
854
854
  // and if current loader uses server data, we want to reuse previous data.
855
855
  server_data_node === undefined && loader[0] ? { type: 'skip' } : server_data_node ?? null,
856
- previous?.server
856
+ loader[0] ? previous?.server : undefined
857
857
  )
858
858
  });
859
859
  });
package/types/index.d.ts CHANGED
@@ -520,7 +520,23 @@ export interface KitConfig {
520
520
  config?: (config: Record<string, any>) => Record<string, any> | void;
521
521
  };
522
522
  /**
523
- * Client-side navigation can be buggy if you deploy a new version of your app while people are using it. If the code for the new page is already loaded, it may have stale content; if it isn't, the app's route manifest may point to a JavaScript file that no longer exists. SvelteKit solves this problem by falling back to traditional full-page navigation if it detects that a new version has been deployed, using the `name` specified here (which defaults to a timestamp of the build).
523
+ * Client-side navigation can be buggy if you deploy a new version of your app while people are using it. If the code for the new page is already loaded, it may have stale content; if it isn't, the app's route manifest may point to a JavaScript file that no longer exists.
524
+ * SvelteKit helps you solve this problem through version management.
525
+ * If SvelteKit encounters an error while loading the page and detects that a new version has been deployed (using the `name` specified here, which defaults to a timestamp of the build) it will fall back to traditional full-page navigation.
526
+ * Not all navigations will result in an error though, for example if the JavaScript for the next page is already loaded. If you still want to force a full-page navigation in these cases, use techniques such as setting the `pollInverval` and then using `beforeNavigate`:
527
+ * ```html
528
+ * /// +layout.svelte
529
+ * <script>
530
+ * import { beforeNavigate } from '$app/navigation';
531
+ * import { updated } from '$app/stores';
532
+ *
533
+ * beforeNavigate(({ willUnload, to }) => {
534
+ * if ($updated && !willUnload && to?.url) {
535
+ * location.href = to.route.url.href;
536
+ * }
537
+ * });
538
+ * </script>
539
+ * ```
524
540
  *
525
541
  * If you set `pollInterval` to a non-zero value, SvelteKit will poll for new versions in the background and set the value of the [`updated`](/docs/modules#$app-stores-updated) store to `true` when it detects one.
526
542
  */
@@ -1091,6 +1107,13 @@ export type Actions<
1091
1107
 
1092
1108
  /**
1093
1109
  * When calling a form action via fetch, the response will be one of these shapes.
1110
+ * ```svelte
1111
+ * <form method="post" use:enhance={() => {
1112
+ * return ({ result }) => {
1113
+ * // result is of type ActionResult
1114
+ * };
1115
+ * }}
1116
+ * ```
1094
1117
  */
1095
1118
  export type ActionResult<
1096
1119
  Success extends Record<string, unknown> | undefined = Record<string, any>,
@@ -334,6 +334,7 @@ export interface PageNodeIndexes {
334
334
  export type SSREndpoint = Partial<Record<HttpMethod, RequestHandler>> & {
335
335
  prerender?: PrerenderOption;
336
336
  trailingSlash?: TrailingSlash;
337
+ config?: any;
337
338
  };
338
339
 
339
340
  export interface SSRRoute {