WIP: Refactor to prepare for Vite's environment API #12807
Draft
+230
−157
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.
While investigating a migration to Vite's environment API, it became clear that some elements of our architecture make this difficult. The biggest challenge is that our server bundle builds can't be expressed as different environment configs within the same plugin instance, instead relying on the fact that each server bundle build is a completely standalone Vite build.
This PR is a refactor to bring our architecture much closer to how the environment API works so the migration work is much simpler, while also making it feasible to maintain backwards compatibility for Vite 5 until our next major release. The ideal solution I'm aiming for is to emulate the environment API in our custom build setup.