@sveltejs/kit 1.0.10 → 1.0.11

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.0.10",
3
+ "version": "1.0.11",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -105,7 +105,7 @@ function parent_element(element) {
105
105
  */
106
106
  export function find_anchor(element, target) {
107
107
  while (element && element !== target) {
108
- if (element.nodeName.toUpperCase() === 'A') {
108
+ if (element.nodeName.toUpperCase() === 'A' && element.hasAttribute('href')) {
109
109
  return /** @type {HTMLAnchorElement | SVGAElement} */ (element);
110
110
  }
111
111
 
@@ -33,6 +33,12 @@ export async function load_server_data({ event, options, state, node, parent })
33
33
 
34
34
  const result = await node.server.load?.call(null, {
35
35
  ...event,
36
+ fetch: (info, init) => {
37
+ const url = new URL(info instanceof Request ? info.url : info, event.url);
38
+ uses.dependencies.add(url.href);
39
+
40
+ return event.fetch(info, init);
41
+ },
36
42
  /** @param {string[]} deps */
37
43
  depends: (...deps) => {
38
44
  for (const dep of deps) {
@@ -6,6 +6,7 @@ import { s } from '../../../utils/misc.js';
6
6
  import { Csp } from './csp.js';
7
7
  import { uneval_action_response } from './actions.js';
8
8
  import { clarify_devalue_error } from '../utils.js';
9
+ import { DEV } from 'esm-env';
9
10
 
10
11
  // TODO rename this function/module
11
12
 
@@ -353,17 +354,34 @@ export async function render_response({
353
354
  // add the content after the script/css links so the link elements are parsed first
354
355
  head += rendered.head;
355
356
 
357
+ const html = options.app_template({
358
+ head,
359
+ body,
360
+ assets,
361
+ nonce: /** @type {string} */ (csp.nonce)
362
+ });
363
+
356
364
  // TODO flush chunks as early as we can
357
- const html =
365
+ const transformed =
358
366
  (await resolve_opts.transformPageChunk({
359
- html: options.app_template({ head, body, assets, nonce: /** @type {string} */ (csp.nonce) }),
367
+ html,
360
368
  done: true
361
369
  })) || '';
362
370
 
371
+ if (DEV && page_config.csr) {
372
+ if (transformed.split('<!--').length < html.split('<!--').length) {
373
+ // the \u001B stuff is ANSI codes, so that we don't need to add a library to the runtime
374
+ // https://svelte.dev/repl/1b3f49696f0c44c881c34587f2537aa2
375
+ console.warn(
376
+ "\u001B[1m\u001B[31mRemoving comments in transformPageChunk can break Svelte's hydration\u001B[39m\u001B[22m"
377
+ );
378
+ }
379
+ }
380
+
363
381
  const headers = new Headers({
364
382
  'x-sveltekit-page': 'true',
365
383
  'content-type': 'text/html',
366
- etag: `"${hash(html)}"`
384
+ etag: `"${hash(transformed)}"`
367
385
  });
368
386
 
369
387
  if (!state.prerendering) {
@@ -381,7 +399,7 @@ export async function render_response({
381
399
  }
382
400
  }
383
401
 
384
- return new Response(html, {
402
+ return new Response(transformed, {
385
403
  status,
386
404
  headers
387
405
  });