page-ssr.ts — astro Source File
Architecture documentation for page-ssr.ts, a typescript file in the astro codebase. 6 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 290beb10_73e9_2e05_55db_2da6633b4de1["page-ssr.ts"] f68003f1_292f_ca44_03ce_21af87a33c7b["../core/util.js"] 290beb10_73e9_2e05_55db_2da6633b4de1 --> f68003f1_292f_ca44_03ce_21af87a33c7b e9b74c5a_8d34_34a7_e196_5e41b87214aa["../types/astro.js"] 290beb10_73e9_2e05_55db_2da6633b4de1 --> e9b74c5a_8d34_34a7_e196_5e41b87214aa 522f0b19_6ee0_4435_8932_24d3a280fd69["./index.js"] 290beb10_73e9_2e05_55db_2da6633b4de1 --> 522f0b19_6ee0_4435_8932_24d3a280fd69 f202f4fa_f9f9_9398_9510_7a42ce8ea007["../environments.js"] 290beb10_73e9_2e05_55db_2da6633b4de1 --> f202f4fa_f9f9_9398_9510_7a42ce8ea007 57045b72_8cbd_6e93_7687_5176cbcd502d["magic-string"] 290beb10_73e9_2e05_55db_2da6633b4de1 --> 57045b72_8cbd_6e93_7687_5176cbcd502d 263e522e_1aa5_ebc3_e7d6_45ebc51671f7["vite"] 290beb10_73e9_2e05_55db_2da6633b4de1 --> 263e522e_1aa5_ebc3_e7d6_45ebc51671f7 style 290beb10_73e9_2e05_55db_2da6633b4de1 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import MagicString from 'magic-string';
import { normalizePath, type Plugin as VitePlugin } from 'vite';
import { isPage } from '../core/util.js';
import type { AstroSettings } from '../types/astro.js';
import { PAGE_SSR_SCRIPT_ID } from './index.js';
import { isAstroServerEnvironment } from '../environments.js';
export default function astroScriptsPostPlugin({
settings,
}: {
settings: AstroSettings;
}): VitePlugin {
return {
name: 'astro:scripts:page-ssr',
enforce: 'post',
transform(this, code, id) {
if (!isAstroServerEnvironment(this.environment)) return;
const hasInjectedScript = settings.scripts.some((s) => s.stage === 'page-ssr');
if (!hasInjectedScript) return;
const filename = normalizePath(id);
let fileURL: URL;
try {
fileURL = new URL(`file://${filename}`);
} catch {
// If we can't construct a valid URL, exit early
return;
}
const fileIsPage = isPage(fileURL, settings);
if (!fileIsPage) return;
const s = new MagicString(code, { filename });
s.prepend(`import '${PAGE_SSR_SCRIPT_ID}';\n`);
return {
code: s.toString(),
map: s.generateMap({ hires: 'boundary' }),
};
},
};
}
Domain
Subdomains
Functions
Dependencies
- ../core/util.js
- ../environments.js
- ../types/astro.js
- ./index.js
- magic-string
- vite
Source
Frequently Asked Questions
What does page-ssr.ts do?
page-ssr.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 page-ssr.ts?
page-ssr.ts defines 1 function(s): astroScriptsPostPlugin.
What does page-ssr.ts depend on?
page-ssr.ts imports 6 module(s): ../core/util.js, ../environments.js, ../types/astro.js, ./index.js, magic-string, vite.
Where is page-ssr.ts in the architecture?
page-ssr.ts is located at packages/astro/src/vite-plugin-scripts/page-ssr.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/astro/src/vite-plugin-scripts).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free