@sveltejs/kit 1.25.1 → 1.25.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.25.1",
3
+ "version": "1.25.2",
4
4
  "description": "The fastest way to build Svelte apps",
5
5
  "repository": {
6
6
  "type": "git",
@@ -38,8 +38,8 @@
38
38
  "svelte": "^4.0.5",
39
39
  "svelte-preprocess": "^5.0.4",
40
40
  "typescript": "^4.9.4",
41
- "vite": "^4.4.2",
42
- "vitest": "^0.34.0"
41
+ "vite": "^4.4.9",
42
+ "vitest": "^0.34.5"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "svelte": "^3.54.0 || ^4.0.0-next.0",
@@ -181,7 +181,10 @@ export function create_builder({
181
181
  },
182
182
 
183
183
  writeClient(dest) {
184
- return copy(`${config.kit.outDir}/output/client`, dest);
184
+ return copy(`${config.kit.outDir}/output/client`, dest, {
185
+ // avoid making vite build artefacts public
186
+ filter: (basename) => basename !== '.vite'
187
+ });
185
188
  },
186
189
 
187
190
  writePrerendered(dest) {
@@ -1,7 +1,11 @@
1
1
  import path from 'node:path';
2
2
  import { posixify } from '../../../utils/filesystem.js';
3
+ import { strip_virtual_prefix } from '../utils.js';
3
4
 
4
- const ILLEGAL_IMPORTS = new Set(['\0$env/dynamic/private', '\0$env/static/private']);
5
+ const ILLEGAL_IMPORTS = new Set([
6
+ '\0virtual:$env/dynamic/private',
7
+ '\0virtual:$env/static/private'
8
+ ]);
5
9
  const ILLEGAL_MODULE_NAME_PATTERN = /.*\.server\..+/;
6
10
 
7
11
  /**
@@ -51,10 +55,14 @@ export function module_guard(context, { cwd, lib }) {
51
55
  chain.map(({ id, dynamic }, i) => {
52
56
  id = normalize_id(id, lib, cwd);
53
57
 
54
- return `${' '.repeat(i * 2)}- ${id} ${dynamic ? 'dynamically imports' : 'imports'}\n`;
55
- }) + `${' '.repeat(chain.length)}- ${id}`;
58
+ return `${' '.repeat(i * 2)}- ${strip_virtual_prefix(id)} ${
59
+ dynamic ? 'dynamically imports' : 'imports'
60
+ }\n`;
61
+ }) + `${' '.repeat(chain.length)}- ${strip_virtual_prefix(id)}`;
56
62
 
57
- const message = `Cannot import ${id} into client-side code:\n${pyramid}`;
63
+ const message = `Cannot import ${strip_virtual_prefix(
64
+ id
65
+ )} into client-side code:\n${pyramid}`;
58
66
 
59
67
  throw new Error(message);
60
68
  }
@@ -18,7 +18,7 @@ import { assets_base, find_deps } from './build/utils.js';
18
18
  import { dev } from './dev/index.js';
19
19
  import { is_illegal, module_guard, normalize_id } from './graph_analysis/index.js';
20
20
  import { preview } from './preview/index.js';
21
- import { get_config_aliases, get_env } from './utils.js';
21
+ import { get_config_aliases, get_env, strip_virtual_prefix } from './utils.js';
22
22
  import { write_client_manifest } from '../../core/sync/write_client_manifest.js';
23
23
  import prerender from '../../core/postbuild/prerender.js';
24
24
  import analyse from '../../core/postbuild/analyse.js';
@@ -336,7 +336,7 @@ function kit({ svelte_config }) {
336
336
  async resolveId(id) {
337
337
  // treat $env/static/[public|private] as virtual
338
338
  if (id.startsWith('$env/') || id.startsWith('__sveltekit/') || id === '$service-worker') {
339
- return `\0${id}`;
339
+ return `\0virtual:${id}`;
340
340
  }
341
341
  },
342
342
 
@@ -358,24 +358,24 @@ function kit({ svelte_config }) {
358
358
  })
359
359
  ) {
360
360
  const relative = normalize_id(id, normalized_lib, normalized_cwd);
361
- throw new Error(`Cannot import ${relative} into client-side code`);
361
+ throw new Error(`Cannot import ${strip_virtual_prefix(relative)} into client-side code`);
362
362
  }
363
363
  }
364
364
 
365
365
  switch (id) {
366
- case '\0$env/static/private':
366
+ case '\0virtual:$env/static/private':
367
367
  return create_static_module('$env/static/private', env.private);
368
368
 
369
- case '\0$env/static/public':
369
+ case '\0virtual:$env/static/public':
370
370
  return create_static_module('$env/static/public', env.public);
371
371
 
372
- case '\0$env/dynamic/private':
372
+ case '\0virtual:$env/dynamic/private':
373
373
  return create_dynamic_module(
374
374
  'private',
375
375
  vite_config_env.command === 'serve' ? env.private : undefined
376
376
  );
377
377
 
378
- case '\0$env/dynamic/public':
378
+ case '\0virtual:$env/dynamic/public':
379
379
  // populate `$env/dynamic/public` from `window`
380
380
  if (browser) {
381
381
  return `export const env = ${global}.env;`;
@@ -386,12 +386,12 @@ function kit({ svelte_config }) {
386
386
  vite_config_env.command === 'serve' ? env.public : undefined
387
387
  );
388
388
 
389
- case '\0$service-worker':
389
+ case '\0virtual:$service-worker':
390
390
  return create_service_worker_module(svelte_config);
391
391
 
392
392
  // for internal use only. it's published as $app/paths externally
393
393
  // we use this alias so that we won't collide with user aliases
394
- case '\0__sveltekit/paths': {
394
+ case '\0virtual:__sveltekit/paths': {
395
395
  const { assets, base } = svelte_config.kit.paths;
396
396
 
397
397
  // use the values defined in `global`, but fall back to hard-coded values
@@ -429,7 +429,7 @@ function kit({ svelte_config }) {
429
429
  `;
430
430
  }
431
431
 
432
- case '\0__sveltekit/environment': {
432
+ case '\0virtual:__sveltekit/environment': {
433
433
  const { version } = svelte_config.kit;
434
434
 
435
435
  return dedent`
@@ -555,7 +555,7 @@ function kit({ svelte_config }) {
555
555
  cssCodeSplit: true,
556
556
  cssMinify: initial_config.build?.minify == null ? true : !!initial_config.build.minify,
557
557
  // don't use the default name to avoid collisions with 'static/manifest.json'
558
- manifest: 'vite-manifest.json',
558
+ manifest: '.vite/manifest.json', // TODO: remove this after bumping peer dep to vite 5
559
559
  outDir: `${out}/${ssr ? 'server' : 'client'}`,
560
560
  rollupOptions: {
561
561
  input,
@@ -805,10 +805,6 @@ function kit({ svelte_config }) {
805
805
  .cyan('npm run preview')} to preview your production build locally.`
806
806
  );
807
807
 
808
- // avoid making the manifest available to users
809
- fs.unlinkSync(`${out}/client/${vite_config.build.manifest}`);
810
- fs.unlinkSync(`${out}/server/${vite_config.build.manifest}`);
811
-
812
808
  if (kit.adapter) {
813
809
  const { adapt } = await import('../../core/adapt/index.js');
814
810
  await adapt(svelte_config, build_data, metadata, prerendered, prerender_map, log);
@@ -97,3 +97,5 @@ export function not_found(req, res, base) {
97
97
  );
98
98
  }
99
99
  }
100
+
101
+ export const strip_virtual_prefix = /** @param {string} id */ (id) => id.replace('\0virtual:', '');
@@ -1662,16 +1662,19 @@ export function create_client(app, target) {
1662
1662
  });
1663
1663
 
1664
1664
  addEventListener('popstate', async (event) => {
1665
+ token = {};
1665
1666
  if (event.state?.[INDEX_KEY]) {
1666
1667
  // if a popstate-driven navigation is cancelled, we need to counteract it
1667
1668
  // with history.go, which means we end up back here, hence this check
1668
1669
  if (event.state[INDEX_KEY] === current_history_index) return;
1669
1670
 
1670
1671
  const scroll = scroll_positions[event.state[INDEX_KEY]];
1672
+ const url = new URL(location.href);
1671
1673
 
1672
1674
  // if the only change is the hash, we don't need to do anything...
1673
1675
  if (current.url.href.split('#')[0] === location.href.split('#')[0]) {
1674
- // ...except handle scroll
1676
+ // ...except update our internal URL tracking and handle scroll
1677
+ update_url(url);
1675
1678
  scroll_positions[current_history_index] = scroll_state();
1676
1679
  current_history_index = event.state[INDEX_KEY];
1677
1680
  scrollTo(scroll.x, scroll.y);
@@ -1681,7 +1684,7 @@ export function create_client(app, target) {
1681
1684
  const delta = event.state[INDEX_KEY] - current_history_index;
1682
1685
 
1683
1686
  await navigate({
1684
- url: new URL(location.href),
1687
+ url,
1685
1688
  scroll,
1686
1689
  keepfocus: false,
1687
1690
  redirect_chain: [],
@@ -1693,7 +1696,8 @@ export function create_client(app, target) {
1693
1696
  history.go(-delta);
1694
1697
  },
1695
1698
  type: 'popstate',
1696
- delta
1699
+ delta,
1700
+ nav_token: token
1697
1701
  });
1698
1702
  } else {
1699
1703
  // since popstate event is also emitted when an anchor referencing the same
package/src/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  // generated during release, do not modify
2
2
 
3
3
  /** @type {string} */
4
- export const VERSION = '1.25.1';
4
+ export const VERSION = '1.25.2';