@sveltejs/kit 2.69.1 → 2.69.3

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": "2.69.1",
3
+ "version": "2.69.3",
4
4
  "description": "SvelteKit is the fastest way to build Svelte apps",
5
5
  "keywords": [
6
6
  "framework",
@@ -636,6 +636,16 @@ export function tweak_types(content, is_server) {
636
636
  const code = new MagicString(content);
637
637
 
638
638
  const exports = new Map();
639
+ /** @param {import('typescript').BindingName} name */
640
+ function add_export(name) {
641
+ if (ts.isIdentifier(name)) {
642
+ if (names.has(name.text)) exports.set(name.text, name.text);
643
+ } else {
644
+ for (const element of name.elements) {
645
+ if (ts.isBindingElement(element)) add_export(element.name);
646
+ }
647
+ }
648
+ }
639
649
 
640
650
  ast.forEachChild((node) => {
641
651
  if (
@@ -662,9 +672,7 @@ export function tweak_types(content, is_server) {
662
672
 
663
673
  if (ts.isVariableStatement(node)) {
664
674
  node.declarationList.declarations.forEach((declaration) => {
665
- if (ts.isIdentifier(declaration.name) && names.has(declaration.name.text)) {
666
- exports.set(declaration.name.text, declaration.name.text);
667
- }
675
+ add_export(declaration.name);
668
676
  });
669
677
  }
670
678
  }
@@ -482,6 +482,23 @@ async function kit({ svelte_config }) {
482
482
  ];
483
483
  }
484
484
 
485
+ // Vite's `define` is a compile-time text replacement, but Vitest strips
486
+ // user `define` from the server config and reinstalls the values only as
487
+ // `globalThis` properties inside test workers, so anything
488
+ // that runs outside of a test will freak out over
489
+ // them not being defined
490
+ if (process.env.VITEST === 'true') {
491
+ for (const key in new_config.define) {
492
+ const value = new_config.define[key];
493
+ try {
494
+ /** @type {Record<string, any>} */ (globalThis)[key] = JSON.parse(value);
495
+ } catch {
496
+ // `kit_global` isn't JSON, so don't try to parse it. We may one day
497
+ // need to define it in Vitest somehow but for now, ignore it
498
+ }
499
+ }
500
+ }
501
+
485
502
  warn_overridden_config(config, new_config);
486
503
 
487
504
  return new_config;
@@ -964,7 +981,7 @@ async function kit({ svelte_config }) {
964
981
 
965
982
  if (is_build) {
966
983
  const ssr = /** @type {boolean} */ (config.build?.ssr);
967
- const prefix = `${kit.appDir}/immutable`;
984
+ const app_immutable = `${kit.appDir}/immutable`;
968
985
 
969
986
  /** @type {Record<string, string>} */
970
987
  const input = {};
@@ -1054,9 +1071,9 @@ async function kit({ svelte_config }) {
1054
1071
 
1055
1072
  /** @type {string} */
1056
1073
  const base = (kit.paths.assets || kit.paths.base) + '/';
1057
- const root_to_assets = prefix + '/assets/';
1074
+ const root_to_assets = app_immutable + '/assets/';
1058
1075
  const assets_to_root =
1059
- prefix
1076
+ app_immutable
1060
1077
  .split('/')
1061
1078
  .map(() => '..')
1062
1079
  .join('/') + '/../';
@@ -1082,9 +1099,11 @@ async function kit({ svelte_config }) {
1082
1099
  output: {
1083
1100
  format: inline ? 'iife' : 'esm',
1084
1101
  name: `__sveltekit_${version_hash}.app`,
1085
- entryFileNames: ssr ? '[name].js' : `${prefix}/[name].[hash].${ext}`,
1086
- chunkFileNames: ssr ? 'chunks/[name].js' : `${prefix}/chunks/[hash].${ext}`,
1087
- assetFileNames: `${prefix}/assets/[name].[hash][extname]`,
1102
+ entryFileNames: ssr ? '[name].js' : `${app_immutable}/[name].[hash].${ext}`,
1103
+ chunkFileNames: ssr
1104
+ ? 'chunks/[name].js'
1105
+ : `${app_immutable}/chunks/[hash].${ext}`,
1106
+ assetFileNames: `${app_immutable}/assets/[name].[hash][extname]`,
1088
1107
  hoistTransitiveImports: false,
1089
1108
  sourcemapIgnoreList,
1090
1109
  inlineDynamicImports: is_rolldown ? undefined : !split
@@ -1112,9 +1131,9 @@ async function kit({ svelte_config }) {
1112
1131
  worker: {
1113
1132
  rollupOptions: {
1114
1133
  output: {
1115
- entryFileNames: `${prefix}/workers/[name]-[hash].js`,
1116
- chunkFileNames: `${prefix}/workers/chunks/[hash].js`,
1117
- assetFileNames: `${prefix}/workers/assets/[name]-[hash][extname]`,
1134
+ entryFileNames: `${app_immutable}/workers/[name]-[hash].js`,
1135
+ chunkFileNames: `${app_immutable}/workers/chunks/[hash].js`,
1136
+ assetFileNames: `${app_immutable}/workers/assets/[name]-[hash][extname]`,
1118
1137
  hoistTransitiveImports: false
1119
1138
  }
1120
1139
  }
@@ -1134,6 +1153,11 @@ async function kit({ svelte_config }) {
1134
1153
  return { relative };
1135
1154
  }
1136
1155
 
1156
+ if (!relative) return;
1157
+
1158
+ // ensure assets loaded by CSS files are loaded relative to the
1159
+ // CSS file rather than the default of relative to the root
1160
+
1137
1161
  // _app/immutable/assets files
1138
1162
  if (filename.startsWith(root_to_assets)) {
1139
1163
  return `./${filename.slice(root_to_assets.length)}`;
@@ -15,10 +15,11 @@ const INVALID_COOKIE_CHARACTER_REGEX = /[\x00-\x1F\x7F()<>@,;:"/[\]?={} \t]/;
15
15
  const cookie_paths = {};
16
16
 
17
17
  /**
18
- * Cookies that are larger than this size (including the name and other
19
- * attributes) are discarded by browsers
18
+ * Cookies whose name and value combined are larger than this size are
19
+ * discarded by browsers. This is the limit codified for the name/value pair
20
+ * in RFC 6265bis: https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis-20#section-5.6-7.5.1
20
21
  */
21
- const MAX_COOKIE_SIZE = 4129;
22
+ const MAX_COOKIE_SIZE = 4096;
22
23
 
23
24
  // TODO 3.0 remove this check
24
25
  /** @param {import('./page/types.js').Cookie['options']} options */
@@ -254,8 +255,11 @@ export function get_cookies(request, url) {
254
255
  new_cookies.set(cookie_key, cookie);
255
256
 
256
257
  if (DEV) {
257
- const serialized = serialize(name, value, cookie.options);
258
- if (text_encoder.encode(serialized).byteLength > MAX_COOKIE_SIZE) {
258
+ // only the name/value pair counts towards MAX_COOKIE_SIZE, not the other attributes
259
+ const encoder = cookie.options.encode || encodeURIComponent;
260
+ const size =
261
+ text_encoder.encode(name).byteLength + text_encoder.encode(encoder(value)).byteLength;
262
+ if (size > MAX_COOKIE_SIZE) {
259
263
  throw new Error(`Cookie "${name}" is too large, and will be discarded by the browser`);
260
264
  }
261
265
 
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 = '2.69.1';
4
+ export const VERSION = '2.69.3';