@sveltejs/kit 2.54.0 → 2.56.0

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 (45) hide show
  1. package/package.json +3 -4
  2. package/src/core/postbuild/analyse.js +3 -3
  3. package/src/core/postbuild/prerender.js +9 -6
  4. package/src/core/sync/write_non_ambient.js +143 -37
  5. package/src/core/sync/write_tsconfig.js +3 -1
  6. package/src/core/sync/write_types/index.js +1 -5
  7. package/src/exports/internal/remote-functions.js +2 -2
  8. package/src/exports/public.d.ts +38 -12
  9. package/src/exports/vite/build/build_server.js +24 -4
  10. package/src/exports/vite/build/build_service_worker.js +16 -6
  11. package/src/exports/vite/build/utils.js +18 -3
  12. package/src/exports/vite/index.js +336 -327
  13. package/src/runtime/app/paths/server.js +1 -1
  14. package/src/runtime/app/server/index.js +1 -1
  15. package/src/runtime/app/server/remote/command.js +12 -7
  16. package/src/runtime/app/server/remote/form.js +14 -14
  17. package/src/runtime/app/server/remote/index.js +1 -0
  18. package/src/runtime/app/server/remote/prerender.js +8 -7
  19. package/src/runtime/app/server/remote/query.js +141 -66
  20. package/src/runtime/app/server/remote/requested.js +172 -0
  21. package/src/runtime/app/server/remote/shared.js +32 -10
  22. package/src/runtime/app/state/server.js +1 -1
  23. package/src/runtime/client/client.js +45 -20
  24. package/src/runtime/client/remote-functions/command.svelte.js +39 -16
  25. package/src/runtime/client/remote-functions/form.svelte.js +41 -24
  26. package/src/runtime/client/remote-functions/prerender.svelte.js +105 -76
  27. package/src/runtime/client/remote-functions/query.svelte.js +408 -138
  28. package/src/runtime/client/remote-functions/shared.svelte.js +95 -94
  29. package/src/runtime/components/svelte-5/error.svelte +2 -0
  30. package/src/runtime/form-utils.js +3 -7
  31. package/src/runtime/server/endpoint.js +0 -1
  32. package/src/runtime/server/page/actions.js +2 -1
  33. package/src/runtime/server/page/load_data.js +3 -1
  34. package/src/runtime/server/page/render.js +38 -15
  35. package/src/runtime/server/remote.js +65 -50
  36. package/src/runtime/server/respond.js +17 -3
  37. package/src/runtime/server/utils.js +0 -12
  38. package/src/runtime/shared.js +233 -5
  39. package/src/types/global-private.d.ts +4 -4
  40. package/src/types/internal.d.ts +80 -44
  41. package/src/utils/css.js +0 -3
  42. package/src/utils/escape.js +15 -3
  43. package/src/version.js +1 -1
  44. package/types/index.d.ts +67 -13
  45. package/types/index.d.ts.map +6 -1
@@ -241,190 +241,192 @@ async function kit({ svelte_config }) {
241
241
  * Build the SvelteKit-provided Vite config to be merged with the user's vite.config.js file.
242
242
  * @see https://vitejs.dev/guide/api-plugin.html#config
243
243
  */
244
- config(config, config_env) {
245
- initial_config = config;
246
- vite_config_env = config_env;
247
- is_build = config_env.command === 'build';
248
-
249
- env = get_env(kit.env, vite_config_env.mode);
250
-
251
- const allow = new Set([
252
- kit.files.lib,
253
- kit.files.routes,
254
- kit.outDir,
255
- path.resolve('src'), // TODO this isn't correct if user changed all his files to sth else than src (like in test/options)
256
- path.resolve('node_modules'),
257
- path.resolve(vite.searchForWorkspaceRoot(cwd), 'node_modules')
258
- ]);
259
-
260
- // We can only add directories to the allow list, so we find out
261
- // if there's a client hooks file and pass its directory
262
- const client_hooks = resolve_entry(kit.files.hooks.client);
263
- if (client_hooks) allow.add(path.dirname(client_hooks));
264
-
265
- const generated = path.posix.join(kit.outDir, 'generated');
266
-
267
- // dev and preview config can be shared
268
- /** @type {import('vite').UserConfig} */
269
- const new_config = {
270
- resolve: {
271
- alias: [
272
- { find: '__SERVER__', replacement: `${generated}/server` },
273
- { find: '$app', replacement: `${runtime_directory}/app` },
274
- ...get_config_aliases(kit)
275
- ]
276
- },
277
- root: cwd,
278
- server: {
279
- cors: { preflightContinue: true },
280
- fs: {
281
- allow: [...allow]
244
+ config: {
245
+ order: 'pre',
246
+ handler(config, config_env) {
247
+ initial_config = config;
248
+ vite_config_env = config_env;
249
+ is_build = config_env.command === 'build';
250
+
251
+ env = get_env(kit.env, vite_config_env.mode);
252
+
253
+ const allow = new Set([
254
+ kit.files.lib,
255
+ kit.files.routes,
256
+ kit.outDir,
257
+ path.resolve('src'), // TODO this isn't correct if user changed all his files to sth else than src (like in test/options)
258
+ path.resolve('node_modules'),
259
+ path.resolve(vite.searchForWorkspaceRoot(cwd), 'node_modules')
260
+ ]);
261
+
262
+ // We can only add directories to the allow list, so we find out
263
+ // if there's a client hooks file and pass its directory
264
+ const client_hooks = resolve_entry(kit.files.hooks.client);
265
+ if (client_hooks) allow.add(path.dirname(client_hooks));
266
+
267
+ const generated = path.posix.join(kit.outDir, 'generated');
268
+
269
+ // dev and preview config can be shared
270
+ /** @type {import('vite').UserConfig} */
271
+ const new_config = {
272
+ resolve: {
273
+ alias: [
274
+ { find: '__SERVER__', replacement: `${generated}/server` },
275
+ { find: '$app', replacement: `${runtime_directory}/app` },
276
+ ...get_config_aliases(kit)
277
+ ]
278
+ },
279
+ root: cwd,
280
+ server: {
281
+ cors: { preflightContinue: true },
282
+ fs: {
283
+ allow: [...allow]
284
+ },
285
+ sourcemapIgnoreList,
286
+ watch: {
287
+ ignored: [
288
+ // Ignore all siblings of config.kit.outDir/generated
289
+ `${posixify(kit.outDir)}/!(generated)`
290
+ ]
291
+ }
292
+ },
293
+ preview: {
294
+ cors: { preflightContinue: true }
295
+ },
296
+ optimizeDeps: {
297
+ entries: [
298
+ `${kit.files.routes}/**/+*.{svelte,js,ts}`,
299
+ `!${kit.files.routes}/**/+*server.*`
300
+ ],
301
+ exclude: [
302
+ // Without this SvelteKit will be prebundled on the client, which means we end up with two versions of Redirect etc.
303
+ // Also see https://github.com/sveltejs/kit/issues/5952#issuecomment-1218844057
304
+ '@sveltejs/kit',
305
+ // exclude kit features so that libraries using them work even when they are prebundled
306
+ // this does not affect app code, just handling of imported libraries that use $app or $env
307
+ '$app',
308
+ '$env'
309
+ ]
282
310
  },
283
- sourcemapIgnoreList,
284
- watch: {
285
- ignored: [
286
- // Ignore all siblings of config.kit.outDir/generated
287
- `${posixify(kit.outDir)}/!(generated)`
311
+ ssr: {
312
+ noExternal: [
313
+ // This ensures that esm-env is inlined into the server output with the
314
+ // export conditions resolved correctly through Vite. This prevents adapters
315
+ // that bundle later on from resolving the export conditions incorrectly
316
+ // and for example include browser-only code in the server output
317
+ // because they for example use esbuild.build with `platform: 'browser'`
318
+ 'esm-env',
319
+ // This forces `$app/*` modules to be bundled, since they depend on
320
+ // virtual modules like `__sveltekit/environment` (this isn't a valid bare
321
+ // import, but it works with vite-node's externalization logic, which
322
+ // uses basic concatenation)
323
+ '@sveltejs/kit/src/runtime'
288
324
  ]
289
325
  }
290
- },
291
- preview: {
292
- cors: { preflightContinue: true }
293
- },
294
- optimizeDeps: {
295
- entries: [
296
- `${kit.files.routes}/**/+*.{svelte,js,ts}`,
297
- `!${kit.files.routes}/**/+*server.*`
298
- ],
299
- exclude: [
300
- // Without this SvelteKit will be prebundled on the client, which means we end up with two versions of Redirect etc.
301
- // Also see https://github.com/sveltejs/kit/issues/5952#issuecomment-1218844057
302
- '@sveltejs/kit',
303
- // exclude kit features so that libraries using them work even when they are prebundled
304
- // this does not affect app code, just handling of imported libraries that use $app or $env
305
- '$app',
306
- '$env'
307
- ]
308
- },
309
- ssr: {
310
- noExternal: [
311
- // This ensures that esm-env is inlined into the server output with the
312
- // export conditions resolved correctly through Vite. This prevents adapters
313
- // that bundle later on from resolving the export conditions incorrectly
314
- // and for example include browser-only code in the server output
315
- // because they for example use esbuild.build with `platform: 'browser'`
316
- 'esm-env',
317
- // This forces `$app/*` modules to be bundled, since they depend on
318
- // virtual modules like `__sveltekit/environment` (this isn't a valid bare
319
- // import, but it works with vite-node's externalization logic, which
320
- // uses basic concatenation)
321
- '@sveltejs/kit/src/runtime'
322
- ]
323
- }
324
- };
326
+ };
325
327
 
326
- if (kit.experimental.remoteFunctions) {
327
- // treat .remote.js files as empty for the purposes of prebundling
328
- // detects rolldown to avoid a warning message in vite 8 beta
329
- const remote_id_filter = new RegExp(
330
- `.remote(${kit.moduleExtensions.join('|')})$`.replaceAll('.', '\\.')
331
- );
332
- new_config.optimizeDeps ??= {}; // for some reason ts says this could be undefined even though it was set above
333
- if (is_rolldown) {
334
- // @ts-ignore
335
- new_config.optimizeDeps.rolldownOptions ??= {};
336
- // @ts-ignore
337
- new_config.optimizeDeps.rolldownOptions.plugins ??= [];
338
- // @ts-ignore
339
- new_config.optimizeDeps.rolldownOptions.plugins.push({
340
- name: 'vite-plugin-sveltekit-setup:optimize-remote-functions',
341
- load: {
342
- filter: { id: remote_id_filter },
343
- handler() {
344
- return '';
328
+ if (kit.experimental.remoteFunctions) {
329
+ // treat .remote.js files as empty for the purposes of prebundling
330
+ // detects rolldown to avoid a warning message in vite 8 beta
331
+ const remote_id_filter = new RegExp(
332
+ `.remote(${kit.moduleExtensions.join('|')})$`.replaceAll('.', '\\.')
333
+ );
334
+ new_config.optimizeDeps ??= {}; // for some reason ts says this could be undefined even though it was set above
335
+ if (is_rolldown) {
336
+ // @ts-ignore
337
+ new_config.optimizeDeps.rolldownOptions ??= {};
338
+ // @ts-ignore
339
+ new_config.optimizeDeps.rolldownOptions.plugins ??= [];
340
+ // @ts-ignore
341
+ new_config.optimizeDeps.rolldownOptions.plugins.push({
342
+ name: 'vite-plugin-sveltekit-setup:optimize-remote-functions',
343
+ load: {
344
+ filter: { id: remote_id_filter },
345
+ handler() {
346
+ return '';
347
+ }
345
348
  }
346
- }
347
- });
348
- } else {
349
- new_config.optimizeDeps.esbuildOptions ??= {};
350
- new_config.optimizeDeps.esbuildOptions.plugins ??= [];
351
- new_config.optimizeDeps.esbuildOptions.plugins.push({
352
- name: 'vite-plugin-sveltekit-setup:optimize-remote-functions',
353
- setup(build) {
354
- build.onLoad({ filter: remote_id_filter }, () => ({ contents: '' }));
355
- }
356
- });
349
+ });
350
+ } else {
351
+ new_config.optimizeDeps.esbuildOptions ??= {};
352
+ new_config.optimizeDeps.esbuildOptions.plugins ??= [];
353
+ new_config.optimizeDeps.esbuildOptions.plugins.push({
354
+ name: 'vite-plugin-sveltekit-setup:optimize-remote-functions',
355
+ setup(build) {
356
+ build.onLoad({ filter: remote_id_filter }, () => ({ contents: '' }));
357
+ }
358
+ });
359
+ }
357
360
  }
358
- }
359
361
 
360
- const define = {
361
- __SVELTEKIT_APP_DIR__: s(kit.appDir),
362
- __SVELTEKIT_EMBEDDED__: s(kit.embedded),
363
- __SVELTEKIT_EXPERIMENTAL__REMOTE_FUNCTIONS__: s(kit.experimental.remoteFunctions),
364
- __SVELTEKIT_FORK_PRELOADS__: s(kit.experimental.forkPreloads),
365
- __SVELTEKIT_PATHS_ASSETS__: s(kit.paths.assets),
366
- __SVELTEKIT_PATHS_BASE__: s(kit.paths.base),
367
- __SVELTEKIT_PATHS_RELATIVE__: s(kit.paths.relative),
368
- __SVELTEKIT_CLIENT_ROUTING__: s(kit.router.resolution === 'client'),
369
- __SVELTEKIT_HASH_ROUTING__: s(kit.router.type === 'hash'),
370
- __SVELTEKIT_SERVER_TRACING_ENABLED__: s(kit.experimental.tracing.server),
371
- __SVELTEKIT_EXPERIMENTAL_USE_TRANSFORM_ERROR__: s(kit.experimental.handleRenderingErrors)
372
- };
373
-
374
- if (is_build) {
375
- if (!new_config.build) new_config.build = {};
376
- new_config.build.ssr = !secondary_build_started;
377
-
378
- new_config.define = {
379
- ...define,
380
- __SVELTEKIT_ADAPTER_NAME__: s(kit.adapter?.name),
381
- __SVELTEKIT_APP_VERSION_FILE__: s(`${kit.appDir}/version.json`),
382
- __SVELTEKIT_APP_VERSION_POLL_INTERVAL__: s(kit.version.pollInterval),
383
- __SVELTEKIT_PAYLOAD__: new_config.build.ssr
384
- ? '{}'
385
- : `globalThis.__sveltekit_${version_hash}`
362
+ const define = {
363
+ __SVELTEKIT_APP_DIR__: s(kit.appDir),
364
+ __SVELTEKIT_EMBEDDED__: s(kit.embedded),
365
+ __SVELTEKIT_FORK_PRELOADS__: s(kit.experimental.forkPreloads),
366
+ __SVELTEKIT_PATHS_ASSETS__: s(kit.paths.assets),
367
+ __SVELTEKIT_PATHS_BASE__: s(kit.paths.base),
368
+ __SVELTEKIT_PATHS_RELATIVE__: s(kit.paths.relative),
369
+ __SVELTEKIT_CLIENT_ROUTING__: s(kit.router.resolution === 'client'),
370
+ __SVELTEKIT_HASH_ROUTING__: s(kit.router.type === 'hash'),
371
+ __SVELTEKIT_SERVER_TRACING_ENABLED__: s(kit.experimental.tracing.server),
372
+ __SVELTEKIT_EXPERIMENTAL_USE_TRANSFORM_ERROR__: s(kit.experimental.handleRenderingErrors)
386
373
  };
387
374
 
388
- if (!secondary_build_started) {
389
- manifest_data = sync.all(svelte_config, config_env.mode).manifest_data;
390
- // During the initial server build we don't know yet
391
- new_config.define.__SVELTEKIT_HAS_SERVER_LOAD__ = 'true';
392
- new_config.define.__SVELTEKIT_HAS_UNIVERSAL_LOAD__ = 'true';
375
+ if (is_build) {
376
+ if (!new_config.build) new_config.build = {};
377
+ new_config.build.ssr = !secondary_build_started;
378
+
379
+ new_config.define = {
380
+ ...define,
381
+ __SVELTEKIT_ADAPTER_NAME__: s(kit.adapter?.name),
382
+ __SVELTEKIT_APP_VERSION_FILE__: s(`${kit.appDir}/version.json`),
383
+ __SVELTEKIT_APP_VERSION_POLL_INTERVAL__: s(kit.version.pollInterval),
384
+ __SVELTEKIT_PAYLOAD__: new_config.build.ssr
385
+ ? '{}'
386
+ : `globalThis.__sveltekit_${version_hash}`
387
+ };
388
+
389
+ if (!secondary_build_started) {
390
+ manifest_data = sync.all(svelte_config, config_env.mode).manifest_data;
391
+ // During the initial server build we don't know yet
392
+ new_config.define.__SVELTEKIT_HAS_SERVER_LOAD__ = 'true';
393
+ new_config.define.__SVELTEKIT_HAS_UNIVERSAL_LOAD__ = 'true';
394
+ } else {
395
+ const nodes = Object.values(
396
+ /** @type {import('types').ServerMetadata} */ (build_metadata).nodes
397
+ );
398
+
399
+ // Through the finished analysis we can now check if any node has server or universal load functions
400
+ const has_server_load = nodes.some((node) => node.has_server_load);
401
+ const has_universal_load = nodes.some((node) => node.has_universal_load);
402
+
403
+ new_config.define.__SVELTEKIT_HAS_SERVER_LOAD__ = s(has_server_load);
404
+ new_config.define.__SVELTEKIT_HAS_UNIVERSAL_LOAD__ = s(has_universal_load);
405
+ }
393
406
  } else {
394
- const nodes = Object.values(
395
- /** @type {import('types').ServerMetadata} */ (build_metadata).nodes
396
- );
407
+ new_config.define = {
408
+ ...define,
409
+ __SVELTEKIT_APP_VERSION_POLL_INTERVAL__: '0',
410
+ __SVELTEKIT_PAYLOAD__: 'globalThis.__sveltekit_dev',
411
+ __SVELTEKIT_HAS_SERVER_LOAD__: 'true',
412
+ __SVELTEKIT_HAS_UNIVERSAL_LOAD__: 'true'
413
+ };
397
414
 
398
- // Through the finished analysis we can now check if any node has server or universal load functions
399
- const has_server_load = nodes.some((node) => node.has_server_load);
400
- const has_universal_load = nodes.some((node) => node.has_universal_load);
415
+ // @ts-ignore this prevents a reference error if `client.js` is imported on the server
416
+ globalThis.__sveltekit_dev = {};
401
417
 
402
- new_config.define.__SVELTEKIT_HAS_SERVER_LOAD__ = s(has_server_load);
403
- new_config.define.__SVELTEKIT_HAS_UNIVERSAL_LOAD__ = s(has_universal_load);
418
+ // These Kit dependencies are packaged as CommonJS, which means they must always be externalized.
419
+ // Without this, the tests will still pass but `pnpm dev` will fail in projects that link `@sveltejs/kit`.
420
+ /** @type {NonNullable<import('vite').UserConfig['ssr']>} */ (new_config.ssr).external = [
421
+ 'cookie',
422
+ 'set-cookie-parser'
423
+ ];
404
424
  }
405
- } else {
406
- new_config.define = {
407
- ...define,
408
- __SVELTEKIT_APP_VERSION_POLL_INTERVAL__: '0',
409
- __SVELTEKIT_PAYLOAD__: 'globalThis.__sveltekit_dev',
410
- __SVELTEKIT_HAS_SERVER_LOAD__: 'true',
411
- __SVELTEKIT_HAS_UNIVERSAL_LOAD__: 'true'
412
- };
413
425
 
414
- // @ts-ignore this prevents a reference error if `client.js` is imported on the server
415
- globalThis.__sveltekit_dev = {};
426
+ warn_overridden_config(config, new_config);
416
427
 
417
- // These Kit dependencies are packaged as CommonJS, which means they must always be externalized.
418
- // Without this, the tests will still pass but `pnpm dev` will fail in projects that link `@sveltejs/kit`.
419
- /** @type {NonNullable<import('vite').UserConfig['ssr']>} */ (new_config.ssr).external = [
420
- 'cookie',
421
- 'set-cookie-parser'
422
- ];
428
+ return new_config;
423
429
  }
424
-
425
- warn_overridden_config(config, new_config);
426
-
427
- return new_config;
428
430
  },
429
431
 
430
432
  /**
@@ -759,7 +761,7 @@ async function kit({ svelte_config }) {
759
761
 
760
762
  // For the client, read the exports and create a new module that only contains fetch functions with the correct metadata
761
763
 
762
- /** @type {Map<string, import('types').RemoteInfo['type']>} */
764
+ /** @type {Map<string, import('types').RemoteInternals['type']>} */
763
765
  const map = new Map();
764
766
 
765
767
  // in dev, load the server module here (which will result in this hook
@@ -815,182 +817,189 @@ async function kit({ svelte_config }) {
815
817
  * Build the SvelteKit-provided Vite config to be merged with the user's vite.config.js file.
816
818
  * @see https://vitejs.dev/guide/api-plugin.html#config
817
819
  */
818
- config(config) {
819
- /** @type {import('vite').UserConfig} */
820
- let new_config;
821
-
822
- const kit_paths_base = kit.paths.base || '/';
823
-
824
- if (is_build) {
825
- const ssr = /** @type {boolean} */ (config.build?.ssr);
826
- const prefix = `${kit.appDir}/immutable`;
827
-
828
- /** @type {Record<string, string>} */
829
- const input = {};
830
-
831
- if (ssr) {
832
- input.index = `${runtime_directory}/server/index.js`;
833
- input.internal = `${kit.outDir}/generated/server/internal.js`;
834
- input['remote-entry'] = `${runtime_directory}/app/server/remote/index.js`;
835
-
836
- // add entry points for every endpoint...
837
- manifest_data.routes.forEach((route) => {
838
- if (route.endpoint) {
839
- const resolved = path.resolve(route.endpoint.file);
840
- const relative = decodeURIComponent(path.relative(kit.files.routes, resolved));
841
- const name = posixify(path.join('entries/endpoints', relative.replace(/\.js$/, '')));
842
- input[name] = resolved;
843
- }
844
- });
845
-
846
- // ...and every component used by pages...
847
- manifest_data.nodes.forEach((node) => {
848
- for (const file of [node.component, node.universal, node.server]) {
849
- if (file) {
850
- const resolved = path.resolve(file);
820
+ config: {
821
+ // avoids overwriting the base setting that's also set by Vitest
822
+ order: 'pre',
823
+ handler(config) {
824
+ /** @type {import('vite').UserConfig} */
825
+ let new_config;
826
+
827
+ const kit_paths_base = kit.paths.base || '/';
828
+
829
+ if (is_build) {
830
+ const ssr = /** @type {boolean} */ (config.build?.ssr);
831
+ const prefix = `${kit.appDir}/immutable`;
832
+
833
+ /** @type {Record<string, string>} */
834
+ const input = {};
835
+
836
+ if (ssr) {
837
+ input.index = `${runtime_directory}/server/index.js`;
838
+ input.internal = `${kit.outDir}/generated/server/internal.js`;
839
+ input['remote-entry'] = `${runtime_directory}/app/server/remote/index.js`;
840
+
841
+ // add entry points for every endpoint...
842
+ manifest_data.routes.forEach((route) => {
843
+ if (route.endpoint) {
844
+ const resolved = path.resolve(route.endpoint.file);
851
845
  const relative = decodeURIComponent(path.relative(kit.files.routes, resolved));
852
-
853
- const name = relative.startsWith('..')
854
- ? posixify(path.join('entries/fallbacks', path.basename(file)))
855
- : posixify(path.join('entries/pages', relative.replace(/\.js$/, '')));
846
+ const name = posixify(
847
+ path.join('entries/endpoints', relative.replace(/\.js$/, ''))
848
+ );
856
849
  input[name] = resolved;
857
850
  }
858
- }
859
- });
851
+ });
860
852
 
861
- // ...and every matcher
862
- Object.entries(manifest_data.matchers).forEach(([key, file]) => {
863
- const name = posixify(path.join('entries/matchers', key));
864
- input[name] = path.resolve(file);
865
- });
853
+ // ...and every component used by pages...
854
+ manifest_data.nodes.forEach((node) => {
855
+ for (const file of [node.component, node.universal, node.server]) {
856
+ if (file) {
857
+ const resolved = path.resolve(file);
858
+ const relative = decodeURIComponent(path.relative(kit.files.routes, resolved));
859
+
860
+ const name = relative.startsWith('..')
861
+ ? posixify(path.join('entries/fallbacks', path.basename(file)))
862
+ : posixify(path.join('entries/pages', relative.replace(/\.js$/, '')));
863
+ input[name] = resolved;
864
+ }
865
+ }
866
+ });
866
867
 
867
- // ...and the hooks files
868
- if (manifest_data.hooks.server) {
869
- input['entries/hooks.server'] = path.resolve(manifest_data.hooks.server);
870
- }
871
- if (manifest_data.hooks.universal) {
872
- input['entries/hooks.universal'] = path.resolve(manifest_data.hooks.universal);
873
- }
868
+ // ...and every matcher
869
+ Object.entries(manifest_data.matchers).forEach(([key, file]) => {
870
+ const name = posixify(path.join('entries/matchers', key));
871
+ input[name] = path.resolve(file);
872
+ });
874
873
 
875
- // ...and the server instrumentation file
876
- const server_instrumentation = resolve_entry(
877
- path.join(kit.files.src, 'instrumentation.server')
878
- );
879
- if (server_instrumentation) {
880
- const { adapter } = kit;
881
- if (adapter && !adapter.supports?.instrumentation?.()) {
882
- throw new Error(`${server_instrumentation} is unsupported in ${adapter.name}.`);
874
+ // ...and the hooks files
875
+ if (manifest_data.hooks.server) {
876
+ input['entries/hooks.server'] = path.resolve(manifest_data.hooks.server);
883
877
  }
884
- if (!kit.experimental.instrumentation.server) {
885
- error_for_missing_config(
886
- '`instrumentation.server.js`',
887
- 'kit.experimental.instrumentation.server',
888
- 'true'
889
- );
878
+ if (manifest_data.hooks.universal) {
879
+ input['entries/hooks.universal'] = path.resolve(manifest_data.hooks.universal);
890
880
  }
891
- input['instrumentation.server'] = server_instrumentation;
892
- }
893
- } else if (svelte_config.kit.output.bundleStrategy !== 'split') {
894
- input['bundle'] = `${runtime_directory}/client/bundle.js`;
895
- } else {
896
- input['entry/start'] = `${runtime_directory}/client/entry.js`;
897
- input['entry/app'] = `${kit.outDir}/generated/client-optimized/app.js`;
898
- manifest_data.nodes.forEach((node, i) => {
899
- if (node.component || node.universal) {
900
- input[`nodes/${i}`] = `${kit.outDir}/generated/client-optimized/nodes/${i}.js`;
881
+
882
+ // ...and the server instrumentation file
883
+ const server_instrumentation = resolve_entry(
884
+ path.join(kit.files.src, 'instrumentation.server')
885
+ );
886
+ if (server_instrumentation) {
887
+ const { adapter } = kit;
888
+ if (adapter && !adapter.supports?.instrumentation?.()) {
889
+ throw new Error(`${server_instrumentation} is unsupported in ${adapter.name}.`);
890
+ }
891
+ if (!kit.experimental.instrumentation.server) {
892
+ error_for_missing_config(
893
+ '`instrumentation.server.js`',
894
+ 'kit.experimental.instrumentation.server',
895
+ 'true'
896
+ );
897
+ }
898
+ input['instrumentation.server'] = server_instrumentation;
901
899
  }
902
- });
903
- }
900
+ } else if (svelte_config.kit.output.bundleStrategy !== 'split') {
901
+ input['bundle'] = `${runtime_directory}/client/bundle.js`;
902
+ } else {
903
+ input['entry/start'] = `${runtime_directory}/client/entry.js`;
904
+ input['entry/app'] = `${kit.outDir}/generated/client-optimized/app.js`;
905
+ manifest_data.nodes.forEach((node, i) => {
906
+ if (node.component || node.universal) {
907
+ input[`nodes/${i}`] = `${kit.outDir}/generated/client-optimized/nodes/${i}.js`;
908
+ }
909
+ });
910
+ }
904
911
 
905
- // see the kit.output.preloadStrategy option for details on why we have multiple options here
906
- const ext = kit.output.preloadStrategy === 'preload-mjs' ? 'mjs' : 'js';
907
-
908
- // We could always use a relative asset base path here, but it's better for performance not to.
909
- // E.g. Vite generates `new URL('/asset.png', import.meta).href` for a relative path vs just '/asset.png'.
910
- // That's larger and takes longer to run and also causes an HTML diff between SSR and client
911
- // causing us to do a more expensive hydration check.
912
- const client_base =
913
- kit.paths.relative !== false || kit.paths.assets ? './' : kit_paths_base;
914
-
915
- const inline = !ssr && svelte_config.kit.output.bundleStrategy === 'inline';
916
- const split = ssr || svelte_config.kit.output.bundleStrategy === 'split';
917
-
918
- new_config = {
919
- base: ssr ? assets_base(kit) : client_base,
920
- build: {
921
- copyPublicDir: !ssr,
922
- cssCodeSplit: svelte_config.kit.output.bundleStrategy !== 'inline',
923
- cssMinify: initial_config.build?.minify == null ? true : !!initial_config.build.minify,
924
- manifest: true,
925
- outDir: `${out}/${ssr ? 'server' : 'client'}`,
926
- rollupOptions: {
927
- input: inline ? input['bundle'] : input,
928
- output: {
929
- format: inline ? 'iife' : 'esm',
930
- name: `__sveltekit_${version_hash}.app`,
931
- entryFileNames: ssr ? '[name].js' : `${prefix}/[name].[hash].${ext}`,
932
- chunkFileNames: ssr ? 'chunks/[name].js' : `${prefix}/chunks/[hash].${ext}`,
933
- assetFileNames: `${prefix}/assets/[name].[hash][extname]`,
934
- hoistTransitiveImports: false,
935
- sourcemapIgnoreList,
936
- inlineDynamicImports: is_rolldown ? undefined : !split
937
- },
938
- preserveEntrySignatures: 'strict',
939
- onwarn(warning, handler) {
940
- if (
941
- (is_rolldown
942
- ? warning.code === 'IMPORT_IS_UNDEFINED'
943
- : warning.code === 'MISSING_EXPORT') &&
944
- warning.id === `${kit.outDir}/generated/client-optimized/app.js`
945
- ) {
946
- // ignore e.g. undefined `handleError` hook when
947
- // referencing `client_hooks.handleError`
948
- return;
912
+ // see the kit.output.preloadStrategy option for details on why we have multiple options here
913
+ const ext = kit.output.preloadStrategy === 'preload-mjs' ? 'mjs' : 'js';
914
+
915
+ // We could always use a relative asset base path here, but it's better for performance not to.
916
+ // E.g. Vite generates `new URL('/asset.png', import.meta).href` for a relative path vs just '/asset.png'.
917
+ // That's larger and takes longer to run and also causes an HTML diff between SSR and client
918
+ // causing us to do a more expensive hydration check.
919
+ const client_base =
920
+ kit.paths.relative !== false || kit.paths.assets ? './' : kit_paths_base;
921
+
922
+ const inline = !ssr && svelte_config.kit.output.bundleStrategy === 'inline';
923
+ const split = ssr || svelte_config.kit.output.bundleStrategy === 'split';
924
+
925
+ new_config = {
926
+ base: ssr ? assets_base(kit) : client_base,
927
+ build: {
928
+ copyPublicDir: !ssr,
929
+ cssCodeSplit: svelte_config.kit.output.bundleStrategy !== 'inline',
930
+ cssMinify:
931
+ initial_config.build?.minify == null ? true : !!initial_config.build.minify,
932
+ manifest: true,
933
+ outDir: `${out}/${ssr ? 'server' : 'client'}`,
934
+ rollupOptions: {
935
+ input: inline ? input['bundle'] : input,
936
+ output: {
937
+ format: inline ? 'iife' : 'esm',
938
+ name: `__sveltekit_${version_hash}.app`,
939
+ entryFileNames: ssr ? '[name].js' : `${prefix}/[name].[hash].${ext}`,
940
+ chunkFileNames: ssr ? 'chunks/[name].js' : `${prefix}/chunks/[hash].${ext}`,
941
+ assetFileNames: `${prefix}/assets/[name].[hash][extname]`,
942
+ hoistTransitiveImports: false,
943
+ sourcemapIgnoreList,
944
+ inlineDynamicImports: is_rolldown ? undefined : !split
945
+ },
946
+ preserveEntrySignatures: 'strict',
947
+ onwarn(warning, handler) {
948
+ if (
949
+ (is_rolldown
950
+ ? warning.code === 'IMPORT_IS_UNDEFINED'
951
+ : warning.code === 'MISSING_EXPORT') &&
952
+ warning.id === `${kit.outDir}/generated/client-optimized/app.js`
953
+ ) {
954
+ // ignore e.g. undefined `handleError` hook when
955
+ // referencing `client_hooks.handleError`
956
+ return;
957
+ }
958
+
959
+ handler(warning);
949
960
  }
950
-
951
- handler(warning);
952
- }
961
+ },
962
+ ssrEmitAssets: true,
963
+ target: ssr ? 'node18.13' : undefined
953
964
  },
954
- ssrEmitAssets: true,
955
- target: ssr ? 'node18.13' : undefined
956
- },
957
- publicDir: kit.files.assets,
958
- worker: {
959
- rollupOptions: {
960
- output: {
961
- entryFileNames: `${prefix}/workers/[name]-[hash].js`,
962
- chunkFileNames: `${prefix}/workers/chunks/[hash].js`,
963
- assetFileNames: `${prefix}/workers/assets/[name]-[hash][extname]`,
964
- hoistTransitiveImports: false
965
+ publicDir: kit.files.assets,
966
+ worker: {
967
+ rollupOptions: {
968
+ output: {
969
+ entryFileNames: `${prefix}/workers/[name]-[hash].js`,
970
+ chunkFileNames: `${prefix}/workers/chunks/[hash].js`,
971
+ assetFileNames: `${prefix}/workers/assets/[name]-[hash][extname]`,
972
+ hoistTransitiveImports: false
973
+ }
965
974
  }
966
975
  }
967
- }
968
- };
976
+ };
969
977
 
970
- // we must reference Vite 8 options conditionally. Otherwise, older Vite
971
- // versions throw an error about unknown config options
972
- if (is_rolldown && new_config?.build?.rollupOptions?.output) {
973
- // @ts-ignore only available in Vite 8
974
- new_config.build.rollupOptions.output.codeSplitting = split;
978
+ // we must reference Vite 8 options conditionally. Otherwise, older Vite
979
+ // versions throw an error about unknown config options
980
+ if (is_rolldown && new_config?.build?.rollupOptions?.output) {
981
+ // @ts-ignore only available in Vite 8
982
+ new_config.build.rollupOptions.output.codeSplitting = split;
983
+ }
984
+ } else {
985
+ new_config = {
986
+ appType: 'custom',
987
+ base: kit_paths_base,
988
+ build: {
989
+ rollupOptions: {
990
+ // Vite dependency crawler needs an explicit JS entry point
991
+ // even though server otherwise works without it
992
+ input: `${runtime_directory}/client/entry.js`
993
+ }
994
+ },
995
+ publicDir: kit.files.assets
996
+ };
975
997
  }
976
- } else {
977
- new_config = {
978
- appType: 'custom',
979
- base: kit_paths_base,
980
- build: {
981
- rollupOptions: {
982
- // Vite dependency crawler needs an explicit JS entry point
983
- // even though server otherwise works without it
984
- input: `${runtime_directory}/client/entry.js`
985
- }
986
- },
987
- publicDir: kit.files.assets
988
- };
989
- }
990
998
 
991
- warn_overridden_config(config, new_config);
999
+ warn_overridden_config(config, new_config);
992
1000
 
993
- return new_config;
1001
+ return new_config;
1002
+ }
994
1003
  },
995
1004
 
996
1005
  /**