Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork4.6k
fix: thunkify deriveds on the server#14977
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
paoloricciuti wants to merge8 commits intomainChoose a base branch fromthunkify-deriveds-on-server
base:main
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Uh oh!
There was an error while loading.Please reload this page.
Open
Changes fromall commits
Commits
Show all changes
8 commits Select commitHold shift + click to select a range
b3eeee0
fix: thunkify deriveds on the server
paoloricciuti4b22a09
chore: install before generating snapshots
paoloricciutiaa224ce
merge main
Rich-Harrisa3f7ae8
dont transform twice
Rich-Harris961c36b
fix
Rich-Harris2f8baac
Merge remote-tracking branch 'origin/main' into thunkify-deriveds-on-…
paoloricciuti22e666c
Merge remote-tracking branch 'origin/main' into thunkify-deriveds-on-…
paoloricciutib1a6b8c
fix: use proxy for destructured values
paoloricciutiFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
5 changes: 5 additions & 0 deletions.changeset/curvy-toes-warn.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'svelte': patch | ||
--- | ||
fix: thunkify deriveds on the server |
1 change: 1 addition & 0 deletionspackages/svelte/src/compiler/phases/3-transform/server/types.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
7 changes: 6 additions & 1 deletionpackages/svelte/src/compiler/phases/3-transform/server/visitors/CallExpression.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
19 changes: 9 additions & 10 deletionspackages/svelte/src/compiler/phases/3-transform/server/visitors/VariableDeclaration.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletionspackages/svelte/src/compiler/phases/3-transform/server/visitors/shared/element.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletionspackages/svelte/src/compiler/phases/3-transform/server/visitors/shared/utils.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
47 changes: 44 additions & 3 deletionspackages/svelte/src/internal/server/index.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletionspackages/svelte/src/internal/shared/utils.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletionspackages/svelte/tests/snapshot/samples/await-block-scope/_expected/server/index.svelte.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletionspackages/svelte/tests/snapshot/samples/server-deriveds/_config.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { test } from '../../test'; | ||
export default test({ | ||
mode: ['server'] | ||
}); |
54 changes: 54 additions & 0 deletionspackages/svelte/tests/snapshot/samples/server-deriveds/_expected/server/index.svelte.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import * as $ from 'svelte/internal/server'; | ||
export default function Server_deriveds($$payload, $$props) { | ||
$.push(); | ||
// destructuring stuff on the server needs a bit more code | ||
// so that every identifier is a function | ||
let stuff = { foo: true, bar: [1, 2, { baz: 'baz' }] }; | ||
let { foo, bar: [a, b, { baz }] } = $.derived(() => stuff, true); | ||
let stuff2 = [1, 2, 3]; | ||
let [d, e, f] = $.derived(() => stuff2, true); | ||
let count = 0; | ||
let double = $.derived(() => count * 2); | ||
let identifier = $.derived(() => count); | ||
let dot_by = $.derived(() => () => count); | ||
class Test { | ||
state = 0; | ||
#der = $.derived(() => this.state * 2); | ||
get der() { | ||
return this.#der(); | ||
} | ||
set der($$value) { | ||
return this.#der($$value); | ||
} | ||
#der_by = $.derived(() => this.state); | ||
get der_by() { | ||
return this.#der_by(); | ||
} | ||
set der_by($$value) { | ||
return this.#der_by($$value); | ||
} | ||
#identifier = $.derived(() => this.state); | ||
get identifier() { | ||
return this.#identifier(); | ||
} | ||
set identifier($$value) { | ||
return this.#identifier($$value); | ||
} | ||
} | ||
const test = new Test(); | ||
$$payload.out += `<!---->${$.escape(foo?.())} ${$.escape(a?.())} ${$.escape(b?.())} ${$.escape(baz?.())} ${$.escape(d?.())} ${$.escape(e?.())} ${$.escape(f?.())} 0 0 ${$.escape(dot_by?.())} ${$.escape(test.der)} ${$.escape(test.der_by)} ${$.escape(test.identifier)}`; | ||
$.pop(); | ||
} |
25 changes: 25 additions & 0 deletionspackages/svelte/tests/snapshot/samples/server-deriveds/index.svelte
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<script> | ||
// destructuring stuff on the server needs a bit more code | ||
// so that every identifier is a function | ||
let stuff = $state({ foo: true, bar: [1, 2, {baz: 'baz'}] }); | ||
let { foo, bar: [a, b, { baz }]} = $derived(stuff); | ||
let stuff2 = $state([1, 2, 3]); | ||
let [d, e, f] = $derived(stuff2); | ||
let count = $state(0); | ||
let double = $derived(count * 2); | ||
let identifier = $derived(count); | ||
let dot_by = $derived(()=>count); | ||
class Test{ | ||
state = $state(0); | ||
der = $derived(this.state * 2); | ||
der_by = $derived.by(()=>this.state); | ||
identifier = $derived(this.state); | ||
} | ||
const test = new Test(); | ||
</script> | ||
{foo} {a} {b} {baz} {d} {e} {f} {double} {identifier} {dot_by} {test.der} {test.der_by} {test.identifier} |
6 changes: 4 additions & 2 deletionspackages/svelte/tests/snapshot/test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.