@sveltejs/kit 1.8.5 → 1.8.7

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.8.5",
3
+ "version": "1.8.7",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -218,6 +218,21 @@ function kit({ svelte_config }) {
218
218
 
219
219
  const generated = path.posix.join(kit.outDir, 'generated');
220
220
 
221
+ // This ensures that esm-env is inlined into the server output with the
222
+ // export conditions resolved correctly through Vite. This prevents adapters
223
+ // that bundle later on from resolving the export conditions incorrectly
224
+ // and for example include browser-only code in the server output
225
+ // because they for example use esbuild.build with `platform: 'browser'`
226
+ const noExternal = ['esm-env'];
227
+
228
+ // Vitest bypasses Vite when loading external modules, so we bundle
229
+ // when it is detected to keep our virtual modules working.
230
+ // See https://github.com/sveltejs/kit/pull/9172
231
+ // and https://vitest.dev/config/#deps-registernodeloader
232
+ if (process.env.TEST) {
233
+ noExternal.push('@sveltejs/kit');
234
+ }
235
+
221
236
  // dev and preview config can be shared
222
237
  /** @type {import('vite').UserConfig} */
223
238
  const new_config = {
@@ -252,6 +267,9 @@ function kit({ svelte_config }) {
252
267
  '$app',
253
268
  '$env'
254
269
  ]
270
+ },
271
+ ssr: {
272
+ noExternal
255
273
  }
256
274
  };
257
275
 
@@ -267,19 +285,6 @@ function kit({ svelte_config }) {
267
285
  __SVELTEKIT_EMBEDDED__: kit.embedded ? 'true' : 'false'
268
286
  };
269
287
 
270
- new_config.ssr = {
271
- noExternal: [
272
- // TODO document why this is necessary
273
- '@sveltejs/kit',
274
- // This ensures that esm-env is inlined into the server output with the
275
- // export conditions resolved correctly through Vite. This prevents adapters
276
- // that bundle later on to resolve the export conditions incorrectly
277
- // and for example include browser-only code in the server output
278
- // because they for example use esbuild.build with `platform: 'browser'`
279
- 'esm-env'
280
- ]
281
- };
282
-
283
288
  if (!secondary_build_started) {
284
289
  manifest_data = (await sync.all(svelte_config, config_env.mode)).manifest_data;
285
290
  }
@@ -290,13 +295,12 @@ function kit({ svelte_config }) {
290
295
  __SVELTEKIT_EMBEDDED__: kit.embedded ? 'true' : 'false'
291
296
  };
292
297
 
293
- new_config.ssr = {
294
- // Without this, Vite will treat `@sveltejs/kit` as noExternal if it's
295
- // a linked dependency, and that causes modules to be imported twice
296
- // under different IDs, which breaks a bunch of stuff
297
- // https://github.com/vitejs/vite/pull/9296
298
- external: ['@sveltejs/kit', 'cookie', 'set-cookie-parser']
299
- };
298
+ // These Kit dependencies are packaged as CommonJS, which means they must always be externalized.
299
+ // Without this, the tests will still pass but `pnpm dev` will fail in projects that link `@sveltejs/kit`.
300
+ /** @type {NonNullable<import('vite').UserConfig['ssr']>} */ (new_config.ssr).external = [
301
+ 'cookie',
302
+ 'set-cookie-parser'
303
+ ];
300
304
  }
301
305
 
302
306
  warn_overridden_config(config, new_config);
@@ -87,11 +87,11 @@ export function not_found(req, res, base) {
87
87
  if (type === 'text/html') {
88
88
  res.setHeader('Content-Type', 'text/html');
89
89
  res.end(
90
- `The server is configured with a public base URL of /path-base - did you mean to visit <a href="${prefixed}">${prefixed}</a> instead?`
90
+ `The server is configured with a public base URL of ${base} - did you mean to visit <a href="${prefixed}">${prefixed}</a> instead?`
91
91
  );
92
92
  } else {
93
93
  res.end(
94
- `The server is configured with a public base URL of /path-base - did you mean to visit ${prefixed} instead?`
94
+ `The server is configured with a public base URL of ${base} - did you mean to visit ${prefixed} instead?`
95
95
  );
96
96
  }
97
97
  }
package/types/index.d.ts CHANGED
@@ -539,7 +539,7 @@ export interface KitConfig {
539
539
  * Client-side navigation can be buggy if you deploy a new version of your app while people are using it. If the code for the new page is already loaded, it may have stale content; if it isn't, the app's route manifest may point to a JavaScript file that no longer exists.
540
540
  * SvelteKit helps you solve this problem through version management.
541
541
  * If SvelteKit encounters an error while loading the page and detects that a new version has been deployed (using the `name` specified here, which defaults to a timestamp of the build) it will fall back to traditional full-page navigation.
542
- * Not all navigations will result in an error though, for example if the JavaScript for the next page is already loaded. If you still want to force a full-page navigation in these cases, use techniques such as setting the `pollInverval` and then using `beforeNavigate`:
542
+ * Not all navigations will result in an error though, for example if the JavaScript for the next page is already loaded. If you still want to force a full-page navigation in these cases, use techniques such as setting the `pollInterval` and then using `beforeNavigate`:
543
543
  * ```html
544
544
  * /// +layout.svelte
545
545
  * <script>
@@ -558,7 +558,7 @@ export interface KitConfig {
558
558
  */
559
559
  version?: {
560
560
  /**
561
- * The current app version string. If specified, this must be deterministic (e.g. a commit ref rather than `Math.random()` or Date.now().toString()`), otherwise defaults to a timestamp of the build
561
+ * The current app version string. If specified, this must be deterministic (e.g. a commit ref rather than `Math.random()` or `Date.now().toString()`), otherwise defaults to a timestamp of the build
562
562
  */
563
563
  name?: string;
564
564
  /**