refactor(vite)!: early init nitro#3675
Closed
pi0 wants to merge 3 commits into
Closed
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Member
Author
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.
Context
Nitro Vite plugin needs to inject other rollup plugin hooks in dev and to resolve those plugins it needs to instantiate based on env (
dev|build+root+ user config are required to init)Currently, we do it with a very hacky workaround to manually call rollup plugin hooks which is broken in many cases as we don't chain hooks nor respect order.
New workaround
We could infer
userConfigsomehow from global (NODE_ENVandprocess.argv) and root dir from last arg + cwd.We cannot anymore also access to user config from top level...
Alternatives
Ideally it would be great if vite could allow exending plugins with
confighook (here) -- giving the responsibility to plugin authors to only inject valid/resolved plugins in there with intended order.One other alternative would be that vite supporting callable functions as plugins input and call/instnatiate them itself using params similar to filter
A 3rd alternative would be keeping current solution but an improved
dynamicRollupPlugins()util that adds hooks with respect of order and chaining (for dev).