@sveltejs/kit 2.55.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.
- package/package.json +3 -4
- package/src/core/postbuild/analyse.js +3 -3
- package/src/core/postbuild/prerender.js +9 -6
- package/src/core/sync/write_tsconfig.js +3 -1
- package/src/exports/internal/remote-functions.js +2 -2
- package/src/exports/public.d.ts +38 -12
- package/src/exports/vite/build/build_server.js +24 -4
- package/src/exports/vite/build/build_service_worker.js +16 -6
- package/src/exports/vite/build/utils.js +18 -3
- package/src/exports/vite/index.js +336 -327
- package/src/runtime/app/paths/server.js +1 -1
- package/src/runtime/app/server/index.js +1 -1
- package/src/runtime/app/server/remote/command.js +12 -7
- package/src/runtime/app/server/remote/form.js +14 -14
- package/src/runtime/app/server/remote/index.js +1 -0
- package/src/runtime/app/server/remote/prerender.js +8 -7
- package/src/runtime/app/server/remote/query.js +141 -66
- package/src/runtime/app/server/remote/requested.js +172 -0
- package/src/runtime/app/server/remote/shared.js +32 -10
- package/src/runtime/client/client.js +45 -20
- package/src/runtime/client/remote-functions/command.svelte.js +39 -16
- package/src/runtime/client/remote-functions/form.svelte.js +41 -24
- package/src/runtime/client/remote-functions/prerender.svelte.js +105 -76
- package/src/runtime/client/remote-functions/query.svelte.js +408 -138
- package/src/runtime/client/remote-functions/shared.svelte.js +95 -94
- package/src/runtime/components/svelte-5/error.svelte +2 -0
- package/src/runtime/form-utils.js +3 -7
- package/src/runtime/server/endpoint.js +0 -1
- package/src/runtime/server/page/actions.js +2 -1
- package/src/runtime/server/page/load_data.js +3 -1
- package/src/runtime/server/page/render.js +38 -15
- package/src/runtime/server/remote.js +65 -50
- package/src/runtime/server/respond.js +17 -3
- package/src/runtime/server/utils.js +0 -12
- package/src/runtime/shared.js +233 -5
- package/src/types/global-private.d.ts +4 -4
- package/src/types/internal.d.ts +80 -44
- package/src/utils/css.js +0 -3
- package/src/utils/escape.js +15 -3
- package/src/version.js +1 -1
- package/types/index.d.ts +67 -13
- 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
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
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
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
//
|
|
287
|
-
|
|
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
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
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
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
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
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
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 (
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
new_config.define
|
|
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
|
-
|
|
395
|
-
|
|
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
|
-
//
|
|
399
|
-
|
|
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
|
-
|
|
403
|
-
|
|
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
|
-
|
|
415
|
-
globalThis.__sveltekit_dev = {};
|
|
426
|
+
warn_overridden_config(config, new_config);
|
|
416
427
|
|
|
417
|
-
|
|
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').
|
|
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
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
const
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
input
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
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
|
-
|
|
854
|
-
|
|
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
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
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
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
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
|
-
|
|
876
|
-
|
|
877
|
-
|
|
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 (
|
|
885
|
-
|
|
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
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
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
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
(
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
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
|
-
|
|
952
|
-
|
|
961
|
+
},
|
|
962
|
+
ssrEmitAssets: true,
|
|
963
|
+
target: ssr ? 'node18.13' : undefined
|
|
953
964
|
},
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
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
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
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
|
-
|
|
999
|
+
warn_overridden_config(config, new_config);
|
|
992
1000
|
|
|
993
|
-
|
|
1001
|
+
return new_config;
|
|
1002
|
+
}
|
|
994
1003
|
},
|
|
995
1004
|
|
|
996
1005
|
/**
|