Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/funny-planes-lick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/cloudflare': patch
---

Add prebundling config for internal Astro modules
1 change: 1 addition & 0 deletions packages/astro/src/manifest/serialized.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { VIRTUAL_PAGES_MODULE_ID } from '../vite-plugin-pages/index.js';
import { ASTRO_RENDERERS_MODULE_ID } from '../vite-plugin-renderers/index.js';
import { ASTRO_ROUTES_MODULE_ID } from '../vite-plugin-routes/index.js';

// This is used by Cloudflare optimizeDeps config
export const SERIALIZED_MANIFEST_ID = 'virtual:astro:manifest';
export const SERIALIZED_MANIFEST_RESOLVED_ID = '\0' + SERIALIZED_MANIFEST_ID;

Expand Down
1 change: 1 addition & 0 deletions packages/astro/src/toolbar/vite-plugin-dev-toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { telemetry } from '../events/index.js';
import { eventAppToggled } from '../events/toolbar.js';
import type { AstroPluginOptions } from '../types/astro.js';

// This is used by Cloudflare optimizeDeps config
const PRIVATE_VIRTUAL_MODULE_ID = 'astro:toolbar:internal';
const resolvedPrivateVirtualModuleId = '\0' + PRIVATE_VIRTUAL_MODULE_ID;

Expand Down
1 change: 1 addition & 0 deletions packages/astro/src/vite-plugin-adapter-config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Plugin as VitePlugin } from 'vite';
import type { AstroSettings } from '../types/astro.js';
import { isAstroServerEnvironment } from '../environments.js';

// This is used by Cloudflare's optimizeDeps
const VIRTUAL_CLIENT_ID = 'virtual:astro:adapter-config/client';
const RESOLVED_VIRTUAL_CLIENT_ID = '\0' + VIRTUAL_CLIENT_ID;

Expand Down
1 change: 1 addition & 0 deletions packages/astro/src/vite-plugin-css/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const MODULE_DEV_CSS = 'virtual:astro:dev-css';
const RESOLVED_MODULE_DEV_CSS = '\0' + MODULE_DEV_CSS;
const MODULE_DEV_CSS_PREFIX = 'virtual:astro:dev-css:';
const RESOLVED_MODULE_DEV_CSS_PREFIX = '\0' + MODULE_DEV_CSS_PREFIX;
// This is used by Cloudflare optimizeDeps config
const MODULE_DEV_CSS_ALL = 'virtual:astro:dev-css-all';
const RESOLVED_MODULE_DEV_CSS_ALL = '\0' + MODULE_DEV_CSS_ALL;
const ASTRO_CSS_EXTENSION_POST_PATTERN = '@_@';
Expand Down
13 changes: 13 additions & 0 deletions packages/integrations/cloudflare/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,27 @@ export default function createIntegration(args?: Options): AstroIntegration {
'astro > es-module-lexer',
'astro > unstorage',
'astro > neotraverse/modern',
'astro/app',
'astro/compiler-runtime',
],
exclude: [
'unstorage/drivers/cloudflare-kv-binding',
'astro:toolbar:internal',
'virtual:astro:middleware',
'virtual:astro:dev-css-all',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this support regexes? If so we could exclude all imports that start with virtual:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It supports tinyglob patterns so maybe. I'll try this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glob works, thanks for the idea!

'virtual:astro:manifest',
'virtual:astro:adapter-config/client',
'virtual:astro-cloudflare:config',
],
},
};
} else if (environmentName === 'client') {
return {
optimizeDeps: {
include: ['astro/runtime/client/dev-toolbar/entrypoint.js'],
exclude: ['astro:toolbar:internal'],
},
};
}
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default defineConfig({
SECRET: envField.string({ context: 'server', access: 'secret' }),
}
},
prefetch: true,
experimental: {
fonts: [{
provider: fontProviders.google(),
Expand Down
Loading