-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
warn module variables are not reactive and make them truely non reactive #5847
Conversation
What do you mean by making them truly non-reactive? What behavior is changing here besides adding the compiler warning? |
so, if u look at the REPL, the value of if you look at the compiled code, svelte tries to set the value of but,
so i suggest that, if the reactive declaration depends only on module variable, then it should be a static reactive declaration. |
Is that technically a breaking change? |
@tanhauhau does this PR cover the following? tested in 3.31.0 <script context="module">
let foo;
</script>
<script>
let foo;
</script> In vanilla html you'd see |
This has been released in 3.32.1 - https://svelte.dev/repl/7eb62137060d4d53abe5e6a8b45074d5?version=3.32.1 |
Is it possible to disable this rule? As of now now impossible to reuse imported constants because of this warning.
gives "CIRCLE_GAP" is declared in a module script and will not be reactive. Ok, constants can be not reactive. |
Same for heavy initializers at module level, how I can now init once something without this warning. |
I thought this should work |
This warning also occurs when using exported functions. https://svelte.dev/repl/7ddb4af47bbf4cdebbefcf5649e83ff1?version=3.32.1 |
I have now a lot of warnings because of this rule.. Please add something to disable it globally. |
For |
* 'master' of https://github.com/sveltejs/svelte: (129 commits) -> v3.32.3 fix remove of lone :host selectors (sveltejs#5984) -> v3.32.2 update changelog fix extra invalidation with component prop binding to object property (sveltejs#5890) update css-tree@^1.1.2 (sveltejs#5958) fix :host and :global css scoping (sveltejs#5957) Tutorial : a better explanation of component events (sveltejs#4639) "What's new in Svelte" February newsletter (sveltejs#5925) Change color on 404 page (sveltejs#5932) -> v3.32.1 warn module variables are nonreactive and make them truly nonreactive (sveltejs#5847) update changelog fix: "foreign" namespace elements should still allow binding 'this' (sveltejs#5942) inline `prop_values` in `init` helper (sveltejs#5909) update changelog don't create class update functions when dependencies aren't reactive (sveltejs#5926) fix extraneous store subscription in SSR (sveltejs#5929) make `SvelteComponentDev` typings more forgiving (sveltejs#5937) make animation/transition params optional (sveltejs#5936) ...
Fixes #5843
Before submitting the PR, please make sure you do the following
- [ ] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcsTests
npm test
and lint the project withnpm run lint