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 RenderingEngine 3 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  2893338f_80b8_6eb0_6b0f_293104b9f955["index.ts"]
  f202f4fa_f9f9_9398_9510_7a42ce8ea007["../environments.js"]
  2893338f_80b8_6eb0_6b0f_293104b9f955 --> f202f4fa_f9f9_9398_9510_7a42ce8ea007
  e9b74c5a_8d34_34a7_e196_5e41b87214aa["../types/astro.js"]
  2893338f_80b8_6eb0_6b0f_293104b9f955 --> e9b74c5a_8d34_34a7_e196_5e41b87214aa
  263e522e_1aa5_ebc3_e7d6_45ebc51671f7["vite"]
  2893338f_80b8_6eb0_6b0f_293104b9f955 --> 263e522e_1aa5_ebc3_e7d6_45ebc51671f7
  style 2893338f_80b8_6eb0_6b0f_293104b9f955 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import type { Plugin as VitePlugin } from 'vite';
import { isAstroServerEnvironment } from '../environments.js';
import type { AstroSettings } from '../types/astro.js';

// This is used by Cloudflare's optimizeDeps
const VIRTUAL_CLIENT_ID = 'virtual:astro:adapter-config/client';
const RESOLVED_VIRTUAL_CLIENT_ID = '\0' + VIRTUAL_CLIENT_ID;

export function vitePluginAdapterConfig(settings: AstroSettings): VitePlugin {
	return {
		name: 'astro:adapter-config',
		resolveId: {
			filter: {
				id: new RegExp(`^${VIRTUAL_CLIENT_ID}$`),
			},
			handler() {
				return RESOLVED_VIRTUAL_CLIENT_ID;
			},
		},
		load: {
			filter: {
				id: new RegExp(`^${RESOLVED_VIRTUAL_CLIENT_ID}$`),
			},
			handler() {
				// During SSR, return empty headers to avoid any runtime issues
				if (isAstroServerEnvironment(this.environment)) {
					return {
						code: `export const internalFetchHeaders = {};`,
					};
				}

				const adapter = settings.adapter;
				const clientConfig = adapter?.client || {};

				let internalFetchHeaders = {};
				if (clientConfig.internalFetchHeaders) {
					internalFetchHeaders =
						typeof clientConfig.internalFetchHeaders === 'function'
							? clientConfig.internalFetchHeaders()
							: clientConfig.internalFetchHeaders;
				}

				return {
					code: `export const internalFetchHeaders = ${JSON.stringify(internalFetchHeaders)};`,
				};
			},
		},
	};
}

Domain

Subdomains

Dependencies

  • ../environments.js
  • ../types/astro.js
  • vite

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, RenderingEngine subdomain.
What functions are defined in index.ts?
index.ts defines 1 function(s): vitePluginAdapterConfig.
What does index.ts depend on?
index.ts imports 3 module(s): ../environments.js, ../types/astro.js, vite.
Where is index.ts in the architecture?
index.ts is located at packages/astro/src/vite-plugin-adapter-config/index.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/astro/src/vite-plugin-adapter-config).

Analyze Your Own Codebase

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

Try Supermodel Free