Replies: 3 comments 9 replies
-
Regarding rollup plugins, it definitely improves the user experience in Vite when they work out of the box. Since Vite is not the only consumer, I agree that About Vite's "feature" plugins, instead of modifying the order and introducing another value for Although it would require an additional configuration option, it opens up the possibility for some plugins to opt-out automatically by using the |
Beta Was this translation helpful? Give feedback.
-
Although the ability to use rollup plugins out-of-box could be a nice feature, I don't think it's good to have Vite-specific options in rollup plugins. I personally think it's better to wrap rollup plugins and publish them as Vite plugins with some override configure like |
Beta Was this translation helpful? Give feedback.
-
Changing the ordering alone won't be enough because Rollup Still, I think the best practice is to first check the features page of the docs to see "is this covered in Vite already?" before reaching for plugins. P.S. we should probably add a dedicated section in the features page for the special queries ( |
Beta Was this translation helpful? Give feedback.
-
enforce naming
@rollup/plugin-image is the only official rollup plugin where
enforce: 'pre'
is required. I wanted to send a PR to rollup/plugins so they includeenforce
in it but I think that it could be rejected because of naming. There could be issues if WMR decides to have a different ordering but the same config name.Would it make sense to rename
enforce
to be more explicit, something likeviteOrder
?I think that rollup plugin maintainers may be more willing to accept these compat enhancements if they know the hooks are not going to interfere later with other projects (or with a future API from rollup itself).
Vite plugin ordering
There are some Vite core plugins that I would consider optional features: jsonPlugin, wasmPlugin, webWorkerPlugin, assetPlugin. I think it is a good idea to have these features out of the box, but if a user would like to use a different wasm plugin, or as with @rollup/plugin-image, would like to import images in a different way than what Vite does out of the box, it would be good if they can just use the plugins without the need to use
enforce: 'pre'
. If they are including one of these plugins, their intent is clear.Right now, the ordering is:
I was thinking that the Vite core plugins could be broken into two buckets: Vite Core plugins (resolve, etc) and Vite Features plugins (json, wasm, webWorker, importing images as URL). The Vite Features plugins could then be applied after normal user plugins like:
I think this could help reduce the need for explicitly enforcing the ordering in user plugins ( I do not know if
after
is really needed. Naming could also bepre
,post
,last
).Beta Was this translation helpful? Give feedback.
All reactions