-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
feat: compiler-driven each block reactivity #12744
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
Conversation
|
I reinstated the 'key is item' optimisation. This does come with a caveat — it will result in incorrect behaviour if a legacy mode component passes mutable data to a runes mode component that then uses the optimisation. I think this trade-off is probably acceptable. |
Currently, we don't know at compile-time whether or not an each block item is wrapped in a source. Consequently, we wrap items in
$.unwrap
— something like this......becomes this:
There's several things about this that are suboptimal:
unwrap
and, in turn,is_signal
) per access$.unwrap($.unwrap(...))
)is_signal
is buggy. Duck typing is very rarely a good idea{#each items as item (item)}
), and even then it will become wrapped if some (possibly brittle) runtime checks aren't satisfied. These checks stand in the way of landing breaking: change$state.frozen
->$state.raw
#12742A better route is to determine at compile time whether we need to wrap items. This does mean sacrificing the 'key is item' optimisation (though perhaps there are cases where we could reinstate it? It might just be stores that break it, because they're mutable even in runes mode) but I suspect this case is somewhat rare. In return we optimise other cases (like
each [1, 2, 3]
), and every property access gets microscopically faster. (We also shrink the runtime a tiny amount.)Draft because this revealed an issue with the#12780getters
mechanism — bindings aren't shadowed. Might fix that in a separate PR first.Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.Tests and linting
pnpm test
and lint the project withpnpm lint