@sveltejs/kit 1.9.0 → 1.9.2

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.9.0",
3
+ "version": "1.9.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -334,7 +334,7 @@ function kit({ svelte_config }) {
334
334
 
335
335
  async load(id, options) {
336
336
  const browser = !options?.ssr;
337
- const global = `__sveltekit_${version_hash}`;
337
+ const global = `globalThis.__sveltekit_${version_hash}`;
338
338
 
339
339
  if (options?.ssr === false && process.env.TEST !== 'true') {
340
340
  const normalized_cwd = vite.normalizePath(cwd);
@@ -33,6 +33,7 @@ import * as devalue from 'devalue';
33
33
  import { INDEX_KEY, PRELOAD_PRIORITIES, SCROLL_KEY, SNAPSHOT_KEY } from './constants.js';
34
34
  import { validate_common_exports } from '../../utils/exports.js';
35
35
  import { compact } from '../../utils/array.js';
36
+ import { validate_depends } from '../shared.js';
36
37
 
37
38
  // We track the scroll position associated with each history entry in sessionStorage,
38
39
  // rather than on history.state itself, because when navigation is driven by
@@ -586,6 +587,8 @@ export function create_client(app, target) {
586
587
  /** @param {string[]} deps */
587
588
  function depends(...deps) {
588
589
  for (const dep of deps) {
590
+ if (DEV) validate_depends(/** @type {string} */ (route.id), dep);
591
+
589
592
  const { href } = new URL(dep, url);
590
593
  uses.dependencies.add(href);
591
594
  }
@@ -1,6 +1,7 @@
1
1
  import { disable_search, make_trackable } from '../../../utils/url.js';
2
2
  import { unwrap_promises } from '../../../utils/promises.js';
3
3
  import { DEV } from 'esm-env';
4
+ import { validate_depends } from '../../shared.js';
4
5
 
5
6
  /**
6
7
  * Calls the user's server `load` function.
@@ -59,10 +60,14 @@ export async function load_server_data({ event, state, node, parent }) {
59
60
  for (const dep of deps) {
60
61
  const { href } = new URL(dep, event.url);
61
62
 
62
- if (DEV && done && !uses.dependencies.has(href)) {
63
- console.warn(
64
- `${node.server_id}: Calling \`depends(...)\` in a promise handler after \`load(...)\` has returned will not cause the function to re-run when the dependency is invalidated`
65
- );
63
+ if (DEV) {
64
+ validate_depends(node.server_id, dep);
65
+
66
+ if (done && !uses.dependencies.has(href)) {
67
+ console.warn(
68
+ `${node.server_id}: Calling \`depends(...)\` in a promise handler after \`load(...)\` has returned will not cause the function to re-run when the dependency is invalidated`
69
+ );
70
+ }
66
71
  }
67
72
 
68
73
  uses.dependencies.add(href);
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @param {string} route_id
3
+ * @param {string} dep
4
+ */
5
+ export function validate_depends(route_id, dep) {
6
+ const match = /^(moz-icon|view-source|jar):/.exec(dep);
7
+ if (match) {
8
+ console.warn(
9
+ `${route_id}: Calling \`depends('${dep}')\` will throw an error in Firefox because \`${match[1]}\` is a special URI scheme`
10
+ );
11
+ }
12
+ }