@sveltejs/kit 1.1.3 → 1.2.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.
@@ -8,20 +8,19 @@ import colors from 'kleur';
8
8
  import * as vite from 'vite';
9
9
 
10
10
  import { mkdirp, posixify, resolve_entry, rimraf } from '../../utils/filesystem.js';
11
- import { SVELTE_KIT_ASSETS } from '../../constants.js';
12
11
  import { create_static_module, create_dynamic_module } from '../../core/env.js';
13
12
  import * as sync from '../../core/sync/sync.js';
14
13
  import { create_assets } from '../../core/sync/create_manifest_data/index.js';
15
- import { runtime_base, runtime_directory, logger } from '../../core/utils.js';
14
+ import { runtime_directory, logger } from '../../core/utils.js';
16
15
  import { load_config } from '../../core/config/index.js';
17
16
  import { generate_manifest } from '../../core/generate_manifest/index.js';
18
17
  import { build_server } from './build/build_server.js';
19
18
  import { build_service_worker } from './build/build_service_worker.js';
20
- import { find_deps, get_build_setup_config, get_build_compile_config } from './build/utils.js';
19
+ import { assets_base, find_deps } from './build/utils.js';
21
20
  import { dev } from './dev/index.js';
22
21
  import { is_illegal, module_guard, normalize_id } from './graph_analysis/index.js';
23
22
  import { preview } from './preview/index.js';
24
- import { get_config_aliases, get_app_aliases, get_env } from './utils.js';
23
+ import { get_config_aliases, get_env } from './utils.js';
25
24
 
26
25
  export { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
27
26
 
@@ -153,6 +152,9 @@ export async function sveltekit() {
153
152
  * @return {import('vite').Plugin[]}
154
153
  */
155
154
  function kit({ svelte_config }) {
155
+ const { kit } = svelte_config;
156
+ const out = `${kit.outDir}/output`;
157
+
156
158
  /** @type {import('vite').ResolvedConfig} */
157
159
  let vite_config;
158
160
 
@@ -180,78 +182,8 @@ function kit({ svelte_config }) {
180
182
  /** @type {{ public: Record<string, string>; private: Record<string, string> }} */
181
183
  let env;
182
184
 
183
- /**
184
- * @type {{
185
- * output_dir: string;
186
- * client_out_dir: string;
187
- * }}
188
- */
189
- let paths;
190
-
191
185
  let completed_build = false;
192
186
 
193
- function vite_client_build_config() {
194
- /** @type {Record<string, string>} */
195
- const input = {
196
- // Put unchanging assets in immutable directory. We don't set that in the
197
- // outDir so that other plugins can add mutable assets to the bundle
198
- start: `${runtime_directory}/client/start.js`
199
- };
200
-
201
- manifest_data.nodes.forEach((node) => {
202
- if (node.component) {
203
- const resolved = path.resolve(node.component);
204
- const relative = decodeURIComponent(
205
- path.relative(svelte_config.kit.files.routes, resolved)
206
- );
207
-
208
- const name = relative.startsWith('..')
209
- ? path.basename(node.component)
210
- : posixify(path.join('pages', relative));
211
- input[`components/${name}`] = resolved;
212
- }
213
-
214
- if (node.universal) {
215
- const resolved = path.resolve(node.universal);
216
- const relative = decodeURIComponent(
217
- path.relative(svelte_config.kit.files.routes, resolved)
218
- );
219
-
220
- const name = relative.startsWith('..')
221
- ? path.basename(node.universal)
222
- : posixify(path.join('pages', relative));
223
- input[`modules/${name}`] = resolved;
224
- }
225
- });
226
-
227
- return get_build_compile_config({
228
- config: svelte_config,
229
- input,
230
- ssr: false,
231
- outDir: `${paths.client_out_dir}`
232
- });
233
- }
234
-
235
- /**
236
- * @param {import('rollup').OutputAsset[]} assets
237
- * @param {import('rollup').OutputChunk[]} chunks
238
- */
239
- function client_build_info(assets, chunks) {
240
- /** @type {import('vite').Manifest} */
241
- const vite_manifest = JSON.parse(
242
- fs.readFileSync(`${paths.client_out_dir}/${vite_config.build.manifest}`, 'utf-8')
243
- );
244
-
245
- const entry_id = posixify(path.relative('.', `${runtime_directory}/client/start.js`));
246
-
247
- return {
248
- assets,
249
- chunks,
250
- entry: find_deps(vite_manifest, entry_id, false),
251
- vite_manifest
252
- };
253
- }
254
-
255
187
  /** @type {import('vite').Plugin} */
256
188
  const plugin_setup = {
257
189
  name: 'vite-plugin-sveltekit-setup',
@@ -262,55 +194,33 @@ function kit({ svelte_config }) {
262
194
  */
263
195
  async config(config, config_env) {
264
196
  vite_config_env = config_env;
265
-
266
- env = get_env(svelte_config.kit.env, vite_config_env.mode);
267
-
268
- // The config is created in build_server for SSR mode and passed inline
269
- if (config.build?.ssr) return;
270
-
271
197
  is_build = config_env.command === 'build';
272
198
 
273
- paths = {
274
- output_dir: `${svelte_config.kit.outDir}/output`,
275
- client_out_dir: `${svelte_config.kit.outDir}/output/client`
276
- };
277
-
278
- if (is_build) {
279
- manifest_data = (await sync.all(svelte_config, config_env.mode)).manifest_data;
280
-
281
- const new_config = get_build_setup_config({ config: svelte_config, ssr: false });
282
-
283
- const warning = warn_overridden_config(config, new_config);
284
- if (warning) console.error(warning + '\n');
285
-
286
- return new_config;
287
- }
199
+ env = get_env(kit.env, vite_config_env.mode);
288
200
 
289
201
  const allow = new Set([
290
- svelte_config.kit.files.lib,
291
- svelte_config.kit.files.routes,
292
- svelte_config.kit.outDir,
202
+ kit.files.lib,
203
+ kit.files.routes,
204
+ kit.outDir,
293
205
  path.resolve('src'), // TODO this isn't correct if user changed all his files to sth else than src (like in test/options)
294
206
  path.resolve('node_modules'),
295
207
  path.resolve(vite.searchForWorkspaceRoot(cwd), 'node_modules')
296
208
  ]);
209
+
297
210
  // We can only add directories to the allow list, so we find out
298
211
  // if there's a client hooks file and pass its directory
299
- const client_hooks = resolve_entry(svelte_config.kit.files.hooks.client);
300
- if (client_hooks) {
301
- allow.add(path.dirname(client_hooks));
302
- }
212
+ const client_hooks = resolve_entry(kit.files.hooks.client);
213
+ if (client_hooks) allow.add(path.dirname(client_hooks));
303
214
 
304
215
  // dev and preview config can be shared
305
216
  /** @type {import('vite').UserConfig} */
306
- const result = {
307
- define: {
308
- __SVELTEKIT_APP_VERSION_POLL_INTERVAL__: '0',
309
- __SVELTEKIT_DEV__: config_env.command === 'serve',
310
- __SVELTEKIT_EMBEDDED__: svelte_config.kit.embedded ? 'true' : 'false'
311
- },
217
+ const new_config = {
312
218
  resolve: {
313
- alias: [...get_app_aliases(svelte_config.kit), ...get_config_aliases(svelte_config.kit)]
219
+ alias: [
220
+ { find: '__GENERATED__', replacement: path.posix.join(kit.outDir, 'generated') },
221
+ { find: '$app', replacement: `${runtime_directory}/app` },
222
+ ...get_config_aliases(kit)
223
+ ]
314
224
  },
315
225
  root: cwd,
316
226
  server: {
@@ -320,17 +230,10 @@ function kit({ svelte_config }) {
320
230
  watch: {
321
231
  ignored: [
322
232
  // Ignore all siblings of config.kit.outDir/generated
323
- `${posixify(svelte_config.kit.outDir)}/!(generated)`
233
+ `${posixify(kit.outDir)}/!(generated)`
324
234
  ]
325
235
  }
326
236
  },
327
- ssr: {
328
- // Without this, Vite will treat `@sveltejs/kit` as noExternal if it's
329
- // a linked dependency, and that causes modules to be imported twice
330
- // under different IDs, which breaks a bunch of stuff
331
- // https://github.com/vitejs/vite/pull/9296
332
- external: ['@sveltejs/kit', 'cookie', 'set-cookie-parser']
333
- },
334
237
  optimizeDeps: {
335
238
  exclude: [
336
239
  '@sveltejs/kit',
@@ -342,12 +245,64 @@ function kit({ svelte_config }) {
342
245
  }
343
246
  };
344
247
 
345
- const warning = warn_overridden_config(config, result);
346
- if (warning) console.error(warning);
248
+ if (is_build) {
249
+ new_config.define = {
250
+ __SVELTEKIT_ADAPTER_NAME__: JSON.stringify(kit.adapter?.name),
251
+ __SVELTEKIT_APP_VERSION_FILE__: JSON.stringify(`${kit.appDir}/version.json`),
252
+ __SVELTEKIT_APP_VERSION_POLL_INTERVAL__: JSON.stringify(kit.version.pollInterval),
253
+ __SVELTEKIT_DEV__: 'false',
254
+ __SVELTEKIT_EMBEDDED__: kit.embedded ? 'true' : 'false'
255
+ };
256
+
257
+ new_config.ssr = {
258
+ noExternal: [
259
+ // TODO document why this is necessary
260
+ '@sveltejs/kit',
261
+ // This ensures that esm-env is inlined into the server output with the
262
+ // export conditions resolved correctly through Vite. This prevents adapters
263
+ // that bundle later on to resolve the export conditions incorrectly
264
+ // and for example include browser-only code in the server output
265
+ // because they for example use esbuild.build with `platform: 'browser'`
266
+ 'esm-env'
267
+ ]
268
+ };
269
+ } else {
270
+ new_config.define = {
271
+ __SVELTEKIT_APP_VERSION_POLL_INTERVAL__: '0',
272
+ __SVELTEKIT_DEV__: 'true',
273
+ __SVELTEKIT_EMBEDDED__: kit.embedded ? 'true' : 'false'
274
+ };
275
+
276
+ new_config.ssr = {
277
+ // Without this, Vite will treat `@sveltejs/kit` as noExternal if it's
278
+ // a linked dependency, and that causes modules to be imported twice
279
+ // under different IDs, which breaks a bunch of stuff
280
+ // https://github.com/vitejs/vite/pull/9296
281
+ external: ['@sveltejs/kit', 'cookie', 'set-cookie-parser']
282
+ };
283
+ }
284
+
285
+ warn_overridden_config(config, new_config);
347
286
 
348
- return result;
287
+ return new_config;
349
288
  },
350
289
 
290
+ /**
291
+ * Stores the final config.
292
+ */
293
+ configResolved(config) {
294
+ vite_config = config;
295
+
296
+ // This is a hack to prevent Vite from nuking useful logs,
297
+ // pending https://github.com/vitejs/vite/issues/9378
298
+ config.logger.warn('');
299
+ }
300
+ };
301
+
302
+ /** @type {import('vite').Plugin} */
303
+ const plugin_virtual_modules = {
304
+ name: 'vite-plugin-sveltekit-virtual-modules',
305
+
351
306
  async resolveId(id) {
352
307
  // treat $env/static/[public|private] as virtual
353
308
  if (id.startsWith('$env/') || id === '$service-worker') return `\0${id}`;
@@ -356,7 +311,7 @@ function kit({ svelte_config }) {
356
311
  async load(id, options) {
357
312
  if (options?.ssr === false && process.env.TEST !== 'true') {
358
313
  const normalized_cwd = vite.normalizePath(cwd);
359
- const normalized_lib = vite.normalizePath(svelte_config.kit.files.lib);
314
+ const normalized_lib = vite.normalizePath(kit.files.lib);
360
315
  if (
361
316
  is_illegal(id, {
362
317
  cwd: normalized_cwd,
@@ -387,62 +342,6 @@ function kit({ svelte_config }) {
387
342
  case '\0$service-worker':
388
343
  return create_service_worker_module(svelte_config);
389
344
  }
390
- },
391
-
392
- /**
393
- * Stores the final config.
394
- */
395
- configResolved(config) {
396
- vite_config = config;
397
-
398
- // This is a hack to prevent Vite from nuking useful logs,
399
- // pending https://github.com/vitejs/vite/issues/9378
400
- config.logger.warn('');
401
- },
402
-
403
- /**
404
- * Clears the output directories.
405
- */
406
- buildStart() {
407
- if (vite_config.build.ssr) return;
408
-
409
- // Reset for new build. Goes here because `build --watch` calls buildStart but not config
410
- completed_build = false;
411
-
412
- if (is_build) {
413
- if (!vite_config.build.watch) {
414
- rimraf(paths.output_dir);
415
- }
416
- mkdirp(paths.output_dir);
417
- }
418
- },
419
-
420
- generateBundle() {
421
- if (vite_config.build.ssr) return;
422
-
423
- this.emitFile({
424
- type: 'asset',
425
- fileName: `${svelte_config.kit.appDir}/version.json`,
426
- source: JSON.stringify({ version: svelte_config.kit.version.name })
427
- });
428
- },
429
-
430
- /**
431
- * @see https://vitejs.dev/guide/api-plugin.html#configureserver
432
- */
433
- async configureServer(vite) {
434
- const { set_paths, set_version } = await vite.ssrLoadModule(`${runtime_base}/shared.js`);
435
-
436
- // set `import { base, assets } from '$app/paths'`
437
- const { base, assets } = svelte_config.kit.paths;
438
-
439
- set_paths({
440
- base,
441
- assets: assets ? SVELTE_KIT_ASSETS : base
442
- });
443
-
444
- // set `import { version } from '$app/environment'`
445
- set_version(svelte_config.kit.version.name);
446
345
  }
447
346
  };
448
347
 
@@ -455,37 +354,129 @@ function kit({ svelte_config }) {
455
354
  * @see https://vitejs.dev/guide/api-plugin.html#config
456
355
  */
457
356
  async config(config, config_env) {
458
- // The config is created in build_server for SSR mode and passed inline
459
- if (config.build?.ssr) return;
357
+ /** @type {import('vite').UserConfig} */
358
+ let new_config;
460
359
 
461
- if (config_env.command === 'build') {
462
- const new_config = vite_client_build_config();
360
+ if (is_build) {
361
+ manifest_data = (await sync.all(svelte_config, config_env.mode)).manifest_data;
463
362
 
464
- const warning = warn_overridden_config(config, new_config);
465
- if (warning) console.error(warning + '\n');
363
+ const ssr = config.build?.ssr ?? false;
364
+ const prefix = `${kit.appDir}/immutable`;
466
365
 
467
- return new_config;
468
- }
366
+ /** @type {Record<string, string>} */
367
+ const input = {};
469
368
 
470
- // dev and preview config can be shared
471
- /** @type {import('vite').UserConfig} */
472
- const result = {
473
- appType: 'custom',
474
- base: svelte_config.kit.paths.base,
475
- build: {
476
- rollupOptions: {
477
- // Vite dependency crawler needs an explicit JS entry point
478
- // eventhough server otherwise works without it
479
- input: `${runtime_directory}/client/start.js`
369
+ if (ssr) {
370
+ input.index = `${runtime_directory}/server/index.js`;
371
+ input.internal = `${kit.outDir}/generated/server-internal.js`;
372
+
373
+ // add entry points for every endpoint...
374
+ manifest_data.routes.forEach((route) => {
375
+ if (route.endpoint) {
376
+ const resolved = path.resolve(route.endpoint.file);
377
+ const relative = decodeURIComponent(path.relative(kit.files.routes, resolved));
378
+ const name = posixify(path.join('entries/endpoints', relative.replace(/\.js$/, '')));
379
+ input[name] = resolved;
380
+ }
381
+ });
382
+
383
+ // ...and every component used by pages...
384
+ manifest_data.nodes.forEach((node) => {
385
+ for (const file of [node.component, node.universal, node.server]) {
386
+ if (file) {
387
+ const resolved = path.resolve(file);
388
+ const relative = decodeURIComponent(path.relative(kit.files.routes, resolved));
389
+
390
+ const name = relative.startsWith('..')
391
+ ? posixify(path.join('entries/fallbacks', path.basename(file)))
392
+ : posixify(path.join('entries/pages', relative.replace(/\.js$/, '')));
393
+ input[name] = resolved;
394
+ }
395
+ }
396
+ });
397
+
398
+ // ...and every matcher
399
+ Object.entries(manifest_data.matchers).forEach(([key, file]) => {
400
+ const name = posixify(path.join('entries/matchers', key));
401
+ input[name] = path.resolve(file);
402
+ });
403
+ } else {
404
+ /** @type {Record<string, string>} */
405
+ input.start = `${runtime_directory}/client/start.js`;
406
+
407
+ manifest_data.nodes.forEach((node) => {
408
+ if (node.component) {
409
+ const resolved = path.resolve(node.component);
410
+ const relative = decodeURIComponent(path.relative(kit.files.routes, resolved));
411
+
412
+ const name = relative.startsWith('..')
413
+ ? path.basename(node.component)
414
+ : posixify(path.join('pages', relative));
415
+ input[`components/${name}`] = resolved;
416
+ }
417
+
418
+ if (node.universal) {
419
+ const resolved = path.resolve(node.universal);
420
+ const relative = decodeURIComponent(path.relative(kit.files.routes, resolved));
421
+
422
+ const name = relative.startsWith('..')
423
+ ? path.basename(node.universal)
424
+ : posixify(path.join('pages', relative));
425
+ input[`modules/${name}`] = resolved;
426
+ }
427
+ });
428
+ }
429
+
430
+ new_config = {
431
+ base: ssr ? assets_base(kit) : './',
432
+ build: {
433
+ cssCodeSplit: true,
434
+ outDir: `${out}/${ssr ? 'server' : 'client'}`,
435
+ rollupOptions: {
436
+ input,
437
+ output: {
438
+ format: 'esm',
439
+ entryFileNames: ssr ? '[name].js' : `${prefix}/[name]-[hash].js`,
440
+ chunkFileNames: ssr ? 'chunks/[name].js' : `${prefix}/chunks/[name]-[hash].js`,
441
+ assetFileNames: `${prefix}/assets/[name]-[hash][extname]`,
442
+ hoistTransitiveImports: false
443
+ },
444
+ preserveEntrySignatures: 'strict'
445
+ },
446
+ target: ssr ? 'node16.14' : undefined,
447
+ // don't use the default name to avoid collisions with 'static/manifest.json'
448
+ manifest: 'vite-manifest.json'
449
+ },
450
+ publicDir: ssr ? false : kit.files.assets,
451
+ worker: {
452
+ rollupOptions: {
453
+ output: {
454
+ entryFileNames: `${prefix}/workers/[name]-[hash].js`,
455
+ chunkFileNames: `${prefix}/workers/chunks/[name]-[hash].js`,
456
+ assetFileNames: `${prefix}/workers/assets/[name]-[hash][extname]`,
457
+ hoistTransitiveImports: false
458
+ }
459
+ }
480
460
  }
481
- },
482
- publicDir: svelte_config.kit.files.assets
483
- };
461
+ };
462
+ } else {
463
+ new_config = {
464
+ appType: 'custom',
465
+ base: kit.paths.base,
466
+ build: {
467
+ rollupOptions: {
468
+ // Vite dependency crawler needs an explicit JS entry point
469
+ // eventhough server otherwise works without it
470
+ input: `${runtime_directory}/client/start.js`
471
+ }
472
+ },
473
+ publicDir: kit.files.assets
474
+ };
475
+ }
484
476
 
485
- const warning = warn_overridden_config(config, result);
486
- if (warning) console.error(warning);
477
+ warn_overridden_config(config, new_config);
487
478
 
488
- return result;
479
+ return new_config;
489
480
  },
490
481
 
491
482
  /**
@@ -504,6 +495,33 @@ function kit({ svelte_config }) {
504
495
  return preview(vite, vite_config, svelte_config);
505
496
  },
506
497
 
498
+ /**
499
+ * Clears the output directories.
500
+ */
501
+ buildStart() {
502
+ if (vite_config.build.ssr) return;
503
+
504
+ // Reset for new build. Goes here because `build --watch` calls buildStart but not config
505
+ completed_build = false;
506
+
507
+ if (is_build) {
508
+ if (!vite_config.build.watch) {
509
+ rimraf(out);
510
+ }
511
+ mkdirp(out);
512
+ }
513
+ },
514
+
515
+ generateBundle() {
516
+ if (vite_config.build.ssr) return;
517
+
518
+ this.emitFile({
519
+ type: 'asset',
520
+ fileName: `${kit.appDir}/version.json`,
521
+ source: JSON.stringify({ version: kit.version.name })
522
+ });
523
+ },
524
+
507
525
  /**
508
526
  * Vite builds a single bundle. We need three bundles: client, server, and service worker.
509
527
  * The user's package.json scripts will invoke the Vite CLI to execute the client build. We
@@ -516,13 +534,11 @@ function kit({ svelte_config }) {
516
534
 
517
535
  const guard = module_guard(this, {
518
536
  cwd: vite.normalizePath(process.cwd()),
519
- lib: vite.normalizePath(svelte_config.kit.files.lib)
537
+ lib: vite.normalizePath(kit.files.lib)
520
538
  });
521
539
 
522
540
  manifest_data.nodes.forEach((_node, i) => {
523
- const id = vite.normalizePath(
524
- path.resolve(svelte_config.kit.outDir, `generated/nodes/${i}.js`)
525
- );
541
+ const id = vite.normalizePath(path.resolve(kit.outDir, `generated/nodes/${i}.js`));
526
542
 
527
543
  guard.check(id);
528
544
  });
@@ -544,26 +560,40 @@ function kit({ svelte_config }) {
544
560
  vite_config,
545
561
  vite_config_env,
546
562
  manifest_data,
547
- output_dir: paths.output_dir
563
+ output_dir: out
548
564
  };
549
- const client = client_build_info(assets, chunks);
565
+
566
+ /** @type {import('vite').Manifest} */
567
+ const vite_manifest = JSON.parse(
568
+ fs.readFileSync(`${out}/client/${vite_config.build.manifest}`, 'utf-8')
569
+ );
570
+
571
+ const client = {
572
+ assets,
573
+ chunks,
574
+ entry: find_deps(
575
+ vite_manifest,
576
+ posixify(path.relative('.', `${runtime_directory}/client/start.js`)),
577
+ false
578
+ ),
579
+ vite_manifest
580
+ };
581
+
550
582
  const server = await build_server(options, client);
551
583
 
552
- const service_worker_entry_file = resolve_entry(svelte_config.kit.files.serviceWorker);
584
+ const service_worker_entry_file = resolve_entry(kit.files.serviceWorker);
553
585
 
554
586
  /** @type {import('types').BuildData} */
555
587
  build_data = {
556
- app_dir: svelte_config.kit.appDir,
557
- app_path: `${svelte_config.kit.paths.base.slice(1)}${
558
- svelte_config.kit.paths.base ? '/' : ''
559
- }${svelte_config.kit.appDir}`,
588
+ app_dir: kit.appDir,
589
+ app_path: `${kit.paths.base.slice(1)}${kit.paths.base ? '/' : ''}${kit.appDir}`,
560
590
  manifest_data,
561
591
  service_worker: !!service_worker_entry_file ? 'service-worker.js' : null, // TODO make file configurable?
562
592
  client,
563
593
  server
564
594
  };
565
595
 
566
- const manifest_path = `${paths.output_dir}/server/manifest-full.js`;
596
+ const manifest_path = `${out}/server/manifest-full.js`;
567
597
  fs.writeFileSync(
568
598
  manifest_path,
569
599
  `export const manifest = ${generate_manifest({
@@ -575,7 +605,7 @@ function kit({ svelte_config }) {
575
605
 
576
606
  log.info('Prerendering');
577
607
  await new Promise((fulfil, reject) => {
578
- const results_path = `${svelte_config.kit.outDir}/generated/prerendered.json`;
608
+ const results_path = `${kit.outDir}/generated/prerendered.json`;
579
609
 
580
610
  // do prerendering in a subprocess so any dangling stuff gets killed upon completion
581
611
  const script = fileURLToPath(new URL('../../core/postbuild/index.js', import.meta.url));
@@ -615,7 +645,7 @@ function kit({ svelte_config }) {
615
645
 
616
646
  // generate a new manifest that doesn't include prerendered pages
617
647
  fs.writeFileSync(
618
- `${paths.output_dir}/server/manifest.js`,
648
+ `${out}/server/manifest.js`,
619
649
  `export const manifest = ${generate_manifest({
620
650
  build_data,
621
651
  relative_path: '.',
@@ -624,7 +654,7 @@ function kit({ svelte_config }) {
624
654
  );
625
655
 
626
656
  if (service_worker_entry_file) {
627
- if (svelte_config.kit.paths.assets) {
657
+ if (kit.paths.assets) {
628
658
  throw new Error('Cannot use service worker alongside config.kit.paths.assets');
629
659
  }
630
660
 
@@ -659,7 +689,7 @@ function kit({ svelte_config }) {
659
689
  return;
660
690
  }
661
691
 
662
- if (svelte_config.kit.adapter) {
692
+ if (kit.adapter) {
663
693
  const { adapt } = await import('../../core/adapt/index.js');
664
694
  await adapt(svelte_config, build_data, prerendered, prerender_map, { log });
665
695
  } else {
@@ -672,13 +702,13 @@ function kit({ svelte_config }) {
672
702
  }
673
703
 
674
704
  // avoid making the manifest available to users
675
- fs.unlinkSync(`${paths.output_dir}/client/${vite_config.build.manifest}`);
676
- fs.unlinkSync(`${paths.output_dir}/server/${vite_config.build.manifest}`);
705
+ fs.unlinkSync(`${out}/client/${vite_config.build.manifest}`);
706
+ fs.unlinkSync(`${out}/server/${vite_config.build.manifest}`);
677
707
  }
678
708
  }
679
709
  };
680
710
 
681
- return [plugin_setup, plugin_compile];
711
+ return [plugin_setup, plugin_virtual_modules, plugin_compile];
682
712
  }
683
713
 
684
714
  /** @param {import('rollup').OutputBundle} bundle */
@@ -706,9 +736,9 @@ function warn_overridden_config(config, resolved_config) {
706
736
  const overridden = find_overridden_config(config, resolved_config, enforced_config, '', []);
707
737
 
708
738
  if (overridden.length > 0) {
709
- return (
739
+ console.error(
710
740
  colors.bold().red('The following Vite config options will be overridden by SvelteKit:') +
711
- overridden.map((key) => `\n - ${key}`).join('')
741
+ overridden.map((key) => `\n - ${key}`).join('')
712
742
  );
713
743
  }
714
744
  }