index.ts — astro Source File
Architecture documentation for index.ts, a typescript file in the astro codebase. 8 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR bf5798b6_a592_be5c_0413_36786059a0dc["index.ts"] 53df1f64_e3ce_b2b8_8d84_afcafa7000ec["../core/build/graph.js"] bf5798b6_a592_be5c_0413_36786059a0dc --> 53df1f64_e3ce_b2b8_8d84_afcafa7000ec 1ddffc51_ee9d_5b0c_968e_331983e95ff4["../core/build/internal.js"] bf5798b6_a592_be5c_0413_36786059a0dc --> 1ddffc51_ee9d_5b0c_968e_331983e95ff4 10d4e39f_edb6_3e34_aa93_ae1211e7da05["../types/public/internal.js"] bf5798b6_a592_be5c_0413_36786059a0dc --> 10d4e39f_edb6_3e34_aa93_ae1211e7da05 2273eb38_2cc1_3ab6_58ce_6299d8f2ed92["../vite-plugin-astro/index.js"] bf5798b6_a592_be5c_0413_36786059a0dc --> 2273eb38_2cc1_3ab6_58ce_6299d8f2ed92 578ea01d_496b_3b43_98f2_7b2f0ce78d7e["../vite-plugin-astro/types.js"] bf5798b6_a592_be5c_0413_36786059a0dc --> 578ea01d_496b_3b43_98f2_7b2f0ce78d7e 7216d952_4e4a_2d18_a85b_74b4ace79e2b["../core/constants.js"] bf5798b6_a592_be5c_0413_36786059a0dc --> 7216d952_4e4a_2d18_a85b_74b4ace79e2b 4454efd2_ab89_97b9_11ec_53ebe0d2f5ce["rollup"] bf5798b6_a592_be5c_0413_36786059a0dc --> 4454efd2_ab89_97b9_11ec_53ebe0d2f5ce 263e522e_1aa5_ebc3_e7d6_45ebc51671f7["vite"] bf5798b6_a592_be5c_0413_36786059a0dc --> 263e522e_1aa5_ebc3_e7d6_45ebc51671f7 style bf5798b6_a592_be5c_0413_36786059a0dc fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import type { ModuleInfo } from 'rollup';
import type * as vite from 'vite';
import type { DevEnvironment } from 'vite';
import { getParentModuleInfos, getTopLevelPageModuleInfos } from '../core/build/graph.js';
import type { BuildInternals } from '../core/build/internal.js';
import type { SSRComponentMetadata, SSRResult } from '../types/public/internal.js';
import { getAstroMetadata } from '../vite-plugin-astro/index.js';
import type { PluginMetadata } from '../vite-plugin-astro/types.js';
import { ASTRO_VITE_ENVIRONMENT_NAMES } from '../core/constants.js';
// Detect this in comments, both in .astro components and in js/ts files.
const injectExp = /(?:^\/\/|\/\/!)\s*astro-head-inject/;
export default function configHeadVitePlugin(): vite.Plugin {
let environment: DevEnvironment;
function propagateMetadata<
P extends keyof PluginMetadata['astro'],
V extends PluginMetadata['astro'][P],
>(
this: { getModuleInfo(id: string): ModuleInfo | null },
id: string,
prop: P,
value: V,
seen = new Set<string>(),
) {
if (seen.has(id)) return;
seen.add(id);
const mod = environment.moduleGraph.getModuleById(id);
const info = this.getModuleInfo(id);
if (info?.meta.astro) {
const astroMetadata = getAstroMetadata(info);
if (astroMetadata) {
Reflect.set(astroMetadata, prop, value);
}
}
for (const parent of mod?.importers || []) {
if (parent.id) {
propagateMetadata.call(this, parent.id, prop, value, seen);
}
}
}
return {
name: 'astro:head-metadata',
enforce: 'pre',
apply: 'serve',
configureServer(server) {
environment = server.environments[ASTRO_VITE_ENVIRONMENT_NAMES.ssr];
},
resolveId(source, importer) {
if (importer) {
// Do propagation any time a new module is imported. This is because
// A module with propagation might be loaded before one of its parent pages
// is loaded, in which case that parent page won't have the in-tree and containsHead
// values. Walking up the tree in resolveId ensures that they do
return this.resolve(source, importer, { skipSelf: true }).then((result) => {
if (result) {
// ... (85 more lines)
Domain
Subdomains
Dependencies
- ../core/build/graph.js
- ../core/build/internal.js
- ../core/constants.js
- ../types/public/internal.js
- ../vite-plugin-astro/index.js
- ../vite-plugin-astro/types.js
- rollup
- vite
Source
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): astroHeadBuildPlugin, configHeadVitePlugin.
What does index.ts depend on?
index.ts imports 8 module(s): ../core/build/graph.js, ../core/build/internal.js, ../core/constants.js, ../types/public/internal.js, ../vite-plugin-astro/index.js, ../vite-plugin-astro/types.js, rollup, vite.
Where is index.ts in the architecture?
index.ts is located at packages/astro/src/vite-plugin-head/index.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/astro/src/vite-plugin-head).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free