From 21cac83013de70ce7aefbd02ef2e98cf0cff87dc Mon Sep 17 00:00:00 2001 From: bholmesdev Date: Mon, 6 Mar 2023 16:13:48 -0500 Subject: [PATCH] revert content import loading --- .../content/vite-plugin-content-imports.ts | 30 +++++-------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/packages/astro/src/content/vite-plugin-content-imports.ts b/packages/astro/src/content/vite-plugin-content-imports.ts index 5b70dd5dd..d8075a1a1 100644 --- a/packages/astro/src/content/vite-plugin-content-imports.ts +++ b/packages/astro/src/content/vite-plugin-content-imports.ts @@ -3,7 +3,8 @@ import type fsMod from 'node:fs'; import { pathToFileURL } from 'url'; import type { Plugin } from 'vite'; import { AstroSettings } from '../@types/astro.js'; -import { AstroError, AstroErrorData } from '../core/errors/index.js'; +import { AstroErrorData } from '../core/errors/errors-data.js'; +import { AstroError } from '../core/errors/errors.js'; import { escapeViteEnvReferences, getFileInfo } from '../vite-plugin-utils/index.js'; import { contentFileExts, CONTENT_FLAG } from './consts.js'; import { @@ -14,7 +15,6 @@ import { getEntrySlug, getEntryType, globalContentConfigObserver, - loadContentConfig, parseFrontmatter, } from './utils.js'; @@ -39,28 +39,12 @@ export function astroContentImportPlugin({ if (isContentFlagImport(id)) { const observable = globalContentConfigObserver.get(); - // Content config is stored globally, - // and can get blown away if Node invalidates the module. - // This was discovered in CI when using Docker. - // Reimport the config in this case. + // Content config should be loaded before this plugin is used if (observable.status === 'init') { - globalContentConfigObserver.set({ status: 'loading' }); - try { - const config = await loadContentConfig({ fs, settings, viteServer }); - if (config) { - globalContentConfigObserver.set({ status: 'loaded', config }); - } else { - globalContentConfigObserver.set({ status: 'does-not-exist' }); - } - } catch (e) { - globalContentConfigObserver.set({ - status: 'error', - error: - e instanceof Error - ? e - : new AstroError(AstroErrorData.UnknownContentCollectionError), - }); - } + throw new AstroError({ + ...AstroErrorData.UnknownContentCollectionError, + message: 'Content config failed to load.', + }); } if (observable.status === 'error') { // Throw here to bubble content config errors