astro
Version:
Astro is a modern site builder with web best practices, performance, and DX front-of-mind.
32 lines (31 loc) • 995 B
JavaScript
import { getContentPaths, reloadContentConfigObserver } from "./utils.js";
/**
* Starts the content config load as early as possible during dev startup so its
* on-demand Vite compilation overlaps other startup work instead of blocking it.
*
* The types generator (`createContentTypesGenerator#init`) and the dev server
* app compile both dedupe on the same in-flight promise, so the config is
* compiled and evaluated exactly once per dev server instance.
*/
let inFlight;
export function getContentConfigLoadPromise() {
return inFlight;
}
export function kickOffContentConfigLoad({ settings, fs, logger, environment }) {
if (inFlight) {
return inFlight;
}
const contentPaths = getContentPaths(settings.config, fs, settings.config.legacy?.collectionsBackwardsCompat);
if (!contentPaths.config.exists) {
return Promise.resolve();
}
inFlight = reloadContentConfigObserver({
fs,
settings,
environment,
logger
}).finally(() => {
inFlight = undefined;
});
return inFlight;
}