Skip to content

Astro Fonts + Astro DB causing build errors when building for Cloudflare #14933

@herbsoftware

Description

@herbsoftware

Astro Info

Astro v5.16.2
Node v22.x
Adapter: @astrojs/[email protected] (output: "server")
Integration: @astrojs/[email protected] (mode: web)
Package manager: pnpm

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

Enabling experimental.fonts while using @astrojs/db with the Cloudflare adapter causes the build to fail during the astro:build:setup hook because source-map-js is required in a worker-like SSR context (require is not defined). Disabling fonts or removing @astrojs/db makes the build succeed.

Steps to reproduce

  1. pnpm create astro@latest fonts-db-cloudflare-repro --template basics && cd fonts-db-cloudflare-repro
  2. pnpm add [email protected] @astrojs/[email protected] @astrojs/[email protected]
  3. Update astro.config.mjs to:
import cloudflare from '@astrojs/cloudflare';
import db from '@astrojs/db';
import { defineConfig, fontProviders } from 'astro/config';

const fonts = [
  {
    provider: fontProviders.google(),
    name: 'Doto',
    cssVariable: '--font-title',
    subsets: ['latin'],
  },
];

export default defineConfig({
  output: 'server',
  adapter: cloudflare({ imageService: 'compile' }),
  integrations: [db({ mode: 'web' })],
  experimental: { fonts },
});

What's the expected result?

Build should succeed.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-bswzo7fm

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions