Coder Social home page Coder Social logo

Comments (8)

alarivan avatar alarivan commented on September 2, 2024 3

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.

from vite-plugin-solid.

Tur8008 avatar Tur8008 commented on September 2, 2024 1

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

from vite-plugin-solid.

peterboyer avatar peterboyer commented on September 2, 2024 1

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

from vite-plugin-solid.

GitMurf avatar GitMurf commented on September 2, 2024

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)

from vite-plugin-solid.

jtmueller avatar jtmueller commented on September 2, 2024

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

from vite-plugin-solid.

GitMurf avatar GitMurf commented on September 2, 2024

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

from vite-plugin-solid.

floratmin avatar floratmin commented on September 2, 2024

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

from vite-plugin-solid.

Tur8008 avatar Tur8008 commented on September 2, 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.

from vite-plugin-solid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.