Repository: withastro/astro
File: packages/integrations/cloudflare/src/index.ts (TypeScript)

Code before:
					addWatchFile(new URL('./wrangler.jsonc', config.root));
				}
				addMiddleware({
					entrypoint: '@astrojs/cloudflare/entrypoints/middleware.js',
					order: 'pre',
				});
			},
			'astro:routes:resolved': ({ routes }) => {
				_routes = routes;
			},
			'astro:config:done': ({ setAdapter, config, buildOutput, logger }) => {
				if (buildOutput === 'static') {
					logger.warn(
						'[@astrojs/cloudflare] This adapter is intended to be used with server rendered pages, which this project does not contain any of. As such, this adapter is unnecessary.',
					);
				}

				_config = config;
				finalBuildOutput = buildOutput;

				setAdapter({
					name: '@astrojs/cloudflare',
					serverEntrypoint: args?.entryfilePath
						? new URL(args?.entryfilePath, config.root)
						: '@astrojs/cloudflare/entrypoints/server.js',
					exports: args?.entryfileExports ? ['default', ...args.entryfileExports] : ['default'],
					adapterFeatures: {
						edgeMiddleware: false,
						buildOutput: 'server',
					},
					supportedAstroFeatures: {
						serverOutput: 'stable',
						hybridOutput: 'stable',
						staticOutput: 'unsupported',
						i18nDomains: 'experimental',
						sharpImageService: {
							support: 'limited',
							message:
								'Cloudflare does not support sharp. You can use the `compile` image service to compile images at build time. It will not work for any on-demand rendered images.',
						},
						envGetSecret: 'stable',
					},
				});
			},
			'astro:server:setup': async ({ server }) => {
				if ((args?.platformProxy?.enabled ?? true) === true) {
					const platformProxy = await getPlatformProxy(args?.platformProxy);

					setProcessEnv(_config, platformProxy.env);

					const clientLocalsSymbol = Symbol.for('astro.locals');

Review comment (bug):
I believe there's a bug in the current configuration. What would happen if users provide **only** `entryfileExports` **without providing** `entryfilePath`? Is it a bug? 

I believe custom exports should be used **only** if there's a custom entry file path. 

Code after:
									if (source.startsWith('cloudflare:')) {
										return { id: source, external: true };
									}
									return null;
								},
							},
						],
					},
					image: setImageConfig(args?.imageService ?? 'compile', config.image, command, logger),
				});
				if (args?.platformProxy?.configPath) {
					addWatchFile(new URL(args.platformProxy.configPath, config.root));
				} else {
					addWatchFile(new URL('./wrangler.toml', config.root));
					addWatchFile(new URL('./wrangler.json', config.root));
					addWatchFile(new URL('./wrangler.jsonc', config.root));
				}
				addMiddleware({
					entrypoint: '@astrojs/cloudflare/entrypoints/middleware.js',
					order: 'pre',
				});
			},
			'astro:routes:resolved': ({ routes }) => {
				_routes = routes;
			},
			'astro:config:done': ({ setAdapter, config, buildOutput, logger }) => {
				if (buildOutput === 'static') {
					logger.warn(
						'[@astrojs/cloudflare] This adapter is intended to be used with server rendered pages, which this project does not contain any of. As such, this adapter is unnecessary.',
					);
				}

				_config = config;
				finalBuildOutput = buildOutput;

				let customWorkerEntryPoint: URL | undefined;
				if (args?.workerEntryPoint && typeof args.workerEntryPoint.path === 'string') {
					const require = createRequire(config.root);
					try {
						customWorkerEntryPoint = pathToFileURL(require.resolve(args.workerEntryPoint.path));
					} catch {
						customWorkerEntryPoint = new URL(args.workerEntryPoint.path, config.root);
					}
				}

				setAdapter({
					name: '@astrojs/cloudflare',
					serverEntrypoint: customWorkerEntryPoint ?? '@astrojs/cloudflare/entrypoints/server.js',
					exports: args?.workerEntryPoint?.namedExports
						? ['default', ...args.workerEntryPoint.namedExports]
						: ['default'],