Home / File/ index.ts — astro Source File

index.ts — astro Source File

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

File typescript CoreAstro RenderingEngine 14 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  97247306_c6df_a187_0755_eec66ac1134b["index.ts"]
  7216d952_4e4a_2d18_a85b_74b4ace79e2b["../core/constants.js"]
  97247306_c6df_a187_0755_eec66ac1134b --> 7216d952_4e4a_2d18_a85b_74b4ace79e2b
  d3861967_b647_84d2_ff48_15013353bd56["../core/logger/core.js"]
  97247306_c6df_a187_0755_eec66ac1134b --> d3861967_b647_84d2_ff48_15013353bd56
  f202f4fa_f9f9_9398_9510_7a42ce8ea007["../environments.js"]
  97247306_c6df_a187_0755_eec66ac1134b --> f202f4fa_f9f9_9398_9510_7a42ce8ea007
  e9b74c5a_8d34_34a7_e196_5e41b87214aa["../types/astro.js"]
  97247306_c6df_a187_0755_eec66ac1134b --> e9b74c5a_8d34_34a7_e196_5e41b87214aa
  c32d12e2_d85e_28c0_eea7_9b29629857e0["../types/public/config.js"]
  97247306_c6df_a187_0755_eec66ac1134b --> c32d12e2_d85e_28c0_eea7_9b29629857e0
  87530382_6d99_2339_182d_074e3de33bc8["../vite-plugin-utils/index.js"]
  97247306_c6df_a187_0755_eec66ac1134b --> 87530382_6d99_2339_182d_074e3de33bc8
  648ad786_9f0a_1dbf_6c80_151450f9f01c["./compile.js"]
  97247306_c6df_a187_0755_eec66ac1134b --> 648ad786_9f0a_1dbf_6c80_151450f9f01c
  d9ff10cf_b8bb_1032_1526_9b035b97446e["./hmr.js"]
  97247306_c6df_a187_0755_eec66ac1134b --> d9ff10cf_b8bb_1032_1526_9b035b97446e
  668b2d72_0336_6d81_ad0e_90aa3aae0ed7["./query.js"]
  97247306_c6df_a187_0755_eec66ac1134b --> 668b2d72_0336_6d81_ad0e_90aa3aae0ed7
  578ea01d_496b_3b43_98f2_7b2f0ce78d7e["../vite-plugin-astro/types.js"]
  97247306_c6df_a187_0755_eec66ac1134b --> 578ea01d_496b_3b43_98f2_7b2f0ce78d7e
  d25683f6_6ac0_f5eb_b4b1_ac7cda6eb3c8["./utils.js"]
  97247306_c6df_a187_0755_eec66ac1134b --> d25683f6_6ac0_f5eb_b4b1_ac7cda6eb3c8
  81a20ac1_6143_16be_33ec_872bb8d3a54b["types"]
  97247306_c6df_a187_0755_eec66ac1134b --> 81a20ac1_6143_16be_33ec_872bb8d3a54b
  4454efd2_ab89_97b9_11ec_53ebe0d2f5ce["rollup"]
  97247306_c6df_a187_0755_eec66ac1134b --> 4454efd2_ab89_97b9_11ec_53ebe0d2f5ce
  263e522e_1aa5_ebc3_e7d6_45ebc51671f7["vite"]
  97247306_c6df_a187_0755_eec66ac1134b --> 263e522e_1aa5_ebc3_e7d6_45ebc51671f7
  style 97247306_c6df_a187_0755_eec66ac1134b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import type { HydratedComponent } from '@astrojs/compiler/types';
import type { SourceDescription } from 'rollup';
import type * as vite from 'vite';
import { defaultClientConditions, defaultServerConditions, normalizePath } from 'vite';
import { ASTRO_VITE_ENVIRONMENT_NAMES } from '../core/constants.js';
import type { Logger } from '../core/logger/core.js';
import { isAstroServerEnvironment } from '../environments.js';
import type { AstroSettings } from '../types/astro.js';
import type { AstroConfig } from '../types/public/config.js';
import { normalizeFilename, specialQueriesRE } from '../vite-plugin-utils/index.js';
import { type CompileAstroResult, compileAstro } from './compile.js';
import { handleHotUpdate } from './hmr.js';
import { parseAstroRequest } from './query.js';
import type { PluginMetadata as AstroPluginMetadata, CompileMetadata } from './types.js';
import { loadId } from './utils.js';

export { getAstroMetadata } from './metadata.js';
export type { AstroPluginMetadata };

interface AstroPluginOptions {
	settings: AstroSettings;
	logger: Logger;
}

const astroFileToCompileMetadataWeakMap = new WeakMap<AstroConfig, Map<string, CompileMetadata>>();

/** Transform .astro files for Vite */
export default function astro({ settings, logger }: AstroPluginOptions): vite.Plugin[] {
	const { config } = settings;
	let server: vite.ViteDevServer | undefined;
	let compile: (code: string, filename: string) => Promise<CompileAstroResult>;
	// Each Astro file has its own compile metadata so that its scripts and styles virtual module
	// can retrieve their code from here.
	// NOTE: We need to initialize a map here and in `buildStart` because our unit tests don't
	// call `buildStart` (test bug)
	let astroFileToCompileMetadata = new Map<string, CompileMetadata>();

	// Variables for determining if an id starts with /src...
	const srcRootWeb = config.srcDir.pathname.slice(config.root.pathname.length - 1);
	const isBrowserPath = (path: string) => path.startsWith(srcRootWeb) && srcRootWeb !== '/';
	const notAstroComponent = (component: HydratedComponent) =>
		!component.resolvedPath.endsWith('.astro');

	return [
		{
			name: 'astro:build:css-hmr',
			enforce: 'pre',
			applyToEnvironment(environment) {
				return environment.name === ASTRO_VITE_ENVIRONMENT_NAMES.client;
			},
			transform: {
				filter: {
					id: {
						include: [/(?:\?|&)astro(?:&|=|$)/],
						// ignore astro file sub-requests, e.g. Foo.astro?astro&type=script&index=0&lang.ts
						exclude: [specialQueriesRE],
					},
				},
				async handler(_source, id) {
					const parsedId = parseAstroRequest(id);
// ... (271 more lines)

Domain

Subdomains

Dependencies

  • ../core/constants.js
  • ../core/logger/core.js
  • ../environments.js
  • ../types/astro.js
  • ../types/public/config.js
  • ../vite-plugin-astro/types.js
  • ../vite-plugin-utils/index.js
  • ./compile.js
  • ./hmr.js
  • ./query.js
  • ./utils.js
  • rollup
  • types
  • 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 2 function(s): appendSourceMap, astro.
What does index.ts depend on?
index.ts imports 14 module(s): ../core/constants.js, ../core/logger/core.js, ../environments.js, ../types/astro.js, ../types/public/config.js, ../vite-plugin-astro/types.js, ../vite-plugin-utils/index.js, ./compile.js, and 6 more.
Where is index.ts in the architecture?
index.ts is located at packages/astro/src/vite-plugin-astro/index.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/astro/src/vite-plugin-astro).

Analyze Your Own Codebase

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

Try Supermodel Free