restart.ts — astro Source File
Architecture documentation for restart.ts, a typescript file in the astro codebase. 16 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 2daba797_7568_42ad_0193_df1cabafb75a["restart.ts"] b0d51698_8c9c_7a14_2fa8_0c688b058e22["../content/content-layer.js"] 2daba797_7568_42ad_0193_df1cabafb75a --> b0d51698_8c9c_7a14_2fa8_0c688b058e22 d2ca769d_b400_4c2d_117f_0c166781080a["../../content/server-listeners.js"] 2daba797_7568_42ad_0193_df1cabafb75a --> d2ca769d_b400_4c2d_117f_0c166781080a e62808d9_0c55_b3a9_00c0_ce588f164dab["../events/index.js"] 2daba797_7568_42ad_0193_df1cabafb75a --> e62808d9_0c55_b3a9_00c0_ce588f164dab da9bb8e1_9de1_7cb3_1c17_0e28541a8180["./constants.js"] 2daba797_7568_42ad_0193_df1cabafb75a --> da9bb8e1_9de1_7cb3_1c17_0e28541a8180 e9b74c5a_8d34_34a7_e196_5e41b87214aa["../types/astro.js"] 2daba797_7568_42ad_0193_df1cabafb75a --> e9b74c5a_8d34_34a7_e196_5e41b87214aa c32d12e2_d85e_28c0_eea7_9b29629857e0["../types/public/config.js"] 2daba797_7568_42ad_0193_df1cabafb75a --> c32d12e2_d85e_28c0_eea7_9b29629857e0 87f38a7c_f7a0_ed67_259c_0706f02399a6["../config/index.js"] 2daba797_7568_42ad_0193_df1cabafb75a --> 87f38a7c_f7a0_ed67_259c_0706f02399a6 cce3ff1b_1104_9b70_1982_a2d0a05516ee["../config/logging.js"] 2daba797_7568_42ad_0193_df1cabafb75a --> cce3ff1b_1104_9b70_1982_a2d0a05516ee 5c1f16d1_f599_2e31_eb17_4c8b8189d4ed["../errors/dev/utils.js"] 2daba797_7568_42ad_0193_df1cabafb75a --> 5c1f16d1_f599_2e31_eb17_4c8b8189d4ed dd6187d6_53c4_ce90_a1d1_3a0b5e7e7d3f["../../core/errors/errors.js"] 2daba797_7568_42ad_0193_df1cabafb75a --> dd6187d6_53c4_ce90_a1d1_3a0b5e7e7d3f ef8a1e3f_e350_75a6_b92d_62a8566d8db9["../core/errors/index.js"] 2daba797_7568_42ad_0193_df1cabafb75a --> ef8a1e3f_e350_75a6_b92d_62a8566d8db9 8db17b08_b9e5_db7e_cd39_46be76c6d5ad["../core/messages.js"] 2daba797_7568_42ad_0193_df1cabafb75a --> 8db17b08_b9e5_db7e_cd39_46be76c6d5ad 10961e7f_3879_b765_92f2_0a1e7b1d01b2["./container.js"] 2daba797_7568_42ad_0193_df1cabafb75a --> 10961e7f_3879_b765_92f2_0a1e7b1d01b2 e16a223b_37f3_6b25_1ee1_2b7bcb9d9415["node:fs"] 2daba797_7568_42ad_0193_df1cabafb75a --> e16a223b_37f3_6b25_1ee1_2b7bcb9d9415 style 2daba797_7568_42ad_0193_df1cabafb75a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import type nodeFs from 'node:fs';
import { fileURLToPath } from 'node:url';
import * as vite from 'vite';
import { globalContentLayer } from '../../content/content-layer.js';
import { attachContentServerListeners } from '../../content/server-listeners.js';
import { eventCliSession, telemetry } from '../../events/index.js';
import { SETTINGS_FILE } from '../../preferences/constants.js';
import type { AstroSettings } from '../../types/astro.js';
import type { AstroInlineConfig } from '../../types/public/config.js';
import { createSettings, resolveConfig } from '../config/index.js';
import { createNodeLogger } from '../config/logging.js';
import { collectErrorMetadata } from '../errors/dev/utils.js';
import { isAstroConfigZodError } from '../errors/errors.js';
import { createSafeError } from '../errors/index.js';
import { formatErrorMessage } from '../messages.js';
import type { Container } from './container.js';
import { createContainer, startContainer } from './container.js';
async function createRestartedContainer(
container: Container,
settings: AstroSettings,
): Promise<Container> {
const { logger, fs, inlineConfig } = container;
const newContainer = await createContainer({
isRestart: true,
logger: logger,
settings,
inlineConfig,
fs,
});
await startContainer(newContainer);
return newContainer;
}
const configRE = /.*astro.config.(?:mjs|mts|cjs|cts|js|ts)$/;
function shouldRestartContainer(
{ settings, inlineConfig, restartInFlight }: Container,
changedFile: string,
): boolean {
if (restartInFlight) return false;
let shouldRestart = false;
const normalizedChangedFile = vite.normalizePath(changedFile);
// If the config file changed, reload the config and restart the server.
if (inlineConfig.configFile) {
shouldRestart = vite.normalizePath(inlineConfig.configFile) === normalizedChangedFile;
}
// Otherwise, watch for any astro.config.* file changes in project root
else {
shouldRestart = configRE.test(normalizedChangedFile);
const settingsPath = vite.normalizePath(
fileURLToPath(new URL(SETTINGS_FILE, settings.dotAstroDir)),
);
if (settingsPath.endsWith(normalizedChangedFile)) {
shouldRestart = settings.preferences.ignoreNextPreferenceReload ? false : true;
// ... (177 more lines)
Domain
Subdomains
Functions
Dependencies
- ../../content/server-listeners.js
- ../../core/errors/errors.js
- ../config/index.js
- ../config/logging.js
- ../content/content-layer.js
- ../core/errors/index.js
- ../core/messages.js
- ../errors/dev/utils.js
- ../events/index.js
- ../types/astro.js
- ../types/public/config.js
- ./constants.js
- ./container.js
- node:fs
- node:url
- vite
Source
Frequently Asked Questions
What does restart.ts do?
restart.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, CoreMiddleware subdomain.
What functions are defined in restart.ts?
restart.ts defines 5 function(s): Promise, createContainerWithAutomaticRestart, createRestartedContainer, restartContainer, shouldRestartContainer.
What does restart.ts depend on?
restart.ts imports 16 module(s): ../../content/server-listeners.js, ../../core/errors/errors.js, ../config/index.js, ../config/logging.js, ../content/content-layer.js, ../core/errors/index.js, ../core/messages.js, ../errors/dev/utils.js, and 8 more.
Where is restart.ts in the architecture?
restart.ts is located at packages/astro/src/core/dev/restart.ts (domain: CoreAstro, subdomain: CoreMiddleware, directory: packages/astro/src/core/dev).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free