hmrReload() — astro Function Reference
Architecture documentation for the hmrReload() function in index.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD c2d57757_e44c_044b_85e4_8b6a901e1405["hmrReload()"] d009c751_7ea8_ae9f_d4e0_89a219f6f7da["index.ts"] c2d57757_e44c_044b_85e4_8b6a901e1405 -->|defined in| d009c751_7ea8_ae9f_d4e0_89a219f6f7da style c2d57757_e44c_044b_85e4_8b6a901e1405 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/vite-plugin-hmr-reload/index.ts lines 11–51
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
Source
Frequently Asked Questions
What does hmrReload() do?
hmrReload() is a function in the astro codebase, defined in packages/astro/src/vite-plugin-hmr-reload/index.ts.
Where is hmrReload() defined?
hmrReload() is defined in packages/astro/src/vite-plugin-hmr-reload/index.ts at line 11.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free