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

(Svelte 4) subscribed store in markup won't use module instance #13061

Closed
theetrain opened this issue Aug 29, 2024 · 1 comment
Closed

(Svelte 4) subscribed store in markup won't use module instance #13061

theetrain opened this issue Aug 29, 2024 · 1 comment

Comments

@theetrain
Copy link
Contributor

theetrain commented Aug 29, 2024

Describe the bug

In a component with <script context="module">, some markup, and without <script>; having a writable store be set by an exported function won't cause reactive updates in the markup.

Adding an empty <script></script> will include writable store in compiled output.

Reproduction

Toast component: https://svelte.dev/repl/6c0757bed5044018ba5560733e7b56bf?version=4.2.19

  1. Click on button labelled "Click me"
  2. Observe empty Toast message

Workaround:

  1. Add <script></script> to the markup
  2. Observe new prop in compiled output (there are more changes in compiled output as well):
/* Toast.svelte generated by Svelte v4.2.19 */
import {
  SvelteComponent,
  append,
  append_styles,
  attr,
  component_subscribe,
  detach,
  element,
  init,
  insert,
  noop,
  safe_not_equal,
+ set_data,
+ text as text_1,
  toggle_class
} from "svelte/internal";
  1. Click button to present a working Toast message

Note this works totally fine in Svelte 5, in both Runes and non-Runes modes. Demo.

Logs

No response

System Info

Svelte 4.2.19

Severity

annoyance

@Conduitry
Copy link
Member

Closing, as this works in v5.

@Conduitry Conduitry closed this as not planned Won't fix, can't repro, duplicate, stale Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants