Home / File/ index.ts — astro Source File

index.ts — astro Source File

Architecture documentation for index.ts, a typescript file in the astro codebase. 3 imports, 0 dependents.

File typescript CoreAstro RoutingSystem 3 imports 3 functions

Entity Profile

Dependency Diagram

graph LR
  f101d1c4_9deb_6cac_9ca2_88a310d5a8a5["index.ts"]
  ecac46ea_344a_6a62_ce19_1b0e13910637["vite-plugin-svelte"]
  f101d1c4_9deb_6cac_9ca2_88a310d5a8a5 --> ecac46ea_344a_6a62_ce19_1b0e13910637
  f16d8c76_2866_6150_bd14_0347b59abfe9["astro"]
  f101d1c4_9deb_6cac_9ca2_88a310d5a8a5 --> f16d8c76_2866_6150_bd14_0347b59abfe9
  263e522e_1aa5_ebc3_e7d6_45ebc51671f7["vite"]
  f101d1c4_9deb_6cac_9ca2_88a310d5a8a5 --> 263e522e_1aa5_ebc3_e7d6_45ebc51671f7
  style f101d1c4_9deb_6cac_9ca2_88a310d5a8a5 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import type { Options } from '@sveltejs/vite-plugin-svelte';
import { svelte, vitePreprocess } from '@sveltejs/vite-plugin-svelte';
import type { AstroIntegration, AstroRenderer } from 'astro';
import type { Plugin } from 'vite';

function getRenderer(): AstroRenderer {
	return {
		name: '@astrojs/svelte',
		clientEntrypoint: '@astrojs/svelte/client.js',
		serverEntrypoint: '@astrojs/svelte/server.js',
	};
}

export { getRenderer as getContainerRenderer };

export default function svelteIntegration(options?: Options): AstroIntegration {
	return {
		name: '@astrojs/svelte',
		hooks: {
			'astro:config:setup': async ({ updateConfig, addRenderer }) => {
				addRenderer(getRenderer());
				updateConfig({
					vite: {
						plugins: [svelte(options), configEnvironmentPlugin()],
					},
				});
			},
		},
	};
}

function configEnvironmentPlugin(): Plugin {
	return {
		name: '@astrojs/svelte:config-environment',
		configEnvironment(environmentName, options) {
			if (
				environmentName === 'client' ||
				((environmentName === 'ssr' || environmentName === 'prerender') &&
					options.optimizeDeps?.noDiscovery === false)
			) {
				return {
					optimizeDeps: {
						include:
							environmentName === 'client'
								? ['@astrojs/svelte/client.js']
								: environmentName === 'ssr' || environmentName === 'prerender'
									? ['svelte/server', 'svelte/internal/server']
									: [],
						exclude:
							environmentName === 'ssr' || environmentName === 'prerender'
								? ['@astrojs/svelte/server.js']
								: [],
					},
				};
			}
		},
	};
}

export { vitePreprocess };

Domain

Subdomains

Dependencies

  • astro
  • vite
  • vite-plugin-svelte

Frequently Asked Questions

What does index.ts do?
index.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, RoutingSystem subdomain.
What functions are defined in index.ts?
index.ts defines 3 function(s): configEnvironmentPlugin, getRenderer, svelteIntegration.
What does index.ts depend on?
index.ts imports 3 module(s): astro, vite, vite-plugin-svelte.
Where is index.ts in the architecture?
index.ts is located at packages/integrations/svelte/src/index.ts (domain: CoreAstro, subdomain: RoutingSystem, directory: packages/integrations/svelte/src).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free