vite icon indicating copy to clipboard operation
vite copied to clipboard

refactor: plugin container for Vite 6

Open antfu opened this issue 1 year ago • 6 comments

This PR refactors the plugin containers file:

  • PluginContext per-plugin, instead of per-hook, align with rollup: https://github.com/rollup/rollup/blob/1b62c336b8e927e846cd2c04563ae0868a5d5832/src/utils/PluginDriver.ts#L105-L110
  • Hoisted Context and TransformContext classes to top-level instead of having them in the function that creates every time.
  • Make EnvironmentPluginContainer a class to have more explicit deps relationships and easier to work with

antfu avatar May 21 '24 14:05 antfu

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

/ecosystem-ci run

antfu avatar May 21 '24 20:05 antfu

📝 Ran ecosystem CI on be9094a: Open

suite result latest scheduled
analogjs :x: failure :white_check_mark: success
astro :x: failure :white_check_mark: success
histoire :x: failure :white_check_mark: success
marko :x: failure :white_check_mark: success
nuxt :x: failure :white_check_mark: success
previewjs :x: failure :x: failure
quasar :x: failure :white_check_mark: success
qwik :x: failure :white_check_mark: success
rakkas :x: failure :white_check_mark: success
remix :x: failure :white_check_mark: success
sveltekit :x: failure :white_check_mark: success
vike :x: failure :white_check_mark: success
vite-plugin-svelte :x: failure :white_check_mark: success
vitepress :x: failure :white_check_mark: success
vitest :x: failure :x: failure

:white_check_mark: ladle, laravel, unocss, vite-plugin-pwa, vite-plugin-react, vite-plugin-react-pages, vite-plugin-react-swc, vite-plugin-vue, vite-setup-catalogue

vite-ecosystem-ci[bot] avatar May 21 '24 21:05 vite-ecosystem-ci[bot]

I've yet to thoroughly review this, but wondering, could this be refactored in main? Seems like a nice general refactor otherwise so we keep the environment API changes small. Or does it introduces breaking changes?

bluwy avatar May 22 '24 04:05 bluwy

It's based on the new abstraction of the new env pluginConainter - it would require certain efforts to redo it in main - and then solving the conflicts in v6 as well. Do you think that would be worth the effort?

antfu avatar May 22 '24 06:05 antfu

Ok, I will try to redo this on main, so we could also at least ensure it works without env api

antfu avatar May 23 '24 10:05 antfu

Made the change/migration in 909782f (#16471)

antfu avatar May 30 '24 10:05 antfu