@sveltejs/kit 3.0.0-next.20 → 3.0.0-next.21

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.
Files changed (61) hide show
  1. package/package.json +7 -3
  2. package/src/cli.js +2 -2
  3. package/src/core/adapt/builder.js +14 -14
  4. package/src/core/adapt/index.js +16 -2
  5. package/src/core/config/index.js +33 -44
  6. package/src/core/config/options.js +66 -44
  7. package/src/core/env.js +3 -3
  8. package/src/core/postbuild/analyse.js +1 -1
  9. package/src/core/postbuild/prerender.js +48 -20
  10. package/src/core/sync/create_manifest_data/index.js +11 -11
  11. package/src/core/sync/sync.js +8 -8
  12. package/src/core/sync/write_app_types.js +2 -2
  13. package/src/core/sync/write_client_manifest.js +1 -1
  14. package/src/core/sync/write_server.js +14 -14
  15. package/src/core/sync/write_tsconfig/index.js +4 -4
  16. package/src/core/sync/write_types/index.js +10 -9
  17. package/src/exports/hooks/public.d.ts +2 -1
  18. package/src/exports/hooks/sequence.js +1 -1
  19. package/src/exports/index.js +0 -10
  20. package/src/exports/internal/server/event.js +1 -1
  21. package/src/exports/public.d.ts +2 -786
  22. package/src/exports/remote/index.js +11 -0
  23. package/src/exports/remote/public.d.ts +519 -0
  24. package/src/exports/vite/build/build_server.js +2 -2
  25. package/src/exports/vite/dev/index.js +30 -32
  26. package/src/exports/vite/index.js +98 -47
  27. package/src/exports/vite/preview/index.js +10 -10
  28. package/src/exports/vite/public.d.ts +588 -0
  29. package/src/exports/vite/utils.js +1 -1
  30. package/src/runtime/app/server/public.d.ts +168 -486
  31. package/src/runtime/app/server/remote/command.js +1 -1
  32. package/src/runtime/app/server/remote/form.js +1 -1
  33. package/src/runtime/app/server/remote/prerender.js +1 -1
  34. package/src/runtime/app/server/remote/query.js +2 -2
  35. package/src/runtime/app/server/remote/requested.js +1 -1
  36. package/src/runtime/app/server/remote/shared.js +1 -1
  37. package/src/runtime/client/remote-functions/command.svelte.js +1 -1
  38. package/src/runtime/client/remote-functions/form.svelte.js +1 -1
  39. package/src/runtime/client/remote-functions/prerender.svelte.js +1 -1
  40. package/src/runtime/client/remote-functions/query/index.js +1 -1
  41. package/src/runtime/client/remote-functions/query-batch.svelte.js +1 -1
  42. package/src/runtime/client/remote-functions/query-live/index.js +1 -1
  43. package/src/runtime/client/remote-functions/shared.svelte.js +1 -1
  44. package/src/runtime/server/cookie.js +2 -2
  45. package/src/runtime/server/data/index.js +1 -1
  46. package/src/runtime/server/endpoint.js +3 -3
  47. package/src/runtime/server/errors.js +2 -2
  48. package/src/runtime/server/fetch.js +1 -1
  49. package/src/runtime/server/page/actions.js +2 -1
  50. package/src/runtime/server/page/data_serializer.js +2 -2
  51. package/src/runtime/server/page/index.js +2 -1
  52. package/src/runtime/server/page/load_data.js +3 -3
  53. package/src/runtime/server/page/render.js +1 -1
  54. package/src/runtime/server/page/respond_with_error.js +1 -1
  55. package/src/runtime/server/remote-functions.js +3 -2
  56. package/src/runtime/server/respond.js +2 -2
  57. package/src/runtime/server/utils.js +1 -1
  58. package/src/types/internal.d.ts +7 -11
  59. package/src/version.js +1 -1
  60. package/types/index.d.ts +2368 -2341
  61. package/types/index.d.ts.map +67 -61
@@ -1,4 +1,5 @@
1
- /** @import { RequestEvent, SSRManifest } from '@sveltejs/kit' */
1
+ /** @import { SSRManifest } from '@sveltejs/kit' */
2
+ /** @import { RequestEvent } from '$app/server' */
2
3
  /** @import { EnvironmentModuleNode, ErrorPayload, ResolvedConfig, ViteDevServer } from 'vite' */
3
4
  /** @import { ManifestData, PrerenderOption, RemoteChunk, ServerModule, SSRNode, UniversalNode, ValidatedConfig } from 'types' */
4
5
  import process from 'node:process';
@@ -59,7 +60,7 @@ export async function dev(
59
60
  /** @type {string} */ (context.event.route.id),
60
61
  context.config,
61
62
  label,
62
- svelte_config.kit.adapter
63
+ svelte_config.adapter
63
64
  );
64
65
  };
65
66
 
@@ -165,29 +166,29 @@ export async function dev(
165
166
  }
166
167
 
167
168
  manifest = {
168
- appDir: svelte_config.kit.appDir,
169
- appPath: svelte_config.kit.appDir,
169
+ appDir: svelte_config.appDir,
170
+ appPath: svelte_config.appDir,
170
171
  assets: new Set(manifest_data.assets.map((asset) => asset.file)),
171
172
  mimeTypes: get_mime_lookup(manifest_data),
172
173
  _: {
173
174
  client: {
174
175
  start: `${get_runtime_base(root)}/client/entry.js`,
175
- app: `${to_fs(svelte_config.kit.outDir)}/generated/client/app.js`,
176
+ app: `${to_fs(svelte_config.outDir)}/generated/client/app.js`,
176
177
  imports: [],
177
178
  stylesheets: [],
178
179
  fonts: [],
179
180
  uses_env_dynamic_public: true,
180
181
  nodes:
181
- svelte_config.kit.router.resolution === 'client'
182
+ svelte_config.router.resolution === 'client'
182
183
  ? undefined
183
184
  : manifest_data.nodes.map((node, i) => {
184
185
  if (node.component || node.universal) {
185
- return `${svelte_config.kit.paths.base}${to_fs(svelte_config.kit.outDir)}/generated/client/nodes/${i}.js`;
186
+ return `${svelte_config.paths.base}${to_fs(svelte_config.outDir)}/generated/client/nodes/${i}.js`;
186
187
  }
187
188
  }),
188
189
  // `css` is not necessary in dev, as the JS file from `nodes` will reference the CSS file
189
190
  routes:
190
- svelte_config.kit.router.resolution === 'client'
191
+ svelte_config.router.resolution === 'client'
191
192
  ? undefined
192
193
  : compact(
193
194
  manifest_data.routes.map((route) => {
@@ -381,7 +382,7 @@ export async function dev(
381
382
  return (error.stack = prelude + lines.join('\n'));
382
383
  }
383
384
 
384
- const params_file = resolve_entry(svelte_config.kit.files.params);
385
+ const params_file = resolve_entry(svelte_config.files.params);
385
386
 
386
387
  /**
387
388
  * @param {string} event
@@ -390,13 +391,13 @@ export async function dev(
390
391
  const watch = (event, cb) => {
391
392
  vite_dev_server.watcher.on(event, (file) => {
392
393
  if (
393
- file.startsWith(svelte_config.kit.files.routes + path.sep) ||
394
- file.startsWith(svelte_config.kit.files.assets + path.sep) ||
394
+ file.startsWith(svelte_config.files.routes + path.sep) ||
395
+ file.startsWith(svelte_config.files.assets + path.sep) ||
395
396
  (params_file && file === params_file) ||
396
397
  is_remote_module(file) ||
397
398
  // in contrast to server hooks, client hooks are written to the client manifest
398
399
  // and therefore need rebuilding when they are added/removed
399
- file.startsWith(svelte_config.kit.files.hooks.client)
400
+ file.startsWith(svelte_config.files.hooks.client)
400
401
  ) {
401
402
  cb(file);
402
403
  }
@@ -430,7 +431,7 @@ export async function dev(
430
431
  if (!sync.update(svelte_config, manifest_data, file, root)) debounce(update_manifest);
431
432
  });
432
433
 
433
- const { appTemplate, errorTemplate, serviceWorker, hooks } = svelte_config.kit.files;
434
+ const { appTemplate, errorTemplate, serviceWorker, hooks } = svelte_config.files;
434
435
 
435
436
  // vite client only executes a full reload if the triggering html file path is index.html
436
437
  // kit defaults to src/app.html, so unless user changed that to index.html
@@ -454,8 +455,8 @@ export async function dev(
454
455
  }
455
456
  });
456
457
 
457
- const assets = svelte_config.kit.paths.assets ? SVELTE_KIT_ASSETS : svelte_config.kit.paths.base;
458
- const asset_server = sirv(svelte_config.kit.files.assets, {
458
+ const assets = svelte_config.paths.assets ? SVELTE_KIT_ASSETS : svelte_config.paths.base;
459
+ const asset_server = sirv(svelte_config.files.assets, {
459
460
  dev: true,
460
461
  etag: true,
461
462
  maxAge: 0,
@@ -471,10 +472,10 @@ export async function dev(
471
472
 
472
473
  if (decoded.startsWith(assets)) {
473
474
  const pathname = decoded.slice(assets.length);
474
- const file = svelte_config.kit.files.assets + pathname;
475
+ const file = svelte_config.files.assets + pathname;
475
476
 
476
477
  if (fs.existsSync(file) && !fs.statSync(file).isDirectory()) {
477
- if (has_correct_case(file, svelte_config.kit.files.assets)) {
478
+ if (has_correct_case(file, svelte_config.files.assets)) {
478
479
  req.url = encodeURI(pathname); // don't need query/hash
479
480
  asset_server(req, res);
480
481
  return;
@@ -485,8 +486,8 @@ export async function dev(
485
486
  next();
486
487
  });
487
488
 
488
- const env = vite.loadEnv(vite_config.mode, svelte_config.kit.env.dir, '');
489
- const emulator = await svelte_config.kit.adapter?.emulate?.();
489
+ const env = vite.loadEnv(vite_config.mode, svelte_config.env.dir, '');
490
+ const emulator = await svelte_config.adapter?.emulate?.();
490
491
 
491
492
  /** @type {Promise<void> | undefined} */
492
493
  let init_manifest;
@@ -517,7 +518,7 @@ export async function dev(
517
518
 
518
519
  const decoded = decodeURI(new URL(base + req.url).pathname);
519
520
  const file = posixify(
520
- path.resolve(root, decoded.slice(svelte_config.kit.paths.base.length + 1))
521
+ path.resolve(root, decoded.slice(svelte_config.paths.base.length + 1))
521
522
  );
522
523
  const is_file = fs.existsSync(file) && !fs.statSync(file).isDirectory();
523
524
  const allowed =
@@ -535,18 +536,18 @@ export async function dev(
535
536
  return;
536
537
  }
537
538
 
538
- if (!decoded.startsWith(svelte_config.kit.paths.base)) {
539
- return not_found(req, res, svelte_config.kit.paths.base);
539
+ if (!decoded.startsWith(svelte_config.paths.base)) {
540
+ return not_found(req, res, svelte_config.paths.base);
540
541
  }
541
542
 
542
- if (decoded === svelte_config.kit.paths.base + '/service-worker.js') {
543
- const resolved = resolve_entry(svelte_config.kit.files.serviceWorker);
543
+ if (decoded === svelte_config.paths.base + '/service-worker.js') {
544
+ const resolved = resolve_entry(svelte_config.files.serviceWorker);
544
545
 
545
546
  if (resolved) {
546
547
  res.writeHead(200, {
547
548
  'content-type': 'application/javascript'
548
549
  });
549
- res.end(`import '${svelte_config.kit.paths.base}${to_fs(resolved)}';`);
550
+ res.end(`import '${svelte_config.paths.base}${to_fs(resolved)}';`);
550
551
  } else {
551
552
  res.writeHead(404);
552
553
  res.end('not found');
@@ -558,16 +559,13 @@ export async function dev(
558
559
  // resolve the instrumentation file per request so that changes to it
559
560
  // are picked up on new requests
560
561
  const resolved_instrumentation = resolve_entry(
561
- path.join(svelte_config.kit.files.src, 'instrumentation.server')
562
+ path.join(svelte_config.files.src, 'instrumentation.server')
562
563
  );
563
564
 
564
565
  if (resolved_instrumentation) {
565
- if (
566
- svelte_config.kit.adapter &&
567
- !svelte_config.kit.adapter.supports?.instrumentation?.()
568
- ) {
566
+ if (svelte_config.adapter && !svelte_config.adapter.supports?.instrumentation?.()) {
569
567
  throw new Error(
570
- `${resolved_instrumentation} is unsupported in ${svelte_config.kit.adapter.name}.`
568
+ `${resolved_instrumentation} is unsupported in ${svelte_config.adapter.name}.`
571
569
  );
572
570
  }
573
571
 
@@ -632,7 +630,7 @@ export async function dev(
632
630
  return fs.readFileSync(from_fs(file));
633
631
  }
634
632
 
635
- return fs.readFileSync(path.join(svelte_config.kit.files.assets, file));
633
+ return fs.readFileSync(path.join(svelte_config.files.assets, file));
636
634
  },
637
635
  before_handle: async (event, config, prerender, handle) => {
638
636
  // we need to use .run because .enterWith() is not supported in Cloudflare Workers
@@ -1,16 +1,24 @@
1
- /** @import { KitConfig } from '@sveltejs/kit' */
1
+ /** @import { TopLevelFilterExpression } from '@rolldown/pluginutils' */
2
2
  /** @import { EnvVarConfig } from '@sveltejs/kit/env' */
3
- /** @import { Options, SvelteConfig } from '@sveltejs/vite-plugin-svelte' */
3
+ /** @import { Options } from '@sveltejs/vite-plugin-svelte' */
4
4
  /** @import { PreprocessorGroup } from 'svelte/compiler' */
5
- /** @import { Asset, BuildData, ManifestData, Prerendered, RemoteChunk, RemoteInternals, RouteData, ServerMetadata, ValidatedConfig, ValidatedKitConfig } from 'types' */
5
+ /** @import { Asset, BuildData, ManifestData, Prerendered, RemoteChunk, RemoteInternals, RouteData, ServerMetadata, ValidatedConfig } from 'types' */
6
6
  /** @import { Manifest, Plugin, ResolvedConfig, Rolldown, UserConfig, ViteDevServer } from 'vite' */
7
7
  import fs from 'node:fs';
8
8
  import path from 'node:path';
9
9
  import process from 'node:process';
10
10
  import { styleText } from 'node:util';
11
+
12
+ import {
13
+ and,
14
+ code,
15
+ exactRegex,
16
+ importerId,
17
+ include,
18
+ not,
19
+ prefixRegex
20
+ } from '@rolldown/pluginutils';
11
21
  import MagicString from 'magic-string';
12
- import { loadEnv } from 'vite';
13
- import { exactRegex, prefixRegex } from 'rolldown/filter';
14
22
 
15
23
  import { copy, read, resolve_entry } from '../../utils/filesystem.js';
16
24
  import { posixify } from '../../utils/os.js';
@@ -129,6 +137,7 @@ const warned = new Set();
129
137
 
130
138
  /** @type {PreprocessorGroup} */
131
139
  const warning_preprocessor = {
140
+ name: 'sveltekit:warnings',
132
141
  script: ({ content, filename }) => {
133
142
  if (!filename) return;
134
143
 
@@ -172,14 +181,39 @@ const warning_preprocessor = {
172
181
  let vite_plugin_svelte;
173
182
 
174
183
  /**
175
- * Returns the SvelteKit Vite plugins.
176
- * Any options that don't belong to SvelteKit are passed through to `vite-plugin-svelte`.
184
+ * The SvelteKit Vite plugin, which must be added to your `vite.config.js` file along with your project's configuration:
185
+ *
186
+ * ```js
187
+ * /// file: vite.config.js
188
+ * import adapter from '@sveltejs/adapter-auto';
189
+ * import { sveltekit } from '@sveltejs/kit/vite';
190
+ * import { defineConfig } from 'vite';
191
+ *
192
+ * export default defineConfig({
193
+ * plugins: [
194
+ * sveltekit({
195
+ * adapter: adapter(),
196
+ * compilerOptions: {
197
+ * experimental: {
198
+ * async: true
199
+ * }
200
+ * },
201
+ * experimental: {
202
+ * remoteFunctions: true
203
+ * }
204
+ * })
205
+ * ]
206
+ * });
207
+ * ```
177
208
  *
178
- * Since version 3.0.0 you must pass [configuration](configuration) directly.
209
+ * As well as SvelteKit, the plugin options are used by other tooling that integrates with Svelte such as editor extensions.
179
210
  *
180
- * Since version 2.62.0 you can pass configuration directly, in which case `svelte.config.js` is ignored.
211
+ * Any options that don't belong to SvelteKit are passed through to [`vite-plugin-svelte`](https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/config.md), so you can set options like `inspector` here too. The `experimental` namespace is shared — SvelteKit reads its own flags and forwards the rest.
181
212
  *
182
- * @param {KitConfig & Omit<Options, 'onwarn'> & Pick<SvelteConfig, 'vitePlugin'>} [config]
213
+ * > [!LEGACY]
214
+ * > Prior to SvelteKit 3, config lived in a `svelte.config.js` file, which is no longer supported. The ability to configure SvelteKit via `vite.config.js` was added in version 2.62.
215
+ *
216
+ * @param {import('./public.js').Config} [config]
183
217
  * @returns {Promise<Plugin[]>}
184
218
  */
185
219
  export async function sveltekit(config) {
@@ -203,7 +237,6 @@ export async function sveltekit(config) {
203
237
  /** @type {Partial<Options>} */
204
238
  const inline_vps_config = {
205
239
  preprocess: svelte_config.preprocess,
206
- ...(svelte_config.vitePlugin ?? {}),
207
240
  // pass through any options that SvelteKit doesn't use itself, so that
208
241
  // the options SvelteKit manages always take precedence
209
242
  ...split.vite_plugin_svelte_config,
@@ -254,7 +287,7 @@ function kit({ svelte_config }) {
254
287
  */
255
288
  let root;
256
289
 
257
- /** @type {ValidatedKitConfig} */
290
+ /** @type {ValidatedConfig} */
258
291
  let kit;
259
292
  /** @type {string} `kit.outDir` but posix-ified */
260
293
  let out_dir;
@@ -340,7 +373,7 @@ function kit({ svelte_config }) {
340
373
  const resolved = await this.resolve(id, importer, { ...options, skipSelf: true });
341
374
  if (resolved) return resolved;
342
375
 
343
- const aliases = svelte_config.kit.alias;
376
+ const aliases = svelte_config.alias;
344
377
  for (const { name, pattern, message } of removed_modules) {
345
378
  if (!pattern.test(id)) continue;
346
379
 
@@ -365,7 +398,7 @@ function kit({ svelte_config }) {
365
398
  initial_config = config;
366
399
  is_build = config_env.command === 'build';
367
400
 
368
- ({ kit } = process_config(svelte_config, root));
401
+ kit = process_config(svelte_config, root);
369
402
  out_dir = posixify(kit.outDir);
370
403
  out = `${out_dir}/output`;
371
404
 
@@ -375,10 +408,10 @@ function kit({ svelte_config }) {
375
408
  ? `globalThis.__sveltekit_${version_hash}`
376
409
  : 'globalThis.__sveltekit_dev';
377
410
 
378
- env = loadEnv(config_env.mode, kit.env.dir, '');
379
-
380
411
  vite = await import_peer('vite', root);
381
412
 
413
+ env = vite.loadEnv(config_env.mode, kit.env.dir, '');
414
+
382
415
  normalized_cwd = vite.normalizePath(root);
383
416
  normalized_aliases = get_import_aliases(root, vite.normalizePath.bind(vite));
384
417
  normalized_node_modules = vite.normalizePath(path.resolve(root, 'node_modules'));
@@ -668,7 +701,7 @@ function kit({ svelte_config }) {
668
701
 
669
702
  resolveId: {
670
703
  filter: {
671
- id: [prefixRegex('__sveltekit/')]
704
+ id: prefixRegex('__sveltekit/')
672
705
  },
673
706
  handler(id) {
674
707
  if (id === '__sveltekit/manifest') {
@@ -761,13 +794,16 @@ function kit({ svelte_config }) {
761
794
  },
762
795
 
763
796
  resolveId: {
764
- // TODO: use composable filter API here when supported:
765
- // https://github.com/vitejs/rolldown-vite/issues/605
766
- // filter: ([
767
- // exclude(importerId(/index\.html$/)),
768
- // include(importerId(/.+/))
769
- // ]),
797
+ // composable filters are not accepted type-wise but still work during build
798
+ // see https://github.com/vitejs/rolldown-vite/issues/605
799
+ filter: /** @type {any} */ (
800
+ /** @satisfies {TopLevelFilterExpression[]} */ ([
801
+ include(and(importerId(/.+/), not(importerId(/index\.html$/))))
802
+ ])
803
+ ),
770
804
  async handler(id, importer, options) {
805
+ // composable filters only work during build so we still need this guard for dev
806
+ // see https://github.com/vitejs/rolldown-vite/issues/605
771
807
  if (importer && !importer.endsWith('index.html')) {
772
808
  const resolved = await this.resolve(id, importer, { ...options, skipSelf: true });
773
809
 
@@ -912,7 +948,7 @@ function kit({ svelte_config }) {
912
948
  name: 'vite-plugin-sveltekit-remote',
913
949
 
914
950
  applyToEnvironment(environment) {
915
- return svelte_config.kit.experimental.remoteFunctions && environment.name !== 'serviceWorker';
951
+ return svelte_config.experimental.remoteFunctions && environment.name !== 'serviceWorker';
916
952
  },
917
953
 
918
954
  // prevent other plugins from resolving our remote virtual module
@@ -1070,13 +1106,13 @@ function kit({ svelte_config }) {
1070
1106
  name: 'vite-plugin-sveltekit-remote-guard',
1071
1107
 
1072
1108
  applyToEnvironment() {
1073
- return !svelte_config.kit.experimental.remoteFunctions;
1109
+ return !svelte_config.experimental.remoteFunctions;
1074
1110
  },
1075
1111
 
1076
1112
  transform: {
1077
1113
  filter: {
1078
1114
  id: new RegExp(
1079
- `.remote(${svelte_config.kit.moduleExtensions.join('|')})$`.replaceAll('.', '\\.')
1115
+ `.remote(${svelte_config.moduleExtensions.join('|')})$`.replaceAll('.', '\\.')
1080
1116
  )
1081
1117
  },
1082
1118
  handler() {
@@ -1162,7 +1198,7 @@ function kit({ svelte_config }) {
1162
1198
 
1163
1199
  resolveId: {
1164
1200
  filter: {
1165
- id: [prefixRegex('__sveltekit/')]
1201
+ id: prefixRegex('__sveltekit/')
1166
1202
  },
1167
1203
  handler(id) {
1168
1204
  return `\0virtual:${id}`;
@@ -1269,13 +1305,19 @@ function kit({ svelte_config }) {
1269
1305
  /** @type {Plugin} */
1270
1306
  const plugin_service_worker_env = {
1271
1307
  name: 'vite-plugin-sveltekit-service-worker-env',
1308
+ configResolved() {
1309
+ if (service_worker_entry_file) {
1310
+ // @ts-expect-error transform is defined in this object
1311
+ plugin_service_worker_env.transform.filter = {
1312
+ id: exactRegex(service_worker_entry_file)
1313
+ };
1314
+ }
1315
+ },
1272
1316
  applyToEnvironment(environment) {
1273
1317
  return !!service_worker_entry_file && environment.config.consumer === 'client';
1274
1318
  },
1275
1319
  transform: {
1276
- handler(code, id) {
1277
- if (id !== service_worker_entry_file) return;
1278
-
1320
+ handler(code) {
1279
1321
  // prepend the service worker with an import that configures
1280
1322
  // `env`, in case `$app/env/public` is imported. In production
1281
1323
  // this is required: dynamic public env vars aren't known at
@@ -1374,7 +1416,7 @@ function kit({ svelte_config }) {
1374
1416
  /** @type {Record<string, string>} */
1375
1417
  const client_input = {};
1376
1418
 
1377
- if (svelte_config.kit.output.bundleStrategy !== 'split') {
1419
+ if (svelte_config.output.bundleStrategy !== 'split') {
1378
1420
  client_input['bundle'] = `${runtime_directory}/client/bundle.js`;
1379
1421
  } else {
1380
1422
  client_input['entry/start'] = `${runtime_directory}/client/entry.js`;
@@ -1387,7 +1429,7 @@ function kit({ svelte_config }) {
1387
1429
  });
1388
1430
  }
1389
1431
 
1390
- const inline = svelte_config.kit.output.bundleStrategy === 'inline';
1432
+ const inline = svelte_config.output.bundleStrategy === 'inline';
1391
1433
 
1392
1434
  /** @type {string} */
1393
1435
  const base = (kit.paths.assets || kit.paths.base) + '/';
@@ -1486,7 +1528,7 @@ function kit({ svelte_config }) {
1486
1528
  return `${app_immutable}/chunks/[hash].js`;
1487
1529
  },
1488
1530
  codeSplitting:
1489
- svelte_config.kit.output.bundleStrategy === 'split'
1531
+ svelte_config.output.bundleStrategy === 'split'
1490
1532
  ? {
1491
1533
  groups: [
1492
1534
  {
@@ -1511,7 +1553,7 @@ function kit({ svelte_config }) {
1511
1553
  },
1512
1554
  define: {
1513
1555
  __SVELTEKIT_PAYLOAD__:
1514
- svelte_config.kit.output.bundleStrategy !== 'split' ? kit_global : 'undefined'
1556
+ svelte_config.output.bundleStrategy !== 'split' ? kit_global : 'undefined'
1515
1557
  }
1516
1558
  }
1517
1559
  },
@@ -1601,17 +1643,26 @@ function kit({ svelte_config }) {
1601
1643
  return environment.name !== 'serviceWorker';
1602
1644
  },
1603
1645
 
1604
- renderChunk(code, chunk) {
1605
- if (code.includes('__SVELTEKIT_TRACK__')) {
1606
- return {
1607
- // Rolldown changes our single quotes to double quotes so we need it in the regex too
1608
- code: code.replace(/__SVELTEKIT_TRACK__\(['"](.+?)['"]\)/g, (_, label) => {
1609
- (tracked_features[chunk.name + '.js'] ??= []).push(label);
1610
- // put extra whitespace at the end of the comment to preserve the source size and avoid interfering with source maps
1611
- return `/* track ${label} */`;
1612
- }),
1613
- map: null // TODO we may need to generate a sourcemap in future
1614
- };
1646
+ renderChunk: {
1647
+ // composable filters are not accepted type-wise but still work during build
1648
+ // see https://github.com/vitejs/rolldown-vite/issues/605
1649
+ filter: /** @type {any} */ (
1650
+ /** @satisfies {TopLevelFilterExpression[]} */ ([include(code('__SVELTEKIT_TRACK__'))])
1651
+ ),
1652
+ handler(code, chunk) {
1653
+ // composable filters only work during build so we still need this guard for dev
1654
+ // see https://github.com/vitejs/rolldown-vite/issues/605
1655
+ if (code.includes('__SVELTEKIT_TRACK__')) {
1656
+ return {
1657
+ // Rolldown changes our single quotes to double quotes so we need it in the regex too
1658
+ code: code.replace(/__SVELTEKIT_TRACK__\(['"](.+?)['"]\)/g, (_, label) => {
1659
+ (tracked_features[chunk.name + '.js'] ??= []).push(label);
1660
+ // put extra whitespace at the end of the comment to preserve the source size and avoid interfering with source maps
1661
+ return `/* track ${label} */`;
1662
+ }),
1663
+ map: null // TODO we may need to generate a sourcemap in future
1664
+ };
1665
+ }
1615
1666
  }
1616
1667
  },
1617
1668
 
@@ -2188,7 +2239,7 @@ function kit({ svelte_config }) {
2188
2239
 
2189
2240
  return /** @type {Plugin[]} */ (
2190
2241
  [
2191
- svelte_config.kit.adapter?.vite?.plugins?.pre,
2242
+ svelte_config.adapter?.vite?.plugins?.pre,
2192
2243
  plugin_resolve_root,
2193
2244
  plugin_setup,
2194
2245
  plugin_remote_guard,
@@ -2199,7 +2250,7 @@ function kit({ svelte_config }) {
2199
2250
  plugin_service_worker_env,
2200
2251
  plugin_compile,
2201
2252
  plugin_adapter,
2202
- svelte_config.kit.adapter?.vite?.plugins?.post
2253
+ svelte_config.adapter?.vite?.plugins?.post
2203
2254
  ].filter(Boolean)
2204
2255
  );
2205
2256
  }
@@ -18,7 +18,7 @@ import { stackless } from '../../../utils/error.js';
18
18
  * @param {ValidatedConfig} svelte_config
19
19
  */
20
20
  export async function preview(vite, vite_config, svelte_config) {
21
- const { paths } = svelte_config.kit;
21
+ const { paths } = svelte_config;
22
22
  const base = paths.base;
23
23
  const assets = paths.assets ? SVELTE_KIT_ASSETS : paths.base;
24
24
 
@@ -26,7 +26,7 @@ export async function preview(vite, vite_config, svelte_config) {
26
26
 
27
27
  const etag = `"${Date.now()}"`;
28
28
 
29
- const dir = join(svelte_config.kit.outDir, 'output/server');
29
+ const dir = join(svelte_config.outDir, 'output/server');
30
30
 
31
31
  if (!fs.existsSync(`${dir}/manifest.js`)) {
32
32
  throw stackless(`Server files not found at ${dir}, did you run \`build\` first?`);
@@ -51,7 +51,7 @@ export async function preview(vite, vite_config, svelte_config) {
51
51
 
52
52
  try {
53
53
  await server.init({
54
- env: loadEnv(vite_config.mode, svelte_config.kit.env.dir, ''),
54
+ env: loadEnv(vite_config.mode, svelte_config.env.dir, ''),
55
55
  read: (file) => createReadableStream(`${dir}/${file}`)
56
56
  });
57
57
  } catch (error) {
@@ -62,7 +62,7 @@ export async function preview(vite, vite_config, svelte_config) {
62
62
  throw error;
63
63
  }
64
64
 
65
- const emulator = await svelte_config.kit.adapter?.emulate?.();
65
+ const emulator = await svelte_config.adapter?.emulate?.();
66
66
 
67
67
  return () => {
68
68
  // Remove the base middleware. It screws with the URL.
@@ -81,10 +81,10 @@ export async function preview(vite, vite_config, svelte_config) {
81
81
  vite.middlewares.use(
82
82
  scoped(
83
83
  assets,
84
- sirv(join(svelte_config.kit.outDir, 'output/client'), {
84
+ sirv(join(svelte_config.outDir, 'output/client'), {
85
85
  setHeaders: (res, pathname) => {
86
86
  // only apply to immutable directory, not e.g. version.json
87
- if (pathname.startsWith(`/${svelte_config.kit.appDir}/immutable`)) {
87
+ if (pathname.startsWith(`/${svelte_config.appDir}/immutable`)) {
88
88
  res.setHeader('cache-control', 'public,max-age=31536000,immutable');
89
89
  }
90
90
  }
@@ -122,7 +122,7 @@ export async function preview(vite, vite_config, svelte_config) {
122
122
 
123
123
  // prerendered dependencies
124
124
  vite.middlewares.use(
125
- scoped(base, mutable(join(svelte_config.kit.outDir, 'output/prerendered/dependencies')))
125
+ scoped(base, mutable(join(svelte_config.outDir, 'output/prerendered/dependencies')))
126
126
  );
127
127
 
128
128
  // prerendered pages (we can't just use sirv because we need to
@@ -143,10 +143,10 @@ export async function preview(vite, vite_config, svelte_config) {
143
143
 
144
144
  const { pathname, search } = new URL(/** @type {string} */ (req.url), 'http://dummy');
145
145
 
146
- const dir = pathname.startsWith(`/${svelte_config.kit.appDir}/remote/`) ? 'data' : 'pages';
146
+ const dir = pathname.startsWith(`/${svelte_config.appDir}/remote/`) ? 'data' : 'pages';
147
147
 
148
148
  let filename = normalizePath(
149
- join(svelte_config.kit.outDir, `output/prerendered/${dir}` + pathname)
149
+ join(svelte_config.outDir, `output/prerendered/${dir}` + pathname)
150
150
  );
151
151
 
152
152
  try {
@@ -222,7 +222,7 @@ export async function preview(vite, vite_config, svelte_config) {
222
222
  return fs.readFileSync(join(dir, file));
223
223
  }
224
224
 
225
- return fs.readFileSync(join(svelte_config.kit.files.assets, file));
225
+ return fs.readFileSync(join(svelte_config.files.assets, file));
226
226
  },
227
227
  emulator
228
228
  })