Repository navigation
fix(dev_server): keep workspace members out of the SSR dep optimizer - #370
Merged
Merged
Conversation
Vite applies the top-level optimizeDeps to the client environment only, so the ssr environment and worker environments still pre-bundled workspace members and plugin transforms never ran on them. The member-sources plugin now adds the member exclude list to every non-client environment through configEnvironment, which merges with a consumer's own list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A workspace member imported from server-side code still gets pre-bundled by the
ssr(or a worker) environment's dep optimizer, so plugin transforms such as StyleX never run on it and the server render breaks at runtime.ts_dev_serverconfig's member-sources plugin adds the member exclude list to every non-client environment through Vite'sconfigEnvironmenthook. The top-leveloptimizeDeps.excludestays for the client.ssrand a worker environment, the SSR transform of an entry importing a member pointed atvite-cache/deps_ssr/shared.jsanddeps_worker/shared.jsbefore this change. After it, both point at the member's source file.Problem and change
Vite 8 hands the top-level
optimizeDepsto the environment namedclientonly; every other environment starts from defaults. Worker and SSR framework plugins turn on dep discovery there, and a member then resolves to a pre-bundle. The hook returns a partial config, which Vite merges by concatenating arrays, so a consumer's own exclude list for that environment still applies. oj's server-environment pre-optimizer resolves the config through Vite itself, so it reads the same list.A member that a plugin names in an environment's
optimizeDeps.includeis still pre-bundled there: Vite does not filter includes by exclude.Tests
server_environment_optimizer_cannot_pre_bundle_a_workspace_member(behaviour test, Vite launcher): with discovery on inssrand a worker environment, each environment's transform must import the member from source. It fails without the hook.🤖 Generated with Claude Code