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 { pathToFileURL } from 'url';
|
||||||
import type { Plugin } from 'vite';
|
import type { Plugin } from 'vite';
|
||||||
import { AstroSettings } from '../@types/astro.js';
|
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 { escapeViteEnvReferences, getFileInfo } from '../vite-plugin-utils/index.js';
|
||||||
import { contentFileExts, CONTENT_FLAG } from './consts.js';
|
import { contentFileExts, CONTENT_FLAG } from './consts.js';
|
||||||
import {
|
import {
|
||||||
|
@ -14,7 +15,6 @@ import {
|
||||||
getEntrySlug,
|
getEntrySlug,
|
||||||
getEntryType,
|
getEntryType,
|
||||||
globalContentConfigObserver,
|
globalContentConfigObserver,
|
||||||
loadContentConfig,
|
|
||||||
parseFrontmatter,
|
parseFrontmatter,
|
||||||
} from './utils.js';
|
} from './utils.js';
|
||||||
|
|
||||||
|
@ -39,28 +39,12 @@ export function astroContentImportPlugin({
|
||||||
if (isContentFlagImport(id)) {
|
if (isContentFlagImport(id)) {
|
||||||
const observable = globalContentConfigObserver.get();
|
const observable = globalContentConfigObserver.get();
|
||||||
|
|
||||||
// Content config is stored globally,
|
// Content config should be loaded before this plugin is used
|
||||||
// and can get blown away if Node invalidates the module.
|
|
||||||
// This was discovered in CI when using Docker.
|
|
||||||
// Reimport the config in this case.
|
|
||||||
if (observable.status === 'init') {
|
if (observable.status === 'init') {
|
||||||
globalContentConfigObserver.set({ status: 'loading' });
|
throw new AstroError({
|
||||||
try {
|
...AstroErrorData.UnknownContentCollectionError,
|
||||||
const config = await loadContentConfig({ fs, settings, viteServer });
|
message: 'Content config failed to load.',
|
||||||
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),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (observable.status === 'error') {
|
if (observable.status === 'error') {
|
||||||
// Throw here to bubble content config errors
|
// Throw here to bubble content config errors
|
||||||
|
|
Loading…
Reference in a new issue