Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module 'cloudflare:email' #441

Open
1 task done
scruffymongrel opened this issue Nov 14, 2024 · 5 comments
Open
1 task done

Cannot find module 'cloudflare:email' #441

scruffymongrel opened this issue Nov 14, 2024 · 5 comments
Labels
needs triage Issue needs to be triaged

Comments

@scruffymongrel
Copy link

scruffymongrel commented Nov 14, 2024

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

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Nov 14, 2024
@bluwy bluwy transferred this issue from withastro/astro Nov 14, 2024
@bluwy
Copy link
Member

bluwy commented Nov 14, 2024

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

@alexanderniebuhr
Copy link
Member

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

@bluwy
Copy link
Member

bluwy commented Nov 15, 2024

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.

@alexanderniebuhr
Copy link
Member

As you can see in this table, email bindings are not support for local dev: https://developers.cloudflare.com/workers/testing/local-development/#supported-resource-bindings-in-different-environments

@scruffymongrel
Copy link
Author

scruffymongrel commented Nov 16, 2024

Aha, thanks for the link!

Does that mean I can expect import { EmailMessage } from 'cloudflare:email' to work in production (inside an Astro page)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

3 participants