Home / File/ index.ts — astro Source File

index.ts — astro Source File

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

File typescript CoreAstro RenderingEngine 11 imports 3 functions

Entity Profile

Dependency Diagram

graph LR
  940bf6b8_08dc_39d6_8acd_921dccfcc472["index.ts"]
  7216d952_4e4a_2d18_a85b_74b4ace79e2b["../core/constants.js"]
  940bf6b8_08dc_39d6_8acd_921dccfcc472 --> 7216d952_4e4a_2d18_a85b_74b4ace79e2b
  f68003f1_292f_ca44_03ce_21af87a33c7b["../core/util.js"]
  940bf6b8_08dc_39d6_8acd_921dccfcc472 --> f68003f1_292f_ca44_03ce_21af87a33c7b
  e9b74c5a_8d34_34a7_e196_5e41b87214aa["../types/astro.js"]
  940bf6b8_08dc_39d6_8acd_921dccfcc472 --> e9b74c5a_8d34_34a7_e196_5e41b87214aa
  efa645f9_2724_da8e_6cfc_0fef8f15e226["../vite-plugin-astro-server/util.js"]
  940bf6b8_08dc_39d6_8acd_921dccfcc472 --> efa645f9_2724_da8e_6cfc_0fef8f15e226
  cf37a168_0cc0_cca0_ac64_5e7070a871a4["./util.js"]
  940bf6b8_08dc_39d6_8acd_921dccfcc472 --> cf37a168_0cc0_cca0_ac64_5e7070a871a4
  86f9753f_24b2_59d0_0895_2be6cf7b0b20["../vite-plugin-css/util.js"]
  940bf6b8_08dc_39d6_8acd_921dccfcc472 --> 86f9753f_24b2_59d0_0895_2be6cf7b0b20
  a370a45c_02f1_30de_445d_47ee08d095a2["../core/viteUtils.js"]
  940bf6b8_08dc_39d6_8acd_921dccfcc472 --> a370a45c_02f1_30de_445d_47ee08d095a2
  eb7ca709_080c_a438_b9d7_f1238835779d["../content/consts.js"]
  940bf6b8_08dc_39d6_8acd_921dccfcc472 --> eb7ca709_080c_a438_b9d7_f1238835779d
  e295a5df_e35c_362b_33c3_5ce4842d17b5["./const.js"]
  940bf6b8_08dc_39d6_8acd_921dccfcc472 --> e295a5df_e35c_362b_33c3_5ce4842d17b5
  e4df8f29_fb2f_3d70_a962_fdf6a3670b22["path"]
  940bf6b8_08dc_39d6_8acd_921dccfcc472 --> e4df8f29_fb2f_3d70_a962_fdf6a3670b22
  263e522e_1aa5_ebc3_e7d6_45ebc51671f7["vite"]
  940bf6b8_08dc_39d6_8acd_921dccfcc472 --> 263e522e_1aa5_ebc3_e7d6_45ebc51671f7
  style 940bf6b8_08dc_39d6_8acd_921dccfcc472 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { prependForwardSlash } from '@astrojs/internal-helpers/path';
import type * as vite from 'vite';
import type { DevEnvironment, Plugin } from 'vite';
import { ASTRO_VITE_ENVIRONMENT_NAMES } from '../core/constants.js';
import { wrapId } from '../core/util.js';
import type { ImportedDevStyle, RoutesList } from '../types/astro.js';
import { inlineRE, isBuildableCSSRequest, rawRE } from '../vite-plugin-astro-server/util.js';
import { getVirtualModulePageNameForComponent } from '../vite-plugin-pages/util.js';
import { getDevCSSModuleName } from './util.js';
import { CSS_LANGS_RE } from '../core/viteUtils.js';
import { PROPAGATED_ASSET_QUERY_PARAM } from '../content/consts.js';
import {
	ASTRO_CSS_EXTENSION_POST_PATTERN,
	MODULE_DEV_CSS,
	MODULE_DEV_CSS_ALL,
	MODULE_DEV_CSS_PREFIX,
	RESOLVED_MODULE_DEV_CSS,
	RESOLVED_MODULE_DEV_CSS_ALL,
	RESOLVED_MODULE_DEV_CSS_PREFIX,
} from './const.js';

interface AstroVitePluginOptions {
	routesList: RoutesList;
	command: 'dev' | 'build';
}

/**
 * Extract the original component path from a masked virtual module name.
 * Inverse function of getVirtualModulePageName().
 */
function getComponentFromVirtualModuleCssName(virtualModulePrefix: string, id: string): string {
	return id
		.slice(virtualModulePrefix.length)
		.replace(new RegExp(ASTRO_CSS_EXTENSION_POST_PATTERN, 'g'), '.');
}

/**
 * Walk down the dependency tree to collect CSS with depth/order.
 * Performs depth-first traversal to ensure correct CSS ordering based on import order.
 */
function* collectCSSWithOrder(
	id: string,
	mod: vite.EnvironmentModuleNode,
	seen = new Set<string>(),
): Generator<ImportedDevStyle & { id: string; idKey: string }, void, unknown> {
	seen.add(id);

	// Stop traversing if we reach an asset propagation stopping point to ensure we only collect CSS
	// relevant to a content collection entry, if any. Not doing so could cause CSS from other
	// entries to potentially be collected and bleed into the CSS included on the page, causing
	// unexpected styles, for example when a module shared between 2 pages would import
	// `astro:content` and thus potentially adding multiple content collection entry assets to the
	// module graph.
	if (id.includes(PROPAGATED_ASSET_QUERY_PARAM)) {
		return;
	}

	// Keep all of the imported modules into an array so we can go through them one at a time
	const imported = Array.from(mod.importedModules);

// ... (187 more lines)

Domain

Subdomains

Dependencies

  • ../content/consts.js
  • ../core/constants.js
  • ../core/util.js
  • ../core/viteUtils.js
  • ../types/astro.js
  • ../vite-plugin-astro-server/util.js
  • ../vite-plugin-css/util.js
  • ./const.js
  • ./util.js
  • path
  • 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 3 function(s): astroDevCssPlugin, collectCSSWithOrder, getComponentFromVirtualModuleCssName.
What does index.ts depend on?
index.ts imports 11 module(s): ../content/consts.js, ../core/constants.js, ../core/util.js, ../core/viteUtils.js, ../types/astro.js, ../vite-plugin-astro-server/util.js, ../vite-plugin-css/util.js, ./const.js, and 3 more.
Where is index.ts in the architecture?
index.ts is located at packages/astro/src/vite-plugin-css/index.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/astro/src/vite-plugin-css).

Analyze Your Own Codebase

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

Try Supermodel Free