@sveltejs/kit 1.5.3 → 1.5.6

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.3",
3
+ "version": "1.5.6",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -179,6 +179,9 @@ function kit({ svelte_config }) {
179
179
  /** @type {() => Promise<void>} */
180
180
  let finalise;
181
181
 
182
+ /** @type {import('vite').UserConfig} */
183
+ let initial_config;
184
+
182
185
  const service_worker_entry_file = resolve_entry(kit.files.serviceWorker);
183
186
 
184
187
  /** @type {import('vite').Plugin} */
@@ -190,6 +193,7 @@ function kit({ svelte_config }) {
190
193
  * @see https://vitejs.dev/guide/api-plugin.html#config
191
194
  */
192
195
  async config(config, config_env) {
196
+ initial_config = config;
193
197
  vite_config_env = config_env;
194
198
  is_build = config_env.command === 'build';
195
199
 
@@ -632,7 +636,15 @@ export function set_assets(path) {
632
636
  // CLI args
633
637
  mode: vite_config_env.mode,
634
638
  logLevel: vite_config.logLevel,
635
- clearScreen: vite_config.clearScreen
639
+ clearScreen: vite_config.clearScreen,
640
+ build: {
641
+ minify: initial_config.build?.minify,
642
+ assetsInlineLimit: vite_config.build.assetsInlineLimit,
643
+ sourcemap: vite_config.build.sourcemap
644
+ },
645
+ optimizeDeps: {
646
+ force: vite_config.optimizeDeps.force
647
+ }
636
648
  })
637
649
  );
638
650
 
@@ -311,7 +311,7 @@ export function create_client({ target }) {
311
311
  );
312
312
  return false;
313
313
  }
314
- } else if (/** @type {number} */ (navigation_result.props?.page?.status) >= 400) {
314
+ } else if (/** @type {number} */ (navigation_result.props.page?.status) >= 400) {
315
315
  const updated = await stores.updated.check();
316
316
  if (updated) {
317
317
  await native_navigation(url);
@@ -331,6 +331,14 @@ export function create_client({ target }) {
331
331
  capture_snapshot(previous_history_index);
332
332
  }
333
333
 
334
+ // ensure the url pathname matches the page's trailing slash option
335
+ if (
336
+ navigation_result.props.page?.url &&
337
+ navigation_result.props.page.url.pathname !== url.pathname
338
+ ) {
339
+ url.pathname = navigation_result.props.page?.url.pathname;
340
+ }
341
+
334
342
  if (opts && opts.details) {
335
343
  const { details } = opts;
336
344
  const change = details.replaceState ? 0 : 1;
@@ -355,6 +363,7 @@ export function create_client({ target }) {
355
363
  if (started) {
356
364
  current = navigation_result.state;
357
365
 
366
+ // reset url before updating page store
358
367
  if (navigation_result.props.page) {
359
368
  navigation_result.props.page.url = url;
360
369
  }
@@ -1256,7 +1265,22 @@ export function create_client({ target }) {
1256
1265
  if (!options.reload) {
1257
1266
  if (priority <= options.preload_data) {
1258
1267
  const intent = get_navigation_intent(/** @type {URL} */ (url), false);
1259
- if (intent) preload_data(intent);
1268
+ if (intent) {
1269
+ if (__SVELTEKIT_DEV__) {
1270
+ preload_data(intent).then((result) => {
1271
+ if (result.type === 'loaded' && result.state.error) {
1272
+ console.warn(
1273
+ `Preloading data for ${intent.url.pathname} failed with the following error: ${result.state.error.message}\n` +
1274
+ 'If this error is transient, you can ignore it. Otherwise, consider disabling preloading for this route. ' +
1275
+ 'This route was preloaded due to a data-sveltekit-preload-data attribute. ' +
1276
+ 'See https://kit.svelte.dev/docs/link-options for more info'
1277
+ );
1278
+ }
1279
+ });
1280
+ } else {
1281
+ preload_data(intent);
1282
+ }
1283
+ }
1260
1284
  } else if (priority <= options.preload_code) {
1261
1285
  preload_code(get_url_path(/** @type {URL} */ (url)));
1262
1286
  }
package/types/index.d.ts CHANGED
@@ -304,6 +304,8 @@ export interface KitConfig {
304
304
  * > When `mode` is `'auto'`, SvelteKit will use nonces for dynamically rendered pages and hashes for prerendered pages. Using nonces with prerendered pages is insecure and therefore forbidden.
305
305
  *
306
306
  * > Note that most [Svelte transitions](https://svelte.dev/tutorial/transition) work by creating an inline `<style>` element. If you use these in your app, you must either leave the `style-src` directive unspecified or add `unsafe-inline`.
307
+ *
308
+ * If this level of configuration is insufficient and you have more dynamic requirements, you can use the [`handle` hook](https://kit.svelte.dev/docs/hooks#server-hooks-handle) to roll your own CSP.
307
309
  */
308
310
  csp?: {
309
311
  /**
@@ -1127,7 +1129,7 @@ export type ActionResult<
1127
1129
  * Creates an `HttpError` object with an HTTP status code and an optional message.
1128
1130
  * This object, if thrown during request handling, will cause SvelteKit to
1129
1131
  * return an error response without invoking `handleError`.
1130
- * Make sure you're not catching the thrown error, which results in a noop.
1132
+ * Make sure you're not catching the thrown error, which would prevent SvelteKit from handling it.
1131
1133
  * @param status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses). Must be in the range 400-599.
1132
1134
  * @param body An object that conforms to the App.Error type. If a string is passed, it will be used as the message property.
1133
1135
  */
@@ -1150,7 +1152,7 @@ export interface HttpError {
1150
1152
 
1151
1153
  /**
1152
1154
  * Create a `Redirect` object. If thrown during request handling, SvelteKit will return a redirect response.
1153
- * Make sure you're not catching the thrown redirect, which results in a noop.
1155
+ * Make sure you're not catching the thrown redirect, which would prevent SvelteKit from handling it.
1154
1156
  * @param status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#redirection_messages). Must be in the range 300-308.
1155
1157
  * @param location The location to redirect to.
1156
1158
  */