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.
We kept discussing about Environment Plugins today. Especially from the perspective of a plugin author and we are finding the fact that we have two different plugin types hard to work with:
UnoCssEnvironmentPlugin
that is a(environment) => EnvironmentPlugin
to implement its internals. It can be used insideenvironmentPlugins
but also exported. So the plugin will export bothUnoCssPlugin
andUnoCssEnvironmentPlugin
. The user normally will use the shared plugin, and if it needs to have it per environment, it could use theUnoCssEnvironmentPlugin
Using the environment plugin sounds complex from the user side. It may not even be possible to do if there is some global configuration required without extra coordination. All plugins would also need to be reworked to expose both plugin types. We could think of
environmentPlugins
as an internal tool only, and not something we expose to users, but we can justify to add it in that case.Environment
instance. So there is no need forthis.environment
. Local state can also be used without issues. There is no need for aWeakMap<Environment, Data>
to avoid cross-environment pollution.This is great, but at the same time, it pushes us to have two mental models when authoring plugins. Environment Plugins can't be added to the main pipeline, and Shared Plugins can't be safely added to the environment pipeline (because some hooks may not be executed).
So, we're rethinking if we need two kinds of plugins at all. It may be better to enforce the use of
this.environment
for all plugins so they can be used in multiple environments or in a single one without any issues.Instead of the
environmentPlugins
hook or the(environment) => EnvironmentPlugin
ideas, we could go back to environment filtering. This was discussed when we started working on the Environment API proposal, but at that point it seemed that it didn't fit well.apply
is run beforeconfig
so that hook can't be used.The idea would be to keep only shared plugins, and add a new
applyForEnvironment(environment)
hook (name to be discussed)We then have a single plugin type, and a way to define per environment plugins that don't diverge from current usage