index.ts — astro Source File
Architecture documentation for index.ts, a typescript file in the astro codebase. 4 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR d009c751_7ea8_ae9f_d4e0_89a219f6f7da["index.ts"] 7216d952_4e4a_2d18_a85b_74b4ace79e2b["../core/constants.js"] d009c751_7ea8_ae9f_d4e0_89a219f6f7da --> 7216d952_4e4a_2d18_a85b_74b4ace79e2b c0c8a87f_ca88_4ea8_585b_2040cded1231["./const.js"] d009c751_7ea8_ae9f_d4e0_89a219f6f7da --> c0c8a87f_ca88_4ea8_585b_2040cded1231 86f9753f_24b2_59d0_0895_2be6cf7b0b20["../vite-plugin-css/util.js"] d009c751_7ea8_ae9f_d4e0_89a219f6f7da --> 86f9753f_24b2_59d0_0895_2be6cf7b0b20 263e522e_1aa5_ebc3_e7d6_45ebc51671f7["vite"] d009c751_7ea8_ae9f_d4e0_89a219f6f7da --> 263e522e_1aa5_ebc3_e7d6_45ebc51671f7 style d009c751_7ea8_ae9f_d4e0_89a219f6f7da fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import type { EnvironmentModuleNode, Plugin } from 'vite';
import { ASTRO_VITE_ENVIRONMENT_NAMES } from '../core/constants.js';
import { VIRTUAL_PAGE_RESOLVED_MODULE_ID } from '../vite-plugin-pages/const.js';
import { getDevCssModuleNameFromPageVirtualModuleName } from '../vite-plugin-css/util.js';
/**
* The very last Vite plugin to reload the browser if any SSR-only module are updated
* which will require a full page reload. This mimics the behaviour of Vite 5 where
* it used to unconditionally reload for us.
*/
export default function hmrReload(): Plugin {
return {
name: 'astro:hmr-reload',
enforce: 'post',
hotUpdate: {
order: 'post',
handler({ modules, server, timestamp }) {
if (this.environment.name !== ASTRO_VITE_ENVIRONMENT_NAMES.ssr) return;
let hasSsrOnlyModules = false;
const invalidatedModules = new Set<EnvironmentModuleNode>();
for (const mod of modules) {
if (mod.id == null) continue;
const clientModule = server.environments.client.moduleGraph.getModuleById(mod.id);
if (clientModule != null) continue;
this.environment.moduleGraph.invalidateModule(mod, invalidatedModules, timestamp, true);
hasSsrOnlyModules = true;
}
// If any invalidated modules are virtual modules for pages, also invalidate their
// associated dev CSS modules, if any.
for (const invalidatedModule of invalidatedModules) {
if (invalidatedModule.id?.startsWith(VIRTUAL_PAGE_RESOLVED_MODULE_ID)) {
const cssMod = this.environment.moduleGraph.getModuleById(
getDevCssModuleNameFromPageVirtualModuleName(invalidatedModule.id),
);
if (!cssMod || cssMod.id == null) continue;
this.environment.moduleGraph.invalidateModule(cssMod, undefined, timestamp, true);
}
}
if (hasSsrOnlyModules) {
server.ws.send({ type: 'full-reload' });
return [];
}
},
},
};
}
Domain
Subdomains
Functions
Dependencies
- ../core/constants.js
- ../vite-plugin-css/util.js
- ./const.js
- 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 1 function(s): hmrReload.
What does index.ts depend on?
index.ts imports 4 module(s): ../core/constants.js, ../vite-plugin-css/util.js, ./const.js, vite.
Where is index.ts in the architecture?
index.ts is located at packages/astro/src/vite-plugin-hmr-reload/index.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/astro/src/vite-plugin-hmr-reload).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free