joshnuss / svelte-persisted-store

A Svelte store that persists to localStorage
MIT License
994 stars 41 forks source link

v0.9.3 breaks imports with SvelteKit #260

Closed khromov closed 3 months ago

khromov commented 3 months ago

Just saw the new version tagged and updated, but it does not seem to work with SvelteKit. So if you have this issue, you can stay on 0.9.2 for now.

Here is a SvelteLab reproduction: https://www.sveltelab.dev/k303hv6xldifpue

 The plugin "vite:dep-scan" was triggered by this import

    src/lib/stores/user.ts:3:26:
      3 │ import { persisted } from 'svelte-persisted-store';
        ╵                           ~~~~~~~~~~~~~~~~~~~~~~~~

✘ [ERROR] Failed to resolve entry for package "svelte-persisted-store". The package may have incorrect main/module/exports specified in its package.json. [plugin vite:dep-scan]
brandonkal commented 3 months ago

I can confirm this change breaks Vite's build process (So even just Vite + Svelte)

Keagel commented 3 months ago

I can confirm the same thing happens for me. It's caused by an attempt to fix this issue: https://github.com/joshnuss/svelte-persisted-store/issues/258 It seems simply adding type: "module" is not enough.

I don't know a lot about packaging but I can see that module is set to dist/index.mjs here which doesn't seem right as the generated dist folder doesn't contain such a file.

Is it possible it never caused an issue before because the package wasn't a module, and now that it is it's trying to load that file which doesn't exist?

o-az commented 3 months ago

what's needed is adding exports field to package.json

https://publint.dev/svelte-persisted-store@0.9.3

@joshnuss I suggest you add a publint as part of your CI / prepublish checks: npx publint

joshnuss commented 3 months ago

Thanks for reporting!

Sorry about that.

It is now fixed in ddfe9d41b0ec1476f1d0f96e0411f2c48b0317de.

Please update to v0.9.4