-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
fix: hoist reactive imports to the module #12845
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
fix: hoist reactive imports to the module #12845
Conversation
🦋 Changeset detectedLatest commit: 6e79526 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Not sure this is quite right. In Svelte 4, mutating a module-level declaration has no effect. I think we just need to skip the |
Ohhh i actually never used this feature so i wasn't sure...fixing it. |
I tought i could've just used
I will continue working on this a bit but since is touching a lot of places i would love some feedback on this...maybe i'm missing something obvious. |
Fixed. The trick is to compare the |
Uh I'm always a bit hesitant to use text positions but I guess it makes sense...noted for next time. However this doesn't fully fix the problem. If you do something like this it stills throws an error. |
Oh also you didn't revert my initial change |
The initial change was fine — there's no need to create a store per component when we can have one per import instead.
Huh. To be honest the Svelte 4 behaviour makes no sense here — given that it was untested, and that this is code that no-one would ever write, I think this is a place where we don't need to worry about bug-for-bug compatibility, as long as we preserve the intended behaviour for realistic cases. |
Great then...yeah i was trying to make it same behavior of svelte 4 in toto but I agree it doesn't make much sense. Then I guess is fine like this |
Svelte 5 rewrite
Closes #12842
Reactive imports should be hoisted to the module in case someone reads or write to them in the module context. I've check and it seems the only thing that is doing is create a source so it should be good to just hoist them to module.
Please note that the Svelte codebase is currently being rewritten for Svelte 5. Changes should target Svelte 5, which lives on the default branch (
main
).If your PR concerns Svelte 4 (including updates to svelte.dev.docs), please ensure the base branch is
svelte-4
and notmain
.Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.Tests and linting
pnpm test
and lint the project withpnpm lint