revert content import loading
This commit is contained in:
parent
17cc8bdeab
commit
21cac83013
1 changed files with 7 additions and 23 deletions
|
@ -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,29 +39,13 @@ 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
|
||||
// to the error overlay in development
|
||||
|
|
Loading…
Reference in a new issue