Open jtmueller opened 1 year ago
Same with me. Another weird thing that I cannot figure out for the life of me @jtmueller is that when I have the vite-plugin-solid
plugin enabled in my vite config, my tests all are duplicated (they each run twice)!! Have you noticed this at all? It is driving me insane, haha. See here: https://github.com/solidjs/vite-plugin-solid/issues/112#issuecomment-1698476208
You can remove the warning by using optimizer and server config:
test: {
server: {
deps: {
// fixes: You appear to have multiple instances of Solid. This can lead to unexpected behavior.
inline: [/solid-js/],
},
},
deps: {
// fixes: Vitest "deps.registerNodeLoader" is deprecated. If you rely on aliases inside external packages, use "deps.optimizer.web.include" instead.
optimizer: {
web: {
enabled: true,
},
},
},
}
https://github.com/vitest-dev/vitest/releases/tag/v0.34.0 From release notes:
Deprecate deps.registerNodeLoader - by @sheremet-va (7f45b) This option was introduced to support aliasing inside external packages. Please, use deps.optimizer.web instead. If you test Node.js applications, consider adding external packages to server.deps.inline.
@alarivan Thanks, that gets rid of the warning for me - I was logging the issue mostly so that the next version of vite-plugin-solid wouldn't trigger the deprecation warning by default, but I appreciate the workaround.
@GitMurf I was seeing the deprecation warning twice, but at least after applying the above workaround, the actual tests don't seem to run more than once.
@GitMurf I was seeing the deprecation warning twice, but at least after applying the above workaround, the actual tests don't seem to run more than once.
When I am running my unit tests with
vitest
, whenever I use my main vite config that has thevite-plugin-solid
included, it runs my tests twice!
FYI see this thread for the solution to my additi issue mentioned above: https://github.com/solidjs/vite-plugin-solid/pull/101#issuecomment-1698495511
Why is that not working for me?
And I get this
@Tur8008 I was also unable to suppress the deprecation message using the above recommendations.
This message seems to be caused by the SolidPlugin()
's returned config-patch object that contains the deprecated property:
I was able to develop a workaround that patches-out the deprecated property (setting it to undefined
) which effectively suppresses the deprecation message when running vitest
:
vite@4.5.0
vitest@0.34.6
vite-plugin-solid@2.7.2
.
- import { defineConfig } from "vitest/config";
+ import { type UserConfig, defineConfig } from "vitest/config";
import SolidPlugin from "vite-plugin-solid";
export default defineConfig({
// ...
plugins: [
- SolidPlugin(),
+ // @workaround
+ // `"deps.registerNodeLoader" is deprecated.`
+ (() => {
+ const plugin = SolidPlugin();
+ const { config } = plugin;
+ return Object.assign(plugin, {
+ config: async (...args: any[]) => {
+ const result: UserConfig = await (config as any)(...args);
+ if (result.test?.deps?.registerNodeLoader) {
+ result.test.deps.registerNodeLoader = undefined;
+ }
+ return result;
+ },
+ });
+ })(),
],
// ...
});
I'm not sure whether or not this patched-out property will cause any other problems -- but for now it seems okay!
[edit 1] ~Sorry, it seems to completely crash vite dev
with TypeError: Cannot read properties of undefined (reading 'deps')
-- I'll have to look into it further.~
[edit 2] Turns out I made a mistake in the original version of my workaround diff causing a config error if not running in the "test" mode
. I've fixed my code snippet to first check for the property before attempting to clear it.
Works also with vitest@1.2.1
, vite@5.0.11
and vite-plugin-solid@2.8.2
Works also with
vitest@1.2.1
,vite@5.0.11
andvite-plugin-solid@2.8.2
Yepp! Just have updated site-plugin-solid up to 2.9.1 and problem has gone. Thank you! They fixed that, at last.
When running
vitest
0.34.2, if I havevite-plugin-solid
registered as a plugin, the following warning is logged:If I remove
vite-plugin-solid
from the vitest config, no warnings are logged.