[PR #539] [MERGED] fix: merge top-level optimizeDeps with per-environment config #658

Closed
opened 2026-05-06 13:09:22 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/539
Author: @Jbithell
Created: 3/14/2026
Status: Merged
Merged: 3/16/2026
Merged by: @james-elicx

Base: mainHead: fix-optimizedeps-merging


📝 Commits (8)

  • 405669e fix: merge top-level optimizeDeps with per-environment config
  • d2de05f fix: merge top-level optimizeDeps with per-environment config
  • 03df101 docs: add PR description for optimizeDeps merge fix
  • fce927b chore: remove pr-description.md
  • e9e7471 fix: merge optimizeDeps for Pages Router + improve test coverage
  • 466a8ad Merge pull request #1 from Jbithell/claude/fix-optimizedeps-merging-jBbMW
  • f16102e fix: preserve optimizeDeps.include for Pages Router + fix formatting
  • b37f89d Merge pull request #2 from Jbithell/claude/fix-optimizedeps-merging-jBbMW

📊 Changes

2 files changed (+115 additions, -18 deletions)

View changed files

📝 packages/vinext/src/index.ts (+33 -17)
📝 tests/build-optimization.test.ts (+82 -1)

📄 Description

Summary

Fixes #538

vinext's config() hook was creating per-environment optimizeDeps objects from scratch, discarding any exclude or include entries that other Vite plugins (e.g. @lingui/vite-plugin) had added to the top-level config.optimizeDeps during their own config hooks.

This PR captures the incoming config.optimizeDeps.exclude and config.optimizeDeps.include arrays before building the per-environment configs, then merges them (with deduplication via Set) into each environment:

  • rsc: exclude now includes incoming excludes + ["vinext", "@vercel/og"]
  • ssr: exclude now includes incoming excludes + ["vinext", "@vercel/og"]
  • client: exclude now includes incoming excludes + ["vinext", "@vercel/og", ...serverExternalPackages]; include now includes incoming includes + React packages

Changes

  • packages/vinext/src/index.ts — Read config.optimizeDeps?.exclude and config.optimizeDeps?.include at the top of the environments block, then spread them into each environment's optimizeDeps using [...new Set([...incoming, ...vinextOwn])]
  • tests/build-optimization.test.ts — New test that passes optimizeDeps.exclude and optimizeDeps.include via the mock config (simulating an earlier plugin like @lingui/vite-plugin) and verifies those entries appear in all three environments alongside vinext's own entries

Test plan

  • New unit test: passes top-level optimizeDeps.exclude (@lingui/macro, @lingui/core/macro) and optimizeDeps.include (some-lib) via mock config, verifies they appear in rsc/ssr/client environments alongside vinext's own entries
  • Existing optimizeDeps.exclude tests still pass (66/66 in build-optimization.test.ts)
  • pnpm run fmt:check — passes
  • pnpm run lint — 0 warnings, 0 errors
  • pnpm run typecheck — passes

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/vinext/pull/539 **Author:** [@Jbithell](https://github.com/Jbithell) **Created:** 3/14/2026 **Status:** ✅ Merged **Merged:** 3/16/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `fix-optimizedeps-merging` --- ### 📝 Commits (8) - [`405669e`](https://github.com/cloudflare/vinext/commit/405669e505acad647478b2de5306d0ec82653ff3) fix: merge top-level optimizeDeps with per-environment config - [`d2de05f`](https://github.com/cloudflare/vinext/commit/d2de05fe4f33b0f1e9a8d9f0072b7cd49c74e0a7) fix: merge top-level optimizeDeps with per-environment config - [`03df101`](https://github.com/cloudflare/vinext/commit/03df1018b1404902ed035f91c700928e5090f675) docs: add PR description for optimizeDeps merge fix - [`fce927b`](https://github.com/cloudflare/vinext/commit/fce927bf84ac3ef74ce7f4dc1ffbf18ff8df727f) chore: remove pr-description.md - [`e9e7471`](https://github.com/cloudflare/vinext/commit/e9e74718862af9322ca99d1f4d2a1999c1a8c5c7) fix: merge optimizeDeps for Pages Router + improve test coverage - [`466a8ad`](https://github.com/cloudflare/vinext/commit/466a8ad0c31a25cc1fc87ffc82251ccfe49fdf3d) Merge pull request #1 from Jbithell/claude/fix-optimizedeps-merging-jBbMW - [`f16102e`](https://github.com/cloudflare/vinext/commit/f16102e5360946d32ed27660756db4d484bb2069) fix: preserve optimizeDeps.include for Pages Router + fix formatting - [`b37f89d`](https://github.com/cloudflare/vinext/commit/b37f89d1e7e40a7b8d0b8cffa1051950d402fc51) Merge pull request #2 from Jbithell/claude/fix-optimizedeps-merging-jBbMW ### 📊 Changes **2 files changed** (+115 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/index.ts` (+33 -17) 📝 `tests/build-optimization.test.ts` (+82 -1) </details> ### 📄 Description ## Summary Fixes #538 vinext's `config()` hook was creating per-environment `optimizeDeps` objects from scratch, discarding any `exclude` or `include` entries that other Vite plugins (e.g. `@lingui/vite-plugin`) had added to the top-level `config.optimizeDeps` during their own `config` hooks. This PR captures the incoming `config.optimizeDeps.exclude` and `config.optimizeDeps.include` arrays before building the per-environment configs, then merges them (with deduplication via `Set`) into each environment: - **rsc**: `exclude` now includes incoming excludes + `["vinext", "@vercel/og"]` - **ssr**: `exclude` now includes incoming excludes + `["vinext", "@vercel/og"]` - **client**: `exclude` now includes incoming excludes + `["vinext", "@vercel/og", ...serverExternalPackages]`; `include` now includes incoming includes + React packages ### Changes - `packages/vinext/src/index.ts` — Read `config.optimizeDeps?.exclude` and `config.optimizeDeps?.include` at the top of the environments block, then spread them into each environment's `optimizeDeps` using `[...new Set([...incoming, ...vinextOwn])]` - `tests/build-optimization.test.ts` — New test that passes `optimizeDeps.exclude` and `optimizeDeps.include` via the mock config (simulating an earlier plugin like `@lingui/vite-plugin`) and verifies those entries appear in all three environments alongside vinext's own entries ## Test plan - [x] New unit test: passes top-level `optimizeDeps.exclude` (`@lingui/macro`, `@lingui/core/macro`) and `optimizeDeps.include` (`some-lib`) via mock config, verifies they appear in rsc/ssr/client environments alongside vinext's own entries - [x] Existing `optimizeDeps.exclude` tests still pass (66/66 in `build-optimization.test.ts`) - [x] `pnpm run fmt:check` — passes - [x] `pnpm run lint` — 0 warnings, 0 errors - [x] `pnpm run typecheck` — passes --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:09:22 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#658
No description provided.