Closed mseele closed 2 years ago
Hi Michael, thanks for reporting this!
Currently, client scripts are implemented using islands (for simplicity), so you can't stack them.
This information is missing in documentation, I'll keep this open as a reminder to cover that, and perhaps explore a different way to render nested client scripts since it's a valid use case (unlike with islands).
Initially I thought you were referring to Client Scripts.
After looking at the example you've linked, I'm afraid this is just incorrect usage.
Once you define a boundary with a client directive, anything inside that component (and its children) will be compiled as a Vue app, so having inner hydration directives would not make sense (they would be hydrated whenever the island is).
To fix the problem, remove the client:load
directive in the inner child (in your example, ScriptTwo
), it will remain interactive because it's already inside an island.
To fix the problem, remove the
client:load
directive in the inner child (in your example,ScriptTwo
), it will remain interactive because it's already inside an island.
What about the inner component being used in different outer components, where some outer components are interactive but others are not?
I mean, <component-a client:load />
in component b, and <component-b client:load />
in component c but <component-b />
in component d. A workaround is to make component b interactive in component d, which is acceptable but may increase the bundle size.
Can you share a use case where you have this scenario? Seems unlikely that the same component would be both interactive and static.
Also, from the bundle size perspective, if b is ever interactive in any page, the same script would be reused across pages.
Sorry, the example was incorrect. It should be b always non-interactive, c interactive and d non-interactive.
It will be good if the inner client directives can be automatically ignored when there are outer ones.
Also, from the bundle size perspective, if b is ever interactive in any page, the same script would be reused across pages.
The total bundle size is virtually the same, but the island script needs to be loaded on more pages.
Besides the bundle size, this can also make components more modular, as I don't need to care whether a component is used within an island or not.
Unfortunately it's not possible to statically analyze this type of usage, so supporting this would greatly increase the complexity of the Islands runtime.
I don't discard supporting this in the future, but I want to see real-life use cases that don't have easy workarounds before embarking on that exploration.
Please share a real site/app/use case if you are interested in this type of usage.
Please share a real site/app/use case if you are interested in this type of usage.
I have been working on my new blog these days. It's still a WIP and will hopefully be published this week.
In short, I want to display a few dynamic stats like relative creation/modification time and visitor count in the header of a blog post. And I also want to display the post header on the search result page. The post header is static on other pages but dynamic on the search result page. The bundle size is small so it's not a big problem for me, though.
Please share a real site/app/use case if you are interested in this type of usage.
@ElMassimo please look at https://github.com/mseele/sve-website/tree/c79c8d2a840d39ab0a573d76fd9b2c915af2894f for a real site use case.
This is where I ran into that error:
- EventContent - EventDetails (client:load) - NewsSubscription - EmailSubscription (client:load)
and
- EventsContent - NewsSubscription - EmailSubscription (client:load)
In the current version I worked around by duplicate a little code, remove EmailSubscription
and make NewsSubscription
client:load or not.
Thanks for providing an example, now tracking in:
iles
andvite
.Description π
When you stack components with client scripts (client:idle / client:load) you get an RangeError: Maximum call stack size exceeded.
Reproduction π
https://stackblitz.com/edit/iles-uiy2vm?file=src/components/ScriptOne.vue