createContainer() — astro Function Reference
Architecture documentation for the createContainer() function in container.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD a846ef56_ac96_e5d5_61e4_dcaba65422f8["createContainer()"] 102fe931_c243_3ea6_cd7a_6811d0d43c9e["container.ts"] a846ef56_ac96_e5d5_61e4_dcaba65422f8 -->|defined in| 102fe931_c243_3ea6_cd7a_6811d0d43c9e f935825f_d96c_bb53_6318_c51c5e9340cf["closeContainer()"] a846ef56_ac96_e5d5_61e4_dcaba65422f8 -->|calls| f935825f_d96c_bb53_6318_c51c5e9340cf style a846ef56_ac96_e5d5_61e4_dcaba65422f8 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/core/dev/container.ts lines 38–146
export async function createContainer({
isRestart = false,
logger,
inlineConfig,
settings,
fs = nodeFs,
}: CreateContainerParams): Promise<Container> {
// Initialize
settings = await runHookConfigSetup({
settings,
command: 'dev',
logger: logger,
isRestart,
});
const {
base,
server: { host, headers, open: serverOpen, allowedHosts },
} = settings.config;
// serverOpen = true, isRestart = false
// when astro dev --open command is run the first time
// expected behavior: spawn a new tab
// ------------------------------------------------------
// serverOpen = true, isRestart = true
// when config file is saved
// expected behavior: do not spawn a new tab
// ------------------------------------------------------
// Non-config files don't reach this point
const isServerOpenURL = typeof serverOpen == 'string' && !isRestart;
const isServerOpenBoolean = serverOpen && !isRestart;
// Open server to the correct path. We pass the `base` here as we didn't pass the
// base to the initial Vite config
const open = isServerOpenURL ? serverOpen : isServerOpenBoolean ? base : false;
// The client entrypoint for renderers. Since these are imported dynamically
// we need to tell Vite to preoptimize them.
const rendererClientEntries = settings.renderers
.map((r) => r.clientEntrypoint)
.filter(Boolean) as string[];
// Create the route manifest already outside of Vite so that `runHookConfigDone` can use it to inform integrations of the build output
await runHookConfigDone({ settings, logger, command: 'dev' });
warnMissingAdapter(logger, settings);
const mode = inlineConfig?.mode ?? 'development';
const initialRoutesList = await createRoutesList(
{
settings,
fsMod: nodeFs,
},
logger,
{
dev: true,
// If the adapter explicitly set a buildOutput, don't override it
skipBuildOutputAssignment: !!settings.adapter?.adapterFeatures?.buildOutput,
},
);
const viteConfig = await createVite(
{
server: { host, headers, open, allowedHosts },
optimizeDeps: {
include: rendererClientEntries,
},
},
{
settings,
logger,
mode,
command: 'dev',
fs,
sync: false,
routesList: initialRoutesList,
},
);
const viteServer = await vite.createServer(viteConfig);
await syncInternal({
settings,
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does createContainer() do?
createContainer() is a function in the astro codebase, defined in packages/astro/src/core/dev/container.ts.
Where is createContainer() defined?
createContainer() is defined in packages/astro/src/core/dev/container.ts at line 38.
What does createContainer() call?
createContainer() calls 1 function(s): closeContainer.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free