Skip to content
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

Exported functions become "stale" on hot reload #43

Closed
enyo opened this issue Feb 28, 2022 · 6 comments · Fixed by #44 or #47
Closed

Exported functions become "stale" on hot reload #43

enyo opened this issue Feb 28, 2022 · 6 comments · Fixed by #44 or #47
Labels
bug Something isn't working hmr

Comments

@enyo
Copy link

enyo commented Feb 28, 2022

Describe the bug

When a component exposes a function with export const doStuff = () => { /* code */ } so that an outer component can invoke it, the code inside the exported function doesn't have access to the local variables anymore after reload.

Reproduction

https://svelte.dev/repl/5d2a100498f34c50ad9ce2ff2a4e3569?version=3.46.4

Logs

No response

System Info

macOS

Severity

annoyance

@bluwy
Copy link
Member

bluwy commented Feb 28, 2022

Duplicate of sveltejs/vite-plugin-svelte#134

@bluwy bluwy marked this as a duplicate of sveltejs/vite-plugin-svelte#134 Feb 28, 2022
@bluwy bluwy closed this as completed Feb 28, 2022
@enyo
Copy link
Author

enyo commented Mar 2, 2022

@bluwy are you sure it's the same? Mine has nothing to do with context module.

@bluwy
Copy link
Member

bluwy commented Mar 3, 2022

Ah I think you're right. I can reproduce this too at https://stackblitz.com/edit/vitejs-vite-rdqnfu?file=src%2FInner.svelte&terminal=dev. Transferring this over to vite-plugin-svelte as HMR is not related to Svelte. But this issue could be related to svelte-hmr too.

Repro steps with stackblitz:

  1. Start the dev server
  2. Edit Inner.svelte
  3. Click on the "Open" button
  4. Notice that the "Open: false" text did not become "Open: true"

@bluwy bluwy reopened this Mar 3, 2022
@bluwy bluwy transferred this issue from sveltejs/svelte Mar 3, 2022
@bluwy bluwy added bug Something isn't working hmr labels Mar 3, 2022
@dominikg
Copy link
Member

dominikg commented Mar 3, 2022

i suppose this is one for svelte-hmr. cc @rixo

@rixo
Copy link
Collaborator

rixo commented Mar 3, 2022

Yes, I confirm this is independent from the context=module issue, and that this is the responsibility of svelte-hmr. This one should be easier, since it pertains to component instances, where svelte-hmr is really acting.

Should we transfer the issue to svelte-hmr or create another one there?

@bluwy
Copy link
Member

bluwy commented Mar 3, 2022

I don't have permissions to transfer over to svelte-hmr, unless someone does 👀 Else I'm fine recreating an issue there too.

@dominikg dominikg transferred this issue from sveltejs/vite-plugin-svelte Mar 3, 2022
rixo added a commit to rixo/svelte-hmr that referenced this issue Mar 3, 2022
@rixo rixo mentioned this issue Mar 3, 2022
@rixo rixo closed this as completed in #44 Mar 8, 2022
rixo added a commit that referenced this issue Mar 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working hmr
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants