-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
refactor: [hookName].handler in plugins
#19586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: [hookName].handler in plugins
#19586
Conversation
| // for backward compat, make `plugin.transform` a function | ||
| // but still keep the `handler` property | ||
| // so that we can use `filter` property in the future | ||
| plugin.transform = transformHook.handler | ||
| ;(plugin.transform as any).handler = transformHook.handler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might need more back-compat for other transforms too
vite:jsonhttps://github.com/intlify/bundle-tools/blob/d3724e19cae256219f57ac7bc364ff2e07d05502/packages/unplugin-vue-i18n/src/core/resource.ts#L196-L197vite:css-posthttps://github.com/hi-ogawa/unocss/blob/261d335eb3a7ebf1700f2418361a2308e240fb22/packages-integrations/vite/src/modes/chunk-build.ts#L14
(I actually hit vite:css-post one in my CI hi-ogawa/vite-environment-examples#157, but I just fixed on my side and forgot to report.)
|
/ecosystem-ci run |
commit: |
This comment was marked as outdated.
This comment was marked as outdated.
|
📝 Ran ecosystem CI on
✅ analogjs, astro, histoire, ladle, laravel, marko, nuxt, previewjs, quasar, qwik, rakkas, react-router, storybook, unocss, vike, vite-environment-examples, vite-plugin-pwa, vite-plugin-react, vite-plugin-react-swc, vite-plugin-vue, vite-plugin-cloudflare, vite-setup-catalogue, vitepress, vitest, vuepress, waku |
patak-dev
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should merge this one in Vite 6.3, just to play safe. But I'm ok if you'd like to go with it in a patch to avoid blocking other work.
The diff is massive. Adding a filter would be a common pattern in the future, and I think the boat already sailed but I wonder if it would have been better to keep the hooks as function only and add new properties for each to configure them. It would also have avoided all the indirections to deal with the hook being an object or a function.
transformConfig: {
filter: /x/,
order: 'pre'
}
transform(code, id) {
return transformed(code)
}
I'm fine with merging in 6.3 👌
Yeah, maybe that would have made some places easier to handle. |
9ea022a to
576695a
Compare
|
I rebased this PR on top of #19588 as that one should be safe to merge in a patch and this PR conflicts with that one. |
576695a to
6566f12
Compare
|
it seems this change broke nuxt / vue-i18n; see nuxt/nuxt#31813 |
|
Got the same |
this was not working because of vitejs#19586 (comment) and vitejs#19878
Description
Moves some
plugin[hookName]toplugin[hookName].handlerso that we can addfilterwithout a big diff.This PR has a big diff, but it only moves the hooks under
.handlerso it shouldn't change any behavior unless the 3rd party plugin / framework calls the plugin manually.