-
-
Notifications
You must be signed in to change notification settings - Fork 193
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
Add support for Babel plugins used in Vite/React config #904
Conversation
I tried to keep the changes minimal but had to copy over the |
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.
Thanks @mbacalan, much appreciated!
I'll enable CI and then it'll run in a couple of projects automatically as a "ecosystem smoke test".
@@ -48,7 +48,7 @@ const findConfigDependencies = (localConfig: ViteConfig, options: PluginOptions) | |||
return [...[...environments, ...reporters, ...coverage].map(toDependency), ...setupFiles, ...globalSetup]; | |||
}; | |||
|
|||
const getConfigs = async (localConfig: ViteConfigOrFn | VitestWorkspaceConfig) => { | |||
export const getConfigs = async (localConfig: ViteConfigOrFn | VitestWorkspaceConfig) => { |
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.
Perhaps we can import the babel function here and handle it from the vitest plugin?
} | ||
} | ||
|
||
return false; |
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.
I didn't realize at first the babel object is sent to the react plugin, but if this works then... all good! :)
@@ -12,6 +18,52 @@ const isEnabled: IsPluginEnabled = ({ dependencies }) => hasDependency(dependenc | |||
|
|||
export const config = ['vite.config.{js,mjs,ts,cjs,mts,cts}']; | |||
|
|||
const hasReactBabelPlugins = (config: ViteConfig) => { |
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.
If we can move it over to the vitest plugin, then this helper could go the helpers.ts
commit: |
Thanks for the feedback. Upon further inspection, it looks like these changes don't solve the issue. I'll get back to it soon and take into account the points you raised. |
Initially I saw However, if the It's basically the same problem as #856 where we also ideally would have an easy way to - instead of loading the configuration file and read as an object - use the AST and traverse it to find strings like At the very least this serves as an extra use case that probably involves reading and parsing config file ASTs. |
I did a little deep dive and just came to the same conclusion :)
Well, hopefully didn't take too much of your time here. Let me know if I should close this or feel free to do as you like. Nice codebase btw, learned a few things and it was fun to investigate through it! |
Thanks for digging through. And no worries about my time, mostly glad to hear you got something out of Knip! |
Fixes #903