-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
fix: improve ssr code generation for class property $derived #10661
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
🦋 Changeset detectedLatest commit: d02511d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This looks like it removes memoization, which could still be relevant if the value is used in multiple places and is expensive to compute. |
Can you provide an example? |
Before, the value was set in a field once, hence it only got computed once. class Counter {
count = 0;
- doubled = this.count * 2;
+ get doubled() {
+ return this.count * 2;
+ }
constructor(initialCount = 0) {
this.count = initialCount;
}
} |
@brunnerh I think this should be fine in all likelihood. It wasn't that the value was being memoized before, it was just always static and never changed. So if you changed |
A static value is a form of memoization. Couldn't the assignment of all derived fields just be moved to the end of the constructor? (Also, I would not even bother using |
Fixes #10643.