-
-
Notifications
You must be signed in to change notification settings - Fork 105
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
Vite optimization treats re-exported stores as different references #124
Comments
Related: vitejs/vite#3910. Currently a bug in vite unfortunately. |
thanks @bluwy The workaround is to add the dependency to |
I think we should close this and continue tracking in #125 or vitejs/vite#3910. It isn't just stores that have different references, any singleton pattern would suffer the same issue, so it isn't specific to Svelte per se. |
I agree, I'll close this now. |
Svelte dependencies are now automatically added to |
Describe the bug
If you have a library that re-exports stores (say, in an
index.js
from./store.js
), the exported store fromindex.js
is a different reference than the same one from./store.js
.This is not the case if the package is excluded from optimizeDeps.
Reproduction
URL: https://github.com/mattjennings/vite-svelte-store-bug
add-numbers
package:and in your App, you use it like so:
$total
updates correctly,<Total />
does not.If you import the stores from store.js:
then it updates as expected. Otherwise, you need to pass the library into
optimizeDeps.exclude
in vite config.Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: