diff options
author | 2024-10-31 16:43:11 +0800 | |
---|---|---|
committer | 2024-10-31 16:43:11 +0800 | |
commit | d62c52b5a50d58bc87727cbbc0d36f9c04c4dc30 (patch) | |
tree | 57ec268fb0a649b93398ac764975a50879bf9c08 /packages/integrations/cloudflare/src | |
parent | f5f9f98696b2e1bd7726be342bcc1cd31978c600 (diff) | |
parent | de435909d36699fadd6f0cbb3d95c49308556fb0 (diff) | |
download | astro-d62c52b5a50d58bc87727cbbc0d36f9c04c4dc30.tar.gz astro-d62c52b5a50d58bc87727cbbc0d36f9c04c4dc30.tar.zst astro-d62c52b5a50d58bc87727cbbc0d36f9c04c4dc30.zip |
Merge branch 'main' into next
Diffstat (limited to 'packages/integrations/cloudflare/src')
-rw-r--r-- | packages/integrations/cloudflare/src/index.ts | 10 | ||||
-rw-r--r-- | packages/integrations/cloudflare/src/utils/generate-routes-json.ts | 10 |
2 files changed, 15 insertions, 5 deletions
diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index c2b2f2de0..0acd86fd8 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/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()], diff --git a/packages/integrations/cloudflare/src/utils/generate-routes-json.ts b/packages/integrations/cloudflare/src/utils/generate-routes-json.ts index 43adeb675..3d7f8a643 100644 --- a/packages/integrations/cloudflare/src/utils/generate-routes-json.ts +++ b/packages/integrations/cloudflare/src/utils/generate-routes-json.ts @@ -225,6 +225,7 @@ export async function createRoutesFile( const convertedPath = segmentsToCfSyntax(route.segments, _config); if (route.pathname === '/404' && route.prerender === true) hasPrerendered404 = true; + // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check switch (route.type) { case 'page': if (route.prerender === false) includePaths.push(convertedPath); @@ -307,11 +308,10 @@ export async function createRoutesFile( const EXTENDED_EXCLUDE_RULES_COUNT = excludeExtends?.length ?? 0; const EXCLUDE_RULES_COUNT = AUTOMATIC_EXCLUDE_RULES_COUNT + EXTENDED_EXCLUDE_RULES_COUNT; - if ( - !hasPrerendered404 || - INCLUDE_RULES_COUNT > CLOUDFLARE_COMBINED_LIMIT || - EXCLUDE_RULES_COUNT > CLOUDFLARE_COMBINED_LIMIT - ) { + const OPTION2_TOTAL_COUNT = + INCLUDE_RULES_COUNT + (includedPathsHaveWildcard ? EXCLUDE_RULES_COUNT : 0); + + if (!hasPrerendered404 || OPTION2_TOTAL_COUNT > CLOUDFLARE_COMBINED_LIMIT) { await writeRoutesFileToOutDir( _config, logger, |