Skip to content

fix(cloudflare): forward user optimizeDeps to SSR/prerender environments#16601

Open
maximslo wants to merge 5 commits intowithastro:mainfrom
maximslo:fix/cloudflare-user-optimizedeps-ssr
Open

fix(cloudflare): forward user optimizeDeps to SSR/prerender environments#16601
maximslo wants to merge 5 commits intowithastro:mainfrom
maximslo:fix/cloudflare-user-optimizedeps-ssr

Conversation

@maximslo
Copy link
Copy Markdown
Contributor

@maximslo maximslo commented May 5, 2026

Fixes #16491

Context: In Vite 6, top-level vite.optimizeDeps only applies to the client environment. The Cloudflare adapter owns SSR/prerender dep optimization via its configEnvironment hook, so user-configured optimizeDeps.exclude and optimizeDeps.esbuildOptions.loader were silently ignored for server environments.

Changes

  • Fix: capture the user's config.vite.optimizeDeps in astro:config:setup and merge it into the adapter's configEnvironment return value for server environments.
  • Added integration test: (test/custom-loader.test.ts) with a fixture containing a fake package that imports a .data file, reproduces the esbuild "No loader is configured for .data files" error when the fix is absent.
  • Extended test/ssr-deps.test.ts with a dynamically-created fake-data-pkg that imports a .data file, reproduces the esbuild "No loader is configured for .data files" error when the fix is absent.

Testing

  1. Run NODE_OPTIONS="--experimental-strip-types --no-warnings" pnpm test in packages/integrations/cloudflare.
  2. If the new test fails locally with a miniflare compatibility date error, that is a pre-existing local env issue (same as ssr-deps.test.ts) CI is the source of truth

Docs

Fix doesn't introduce any new config options or change any public API. No docs update needed.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 5, 2026

🦋 Changeset detected

Latest commit: 414a4a6

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added the pkg: integration Related to any renderer integration (scope) label May 5, 2026
maximslo and others added 4 commits May 5, 2026 00:06
Remove duplicate AstroLogger block that was left over from the merge
conflict; keep only the createLogger approach from main so biome lint
no longer flags logger as unused.
@maximslo maximslo force-pushed the fix/cloudflare-user-optimizedeps-ssr branch from c20bc8e to 414a4a6 Compare May 5, 2026 04:55
@maximslo maximslo marked this pull request as ready for review May 5, 2026 05:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: integration Related to any renderer integration (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Astro is unable to load .data and .wasm file

1 participant