dev.ts — astro Source File
Architecture documentation for dev.ts, a typescript file in the astro codebase. 18 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 84715425_98c7_454a_c767_8998ba6815e1["dev.ts"] b0d51698_8c9c_7a14_2fa8_0c688b058e22["../content/content-layer.js"] 84715425_98c7_454a_c767_8998ba6815e1 --> b0d51698_8c9c_7a14_2fa8_0c688b058e22 ca498ea5_adca_33b2_ab82_832064ec49f1["../../content/index.js"] 84715425_98c7_454a_c767_8998ba6815e1 --> ca498ea5_adca_33b2_ab82_832064ec49f1 f0d8d494_c471_39a6_5e1f_0ed356c4f6d8["../../content/mutable-data-store.js"] 84715425_98c7_454a_c767_8998ba6815e1 --> f0d8d494_c471_39a6_5e1f_0ed356c4f6d8 520c567a_b741_f105_70ac_c637eacc7f83["../content/utils.js"] 84715425_98c7_454a_c767_8998ba6815e1 --> 520c567a_b741_f105_70ac_c637eacc7f83 e62808d9_0c55_b3a9_00c0_ce588f164dab["../events/index.js"] 84715425_98c7_454a_c767_8998ba6815e1 --> e62808d9_0c55_b3a9_00c0_ce588f164dab c32d12e2_d85e_28c0_eea7_9b29629857e0["../types/public/config.js"] 84715425_98c7_454a_c767_8998ba6815e1 --> c32d12e2_d85e_28c0_eea7_9b29629857e0 8db17b08_b9e5_db7e_cd39_46be76c6d5ad["../core/messages.js"] 84715425_98c7_454a_c767_8998ba6815e1 --> 8db17b08_b9e5_db7e_cd39_46be76c6d5ad f68003f1_292f_ca44_03ce_21af87a33c7b["../core/util.js"] 84715425_98c7_454a_c767_8998ba6815e1 --> f68003f1_292f_ca44_03ce_21af87a33c7b 10961e7f_3879_b765_92f2_0a1e7b1d01b2["./container.js"] 84715425_98c7_454a_c767_8998ba6815e1 --> 10961e7f_3879_b765_92f2_0a1e7b1d01b2 70de8f8e_be8d_dcd0_7630_7f4e4eeb29af["./restart.js"] 84715425_98c7_454a_c767_8998ba6815e1 --> 70de8f8e_be8d_dcd0_7630_7f4e4eeb29af 54a8453f_4755_6134_1c92_ecc9a99f7d70["./update-check.js"] 84715425_98c7_454a_c767_8998ba6815e1 --> 54a8453f_4755_6134_1c92_ecc9a99f7d70 e16a223b_37f3_6b25_1ee1_2b7bcb9d9415["node:fs"] 84715425_98c7_454a_c767_8998ba6815e1 --> e16a223b_37f3_6b25_1ee1_2b7bcb9d9415 c2f6615e_96e9_c4eb_5f71_cf120e271705["node:http"] 84715425_98c7_454a_c767_8998ba6815e1 --> c2f6615e_96e9_c4eb_5f71_cf120e271705 155bd823_ceeb_ca16_2d83_f5ec72c22720["node:net"] 84715425_98c7_454a_c767_8998ba6815e1 --> 155bd823_ceeb_ca16_2d83_f5ec72c22720 style 84715425_98c7_454a_c767_8998ba6815e1 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import fs from 'node:fs';
import type http from 'node:http';
import type { AddressInfo } from 'node:net';
import { performance } from 'node:perf_hooks';
import colors from 'piccolore';
import { gt, major, minor, patch } from 'semver';
import type * as vite from 'vite';
import { getDataStoreFile, globalContentLayer } from '../../content/content-layer.js';
import { attachContentServerListeners } from '../../content/index.js';
import { MutableDataStore } from '../../content/mutable-data-store.js';
import { globalContentConfigObserver } from '../../content/utils.js';
import { telemetry } from '../../events/index.js';
import type { AstroInlineConfig } from '../../types/public/config.js';
import * as msg from '../messages.js';
import { ensureProcessNodeEnv } from '../util.js';
import { startContainer } from './container.js';
import { createContainerWithAutomaticRestart } from './restart.js';
import {
fetchLatestAstroVersion,
MAX_PATCH_DISTANCE,
shouldCheckForUpdates,
} from './update-check.js';
export interface DevServer {
address: AddressInfo;
handle: (req: http.IncomingMessage, res: http.ServerResponse<http.IncomingMessage>) => void;
watcher: vite.FSWatcher;
stop(): Promise<void>;
}
/**
* Runs Astro’s development server. This is a local HTTP server that doesn’t bundle assets.
* It uses Hot Module Replacement (HMR) to update your browser as you save changes in your editor.
*
* @experimental The JavaScript API is experimental
*/
export default async function dev(inlineConfig: AstroInlineConfig): Promise<DevServer> {
ensureProcessNodeEnv('development');
const devStart = performance.now();
await telemetry.record([]);
// Create a container which sets up the Vite server.
const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
const logger = restart.container.logger;
const currentVersion = process.env.PACKAGE_VERSION ?? '0.0.0';
const isPrerelease = currentVersion.includes('-');
if (!isPrerelease) {
try {
// Don't await this, we don't want to block the dev server from starting
shouldCheckForUpdates(restart.container.settings.preferences)
.then(async (shouldCheck) => {
if (shouldCheck) {
const version = await fetchLatestAstroVersion(restart.container.settings.preferences);
if (gt(version, currentVersion)) {
// Only update the latestAstroVersion if the latest version is greater than the current version, that way we don't need to check that again
// whenever we check for the latest version elsewhere
restart.container.settings.latestAstroVersion = version;
// ... (91 more lines)
Domain
Subdomains
Types
Dependencies
- ../../content/index.js
- ../../content/mutable-data-store.js
- ../content/content-layer.js
- ../content/utils.js
- ../core/messages.js
- ../core/util.js
- ../events/index.js
- ../types/public/config.js
- ./container.js
- ./restart.js
- ./update-check.js
- node:fs
- node:http
- node:net
- node:perf_hooks
- piccolore
- semver
- vite
Source
Frequently Asked Questions
What does dev.ts do?
dev.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 dev.ts?
dev.ts defines 2 function(s): dev, req.
What does dev.ts depend on?
dev.ts imports 18 module(s): ../../content/index.js, ../../content/mutable-data-store.js, ../content/content-layer.js, ../content/utils.js, ../core/messages.js, ../core/util.js, ../events/index.js, ../types/public/config.js, and 10 more.
Where is dev.ts in the architecture?
dev.ts is located at packages/astro/src/core/dev/dev.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