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

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 (44) 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 +7 -8
  17. package/src/exports/index.js +0 -10
  18. package/src/exports/public.d.ts +0 -590
  19. package/src/exports/remote/index.js +11 -0
  20. package/src/exports/remote/public.d.ts +519 -0
  21. package/src/exports/vite/build/build_server.js +2 -2
  22. package/src/exports/vite/dev/index.js +28 -31
  23. package/src/exports/vite/index.js +100 -49
  24. package/src/exports/vite/preview/index.js +10 -10
  25. package/src/exports/vite/public.d.ts +588 -0
  26. package/src/exports/vite/utils.js +1 -1
  27. package/src/runtime/app/server/public.d.ts +0 -518
  28. package/src/runtime/app/server/remote/command.js +1 -1
  29. package/src/runtime/app/server/remote/form.js +1 -1
  30. package/src/runtime/app/server/remote/prerender.js +1 -1
  31. package/src/runtime/app/server/remote/query.js +1 -1
  32. package/src/runtime/app/server/remote/requested.js +1 -1
  33. package/src/runtime/client/remote-functions/command.svelte.js +1 -1
  34. package/src/runtime/client/remote-functions/form.svelte.js +1 -1
  35. package/src/runtime/client/remote-functions/prerender.svelte.js +1 -1
  36. package/src/runtime/client/remote-functions/query/index.js +1 -1
  37. package/src/runtime/client/remote-functions/query-batch.svelte.js +1 -1
  38. package/src/runtime/client/remote-functions/query-live/index.js +1 -1
  39. package/src/runtime/client/remote-functions/shared.svelte.js +1 -1
  40. package/src/runtime/server/remote-functions.js +1 -1
  41. package/src/types/internal.d.ts +6 -10
  42. package/src/version.js +1 -1
  43. package/types/index.d.ts +2582 -2559
  44. package/types/index.d.ts.map +64 -60
@@ -59,7 +59,7 @@ export async function dev(
59
59
  /** @type {string} */ (context.event.route.id),
60
60
  context.config,
61
61
  label,
62
- svelte_config.kit.adapter
62
+ svelte_config.adapter
63
63
  );
64
64
  };
65
65
 
@@ -165,29 +165,29 @@ export async function dev(
165
165
  }
166
166
 
167
167
  manifest = {
168
- appDir: svelte_config.kit.appDir,
169
- appPath: svelte_config.kit.appDir,
168
+ appDir: svelte_config.appDir,
169
+ appPath: svelte_config.appDir,
170
170
  assets: new Set(manifest_data.assets.map((asset) => asset.file)),
171
171
  mimeTypes: get_mime_lookup(manifest_data),
172
172
  _: {
173
173
  client: {
174
174
  start: `${get_runtime_base(root)}/client/entry.js`,
175
- app: `${to_fs(svelte_config.kit.outDir)}/generated/client/app.js`,
175
+ app: `${to_fs(svelte_config.outDir)}/generated/client/app.js`,
176
176
  imports: [],
177
177
  stylesheets: [],
178
178
  fonts: [],
179
179
  uses_env_dynamic_public: true,
180
180
  nodes:
181
- svelte_config.kit.router.resolution === 'client'
181
+ svelte_config.router.resolution === 'client'
182
182
  ? undefined
183
183
  : manifest_data.nodes.map((node, i) => {
184
184
  if (node.component || node.universal) {
185
- return `${svelte_config.kit.paths.base}${to_fs(svelte_config.kit.outDir)}/generated/client/nodes/${i}.js`;
185
+ return `${svelte_config.paths.base}${to_fs(svelte_config.outDir)}/generated/client/nodes/${i}.js`;
186
186
  }
187
187
  }),
188
188
  // `css` is not necessary in dev, as the JS file from `nodes` will reference the CSS file
189
189
  routes:
190
- svelte_config.kit.router.resolution === 'client'
190
+ svelte_config.router.resolution === 'client'
191
191
  ? undefined
192
192
  : compact(
193
193
  manifest_data.routes.map((route) => {
@@ -381,7 +381,7 @@ export async function dev(
381
381
  return (error.stack = prelude + lines.join('\n'));
382
382
  }
383
383
 
384
- const params_file = resolve_entry(svelte_config.kit.files.params);
384
+ const params_file = resolve_entry(svelte_config.files.params);
385
385
 
386
386
  /**
387
387
  * @param {string} event
@@ -390,13 +390,13 @@ export async function dev(
390
390
  const watch = (event, cb) => {
391
391
  vite_dev_server.watcher.on(event, (file) => {
392
392
  if (
393
- file.startsWith(svelte_config.kit.files.routes + path.sep) ||
394
- file.startsWith(svelte_config.kit.files.assets + path.sep) ||
393
+ file.startsWith(svelte_config.files.routes + path.sep) ||
394
+ file.startsWith(svelte_config.files.assets + path.sep) ||
395
395
  (params_file && file === params_file) ||
396
396
  is_remote_module(file) ||
397
397
  // in contrast to server hooks, client hooks are written to the client manifest
398
398
  // and therefore need rebuilding when they are added/removed
399
- file.startsWith(svelte_config.kit.files.hooks.client)
399
+ file.startsWith(svelte_config.files.hooks.client)
400
400
  ) {
401
401
  cb(file);
402
402
  }
@@ -430,7 +430,7 @@ export async function dev(
430
430
  if (!sync.update(svelte_config, manifest_data, file, root)) debounce(update_manifest);
431
431
  });
432
432
 
433
- const { appTemplate, errorTemplate, serviceWorker, hooks } = svelte_config.kit.files;
433
+ const { appTemplate, errorTemplate, serviceWorker, hooks } = svelte_config.files;
434
434
 
435
435
  // vite client only executes a full reload if the triggering html file path is index.html
436
436
  // kit defaults to src/app.html, so unless user changed that to index.html
@@ -454,8 +454,8 @@ export async function dev(
454
454
  }
455
455
  });
456
456
 
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, {
457
+ const assets = svelte_config.paths.assets ? SVELTE_KIT_ASSETS : svelte_config.paths.base;
458
+ const asset_server = sirv(svelte_config.files.assets, {
459
459
  dev: true,
460
460
  etag: true,
461
461
  maxAge: 0,
@@ -471,10 +471,10 @@ export async function dev(
471
471
 
472
472
  if (decoded.startsWith(assets)) {
473
473
  const pathname = decoded.slice(assets.length);
474
- const file = svelte_config.kit.files.assets + pathname;
474
+ const file = svelte_config.files.assets + pathname;
475
475
 
476
476
  if (fs.existsSync(file) && !fs.statSync(file).isDirectory()) {
477
- if (has_correct_case(file, svelte_config.kit.files.assets)) {
477
+ if (has_correct_case(file, svelte_config.files.assets)) {
478
478
  req.url = encodeURI(pathname); // don't need query/hash
479
479
  asset_server(req, res);
480
480
  return;
@@ -485,8 +485,8 @@ export async function dev(
485
485
  next();
486
486
  });
487
487
 
488
- const env = vite.loadEnv(vite_config.mode, svelte_config.kit.env.dir, '');
489
- const emulator = await svelte_config.kit.adapter?.emulate?.();
488
+ const env = vite.loadEnv(vite_config.mode, svelte_config.env.dir, '');
489
+ const emulator = await svelte_config.adapter?.emulate?.();
490
490
 
491
491
  /** @type {Promise<void> | undefined} */
492
492
  let init_manifest;
@@ -517,7 +517,7 @@ export async function dev(
517
517
 
518
518
  const decoded = decodeURI(new URL(base + req.url).pathname);
519
519
  const file = posixify(
520
- path.resolve(root, decoded.slice(svelte_config.kit.paths.base.length + 1))
520
+ path.resolve(root, decoded.slice(svelte_config.paths.base.length + 1))
521
521
  );
522
522
  const is_file = fs.existsSync(file) && !fs.statSync(file).isDirectory();
523
523
  const allowed =
@@ -535,18 +535,18 @@ export async function dev(
535
535
  return;
536
536
  }
537
537
 
538
- if (!decoded.startsWith(svelte_config.kit.paths.base)) {
539
- return not_found(req, res, svelte_config.kit.paths.base);
538
+ if (!decoded.startsWith(svelte_config.paths.base)) {
539
+ return not_found(req, res, svelte_config.paths.base);
540
540
  }
541
541
 
542
- if (decoded === svelte_config.kit.paths.base + '/service-worker.js') {
543
- const resolved = resolve_entry(svelte_config.kit.files.serviceWorker);
542
+ if (decoded === svelte_config.paths.base + '/service-worker.js') {
543
+ const resolved = resolve_entry(svelte_config.files.serviceWorker);
544
544
 
545
545
  if (resolved) {
546
546
  res.writeHead(200, {
547
547
  'content-type': 'application/javascript'
548
548
  });
549
- res.end(`import '${svelte_config.kit.paths.base}${to_fs(resolved)}';`);
549
+ res.end(`import '${svelte_config.paths.base}${to_fs(resolved)}';`);
550
550
  } else {
551
551
  res.writeHead(404);
552
552
  res.end('not found');
@@ -558,16 +558,13 @@ export async function dev(
558
558
  // resolve the instrumentation file per request so that changes to it
559
559
  // are picked up on new requests
560
560
  const resolved_instrumentation = resolve_entry(
561
- path.join(svelte_config.kit.files.src, 'instrumentation.server')
561
+ path.join(svelte_config.files.src, 'instrumentation.server')
562
562
  );
563
563
 
564
564
  if (resolved_instrumentation) {
565
- if (
566
- svelte_config.kit.adapter &&
567
- !svelte_config.kit.adapter.supports?.instrumentation?.()
568
- ) {
565
+ if (svelte_config.adapter && !svelte_config.adapter.supports?.instrumentation?.()) {
569
566
  throw new Error(
570
- `${resolved_instrumentation} is unsupported in ${svelte_config.kit.adapter.name}.`
567
+ `${resolved_instrumentation} is unsupported in ${svelte_config.adapter.name}.`
571
568
  );
572
569
  }
573
570
 
@@ -632,7 +629,7 @@ export async function dev(
632
629
  return fs.readFileSync(from_fs(file));
633
630
  }
634
631
 
635
- return fs.readFileSync(path.join(svelte_config.kit.files.assets, file));
632
+ return fs.readFileSync(path.join(svelte_config.files.assets, file));
636
633
  },
637
634
  before_handle: async (event, config, prerender, handle) => {
638
635
  // 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'));
@@ -602,7 +635,7 @@ function kit({ svelte_config }) {
602
635
 
603
636
  const unsupported_plugins = vite_config.plugins.filter((plugin) => plugin.transformIndexHtml);
604
637
  if (unsupported_plugins.length) {
605
- const verbose = vite_config.logLevel === 'info';
638
+ const verbose = vite_config.logLevel === 'info' || vite_config.logLevel === undefined;
606
639
  const log = logger({ verbose });
607
640
 
608
641
  const list = unsupported_plugins
@@ -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
 
@@ -1638,7 +1689,7 @@ function kit({ svelte_config }) {
1638
1689
  fs.rmSync(out, { force: true, recursive: true });
1639
1690
  fs.mkdirSync(out, { recursive: true });
1640
1691
 
1641
- const verbose = builder.config.logLevel === 'info';
1692
+ const verbose = builder.config.logLevel === 'info' || builder.config.logLevel === undefined;
1642
1693
  const log = logger({ verbose });
1643
1694
 
1644
1695
  let ssr_build = await builder.build(builder.environments.ssr);
@@ -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
  })