Skip to content
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

Warning: "deps.registerNodeLoader" is deprecated #114

Open
jtmueller opened this issue Aug 23, 2023 · 8 comments
Open

Warning: "deps.registerNodeLoader" is deprecated #114

jtmueller opened this issue Aug 23, 2023 · 8 comments

Comments

@jtmueller
Copy link

When running vitest 0.34.2, if I have vite-plugin-solid registered as a plugin, the following warning is logged:

Vitest "deps.registerNodeLoader" is deprecated. If you rely on aliases inside external packages, use "deps.optimizer.web.include" instead.

If I remove vite-plugin-solid from the vitest config, no warnings are logged.

@GitMurf
Copy link

GitMurf commented Aug 30, 2023

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: #112 (comment)

@alarivan
Copy link

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.

@jtmueller
Copy link
Author

@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
Copy link

GitMurf commented Sep 12, 2023

@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 the vite-plugin-solid included, it runs my tests twice!

FYI see this thread for the solution to my additi issue mentioned above: #101 (comment)

@Tur8008
Copy link

Tur8008 commented Nov 20, 2023

Why is that not working for me?

  • vitest 0.34.6
  • vite 4.5.0
  • vite-plugin-solid 2.7.2
    My vitest.config.ts
Снимок экрана 2023-11-20 в 11 51 04

And I get this
Снимок экрана 2023-11-20 в 11 53 40

@peterboyer
Copy link

peterboyer commented Nov 30, 2023

@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:

deps: { registerNodeLoader: true },

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:

[email protected] [email protected] [email protected].

- 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.

@floratmin
Copy link

Works also with [email protected], [email protected] and [email protected]

@Tur8008
Copy link

Tur8008 commented Jan 28, 2024

Works also with [email protected], [email protected] and [email protected]
Yepp! Just have updated site-plugin-solid up to 2.9.1 and problem has gone. Thank you! They fixed that, at last.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants