function buildExtraConfigForSvelte(config) {
	// include svelte imports for optimization unless explicitly excluded
	/** @type {string[]} */
	const include = [];
	/** @type {string[]} */
	const exclude = [];
	if (!isDepExcluded('svelte', config.optimizeDeps?.exclude ?? [])) {
		const svelteImportsToInclude = SVELTE_IMPORTS.filter(
			(si) => !(si.endsWith('/server') || si.includes('/server/'))
		);
		svelteImportsToInclude.push(...SVELTE_RUNTIME_DEPENDENCIES.map((dep) => `svelte > ${dep}`));
		log.debug(
			`adding bare svelte packages and runtime dependencies to optimizeDeps.include: ${svelteImportsToInclude.join(', ')} `,
			undefined,
			'config'
		);
		include.push(...svelteImportsToInclude);
	} else {
		log.debug(
			'"svelte" is excluded in optimizeDeps.exclude, skipped adding it to include.',
			undefined,
			'config'
		);
	}
	/** @type {(string | RegExp)[]} */
	const noExternal = [];
	/** @type {string[]} */
	const external = [];
	// add svelte to ssr.noExternal unless it is present in ssr.external
	// so it is correctly resolving according to the conditions in sveltes exports map
	if (!isDepExternaled('svelte', config.ssr?.external ?? [])) {
		noExternal.push('svelte', /^svelte\//);
	}
	// esm-env needs to be bundled by default for the development/production condition
	// be properly used by svelte
	if (!isDepExternaled('esm-env', config.ssr?.external ?? [])) {
		noExternal.push('esm-env');
	}
	return { optimizeDeps: { include, exclude }, ssr: { noExternal, external } };
}
@param {import('vite').UserConfig} config
@returns {import('vite').UserConfig & { optimizeDeps: { include: string[], exclude:string[] }, ssr: { noExternal:(string|RegExp)[], external: string[] } } }