serializedManifestPlugin() — astro Function Reference
Architecture documentation for the serializedManifestPlugin() function in serialized.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 190e75c9_54aa_2bba_2eb7_7de138acf04a["serializedManifestPlugin()"] bb258207_6489_88c4_0ed3_a25dbb4adf47["serialized.ts"] 190e75c9_54aa_2bba_2eb7_7de138acf04a -->|defined in| bb258207_6489_88c4_0ed3_a25dbb4adf47 ca4d46ba_52db_5fb0_8f4d_2658c4aa3c9c["createSerializedManifest()"] 190e75c9_54aa_2bba_2eb7_7de138acf04a -->|calls| ca4d46ba_52db_5fb0_8f4d_2658c4aa3c9c style 190e75c9_54aa_2bba_2eb7_7de138acf04a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/manifest/serialized.ts lines 32–112
export function serializedManifestPlugin({
settings,
command,
sync,
}: {
settings: AstroSettings;
command: 'dev' | 'build';
sync: boolean;
}): Plugin {
function reloadManifest(path: string | null, server: ViteDevServer) {
if (path != null && path.startsWith(settings.config.srcDir.pathname)) {
const environment = server.environments[ASTRO_VITE_ENVIRONMENT_NAMES.ssr];
const virtualMod = environment.moduleGraph.getModuleById(SERIALIZED_MANIFEST_RESOLVED_ID);
if (!virtualMod) return;
environment.moduleGraph.invalidateModule(virtualMod);
}
}
return {
name: SERIALIZED_MANIFEST_ID,
enforce: 'pre',
configureServer(server) {
server.watcher.on('add', (path) => reloadManifest(path, server));
server.watcher.on('unlink', (path) => reloadManifest(path, server));
server.watcher.on('change', (path) => reloadManifest(path, server));
},
resolveId: {
filter: {
id: new RegExp(`^${SERIALIZED_MANIFEST_ID}$`),
},
handler() {
return SERIALIZED_MANIFEST_RESOLVED_ID;
},
},
load: {
filter: {
id: new RegExp(`^${SERIALIZED_MANIFEST_RESOLVED_ID}$`),
},
async handler() {
let manifestData: string;
if (command === 'build' && !sync) {
// Emit placeholder token that will be replaced by plugin-manifest.ts in build:post
// See plugin-manifest.ts for full architecture explanation
manifestData = `'${MANIFEST_REPLACE}'`;
} else {
const serialized = await createSerializedManifest(settings);
manifestData = JSON.stringify(serialized);
}
const code = `
import { deserializeManifest as _deserializeManifest } from 'astro/app';
import { renderers } from '${ASTRO_RENDERERS_MODULE_ID}';
import { routes } from '${ASTRO_ROUTES_MODULE_ID}';
import { pageMap } from '${VIRTUAL_PAGES_MODULE_ID}';
const _manifest = _deserializeManifest((${manifestData}));
// _manifest.routes contains enriched route info with scripts and styles,
// TODO port this info over to virtual:astro:routes to prevent the need to
// have this duplication
const isDev = ${JSON.stringify(command === 'dev')};
const manifestRoutes = isDev ? routes : _manifest.routes;
const manifest = Object.assign(_manifest, {
renderers,
actions: () => import('${ACTIONS_ENTRYPOINT_VIRTUAL_MODULE_ID}'),
middleware: () => import('${MIDDLEWARE_MODULE_ID}'),
sessionDriver: () => import('${VIRTUAL_SESSION_DRIVER_ID}'),
serverIslandMappings: () => import('${SERVER_ISLAND_MANIFEST}'),
routes: manifestRoutes,
pageMap,
});
export { manifest };
`;
return { code };
},
},
};
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does serializedManifestPlugin() do?
serializedManifestPlugin() is a function in the astro codebase, defined in packages/astro/src/manifest/serialized.ts.
Where is serializedManifestPlugin() defined?
serializedManifestPlugin() is defined in packages/astro/src/manifest/serialized.ts at line 32.
What does serializedManifestPlugin() call?
serializedManifestPlugin() calls 1 function(s): createSerializedManifest.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free