withastro / adapters

Home for Astro's core maintained adapters
69 stars 41 forks source link

Cannot find module 'cloudflare:email' #441

Open scruffymongrel opened 1 day ago

scruffymongrel commented 1 day ago

Astro Info

Astro                    v4.16.12
Node                     v22.2.0
System                   macOS (arm64)
Package Manager          pnpm
Output                   hybrid
Adapter                  @astrojs/cloudflare
Integrations             @astrojs/tailwind

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

No response

Describe the Bug

I'm trying to import { EmailMessage } from 'cloudflare:email' in an Astro page.

Normally this kinda import would be used in Workers just fine, but Astro seems unable to do the magic...

When I request the page, I get the following stack trace:

Error: Failed to load url cloudflare:email (resolved id: cloudflare:email) in /REDACTED_PATH/src/pages/for/enterprise.astro. Does the file exist?
    at loadAndTransform (file:///REDACTED_PATH/node_modules/.pnpm/vite@5.4.11_@types+node@22.9.0/node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:51920:17)
    at async instantiateModule (file:///REDACTED_PATH/node_modules/.pnpm/vite@5.4.11_@types+node@22.9.0/node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:52874:44)

I'm using the following astro.config.js:

import { defineConfig } from 'astro/config'
import tailwind from '@astrojs/tailwind'

import cloudflare from '@astrojs/cloudflare'

export default defineConfig({
  adapter: cloudflare({
    imageService: 'passthrough',
    platformProxy: {
      enabled: true
    }
  }),
  integrations: [tailwind()],
  output: 'hybrid',
  vite: {
    ssr: {
      external: ['cloudflare:email']
    }
  }
})

What's the expected result?

I would like for the page to render without error.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-6doees

Participation

bluwy commented 23 hours ago

I don't think this is meant to be supported in dev, but maybe @alexanderniebuhr has a better idea of this.

alexanderniebuhr commented 22 hours ago

Yeah we don't have support for this in dev unless Cloudflare has a solution for local support?

bluwy commented 7 hours ago

Yeah I don't think Cloudflare provides local support for that. I wonder if it's worth providing a better error message when a cloudflare builtin is encountered, if not maybe we can close this.