-
-
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
Snippet export - compiler treats $page
as local declaration
#14693
Comments
I don't believe this can work, as the template needs to create a subscription to the store and the only way we can do that is by using the component's effect to dispose of it. So in this case, you can't reference a store from within a snippet that needs to be exported using the |
The auto subscription with the $ prefix is tied to the component lifecycle |
as a workaround, maybe just have the snippet take page as a parameter and pass <script module>
import { page } from '$app/stores';
export { exampleSnippet };
</script>
{#snippet exampleSnippet(page)}
{JSON.stringify(page.data)}
{/snippet} I think this should work with the |
@Leonidaz, indeed, passing |
Closing as "works as designed", even though it's unintuitive in this case |
Describe the bug
There is only a
<script module>
and no<script>
in the component, but the snippet can not be exported, because the compiler treats the$page
subscription as if it were local. If I remove the$
from$page
, it can be exported.Reproduction
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: