mattjennings / svelte-modals

A simple, flexible, zero-dependency modal stack manager for Svelte.
https://svelte-modals.mattjennings.io
154 stars 8 forks source link

use a svelte resolve configuration in package.json #30

Closed stalkerg closed 1 year ago

stalkerg commented 1 year ago

I see the next message: 16:36:56 [vite-plugin-svelte] WARNING: The following packages use a svelte resolve configuration in package.json that has conflicting results and is going to cause problems future.

svelte-modals@1.2.1

Please see https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/faq.md#conflicts-in-svelte-resolve for details.

mattjennings commented 1 year ago

thanks for reporting this, it should be fixed in 1.3.0

stalkerg commented 1 year ago

@mattjennings Hello, still an issue:

19:46:17 [vite-plugin-svelte] WARNING: The following packages use a svelte resolve configuration in package.json that has conflicting results and is going to cause problems future.

svelte-modals@1.3.0

Please see https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/faq.md#conflicts-in-svelte-resolve for details.
mattjennings commented 1 year ago

@stalkerg can you provide a repro? I do not see this error when using @sveltejs/vite-plugin-svelte@2.4.3.

I updated the package.json according to the FAQ in https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/faq.md#conflicts-in-svelte-resolve. So if it's still happening then I'm not sure why.

What the FAQ suggested:

// package.json
  "files": ["dist"],
  "svelte": "dist/index.js",
+ "exports": {
+   ".": {
+     "svelte": "./dist/index.js"
+   }
  }

What svelte-modals has:

  "svelte": "./dist/index.js",
  "types": "./dist/index.d.ts",
  "exports": {
    ".": {
      "types": "./dist/index.d.ts",
      "svelte": "./dist/index.js"
    }
  },
stalkerg commented 1 year ago

Seems like in debug mode possible to find a reason: https://github.com/sveltejs/vite-plugin-svelte/blob/main/packages/vite-plugin-svelte/src/index.js#L185 but seems like if you have "svelte" it can produce it such warning it during SSR.

mattjennings commented 1 year ago

interesting. both the FAQ and svelte-package suggest having both the old "svelte" and the one in exports for backwards compatibility reasons.

can you share what the debug log prints for you?

stalkerg commented 1 year ago

can you share what the debug log prints for you?

yeah, I am trying to reproduce it, it's happened randomly during the dev process.

stalkerg commented 1 year ago

@mattjennings finally find a reason!

vite:resolve 0.10ms svelte-modals -> spa/node_modules/svelte-modals/dist/index.js?v=73e39ece +65ms
vite:vite-plugin-svelte resolve difference for svelte-modals@1.3.0 svelte-modals - svelte: "spa/node_modules/svelte-modals/dist/index.js", vite: "spa/node_modules/svelte-modals/dist/index.js?v=73e39ece" +3ms

for some reason, we are using an extra v argument for svelte-modals.

mattjennings commented 1 year ago

@stalkerg huh, good find! this seems like it might have something to do with vite prebundling svelte-modals. Perhaps some of your imports are using the prebundle, and others aren't? Maybe you could try out some of these settings and see if it fixes the issue.

Either way, I'm not entirely sure what I can do here as I've done what vite-plugin-svelte's FAQ suggests to setup the library. This might be something for them to look at.