diff --git a/.changeset/good-rivers-add.md b/.changeset/good-rivers-add.md new file mode 100644 index 00000000..24fb7204 --- /dev/null +++ b/.changeset/good-rivers-add.md @@ -0,0 +1,5 @@ +--- +'@astrojs/cloudflare': patch +--- + +Fixes an issue where `cloudflare:` scoped imports made the build fail. We externalize all imports with the `cloudflare:` scope by default now. diff --git a/packages/cloudflare/src/index.ts b/packages/cloudflare/src/index.ts index 718fac02..4facef32 100644 --- a/packages/cloudflare/src/index.ts +++ b/packages/cloudflare/src/index.ts @@ -129,6 +129,16 @@ export default function createIntegration(args?: Options): AstroIntegration { // https://developers.cloudflare.com/pages/functions/module-support/ // Allows imports of '.wasm', '.bin', and '.txt' file types cloudflareModulePlugin, + { + name: 'vite:cf-imports', + enforce: 'pre', + resolveId(source) { + if (source.startsWith('cloudflare:')) { + return { id: source, external: true }; + } + return null; + }, + }, ], }, integrations: [astroWhen()],