Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/petite-rockets-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fixes a case where an error would not be thrown when using the `<Font />` component from the experimental fonts API without adding fonts in the Astro config
8 changes: 5 additions & 3 deletions packages/astro/components/Font.astro
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
---
import { AstroError, AstroErrorData } from '../dist/core/errors/index.js';
import * as mod from 'virtual:astro:assets/fonts/internal';

// TODO: remove dynamic import when fonts are stabilized
const { fontsData } = await import('virtual:astro:assets/fonts/internal').catch(() => {
// TODO: remove check when fonts are stabilized
const { fontsData } = mod;
if (!fontsData) {
throw new AstroError(AstroErrorData.ExperimentalFontsNotEnabled);
});
}

interface Props {
/** The `cssVariable` registered in your Astro configuration. */
Expand Down