-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
feat: allow await
in components
#15844
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
Open
Rich-Harris
wants to merge
533
commits into
main
Choose a base branch
from
async
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.
+4,823
−680
Open
Changes from all commits
Commits
Show all changes
533 commits
Select commit
Hold shift + click to select a range
4e417e1
fix
Rich-Harris f90132c
fix
Rich-Harris ac33857
fix
Rich-Harris 9b36b6b
add callsite to effect tree logs
Rich-Harris 3c350db
fix
Rich-Harris 8a96f23
tidy
Rich-Harris eb8c8e6
simplify
Rich-Harris 52d4ade
simplify
Rich-Harris 47a1693
fix
Rich-Harris 94da28f
skip test
Rich-Harris ee71311
fix
Rich-Harris a0a4d4f
fix
Rich-Harris 31882d1
add `$effect.pending()`
Rich-Harris 49480f0
try this
Rich-Harris 5bcdb13
fix
Rich-Harris 3d970d2
merge main -> async
Rich-Harris 3decb67
add TODO
Rich-Harris 8ba4f71
Merge branch 'main' into async
Rich-Harris 90cdc16
align with main
Rich-Harris 02efac9
fix
Rich-Harris d5922f8
merge main
Rich-Harris fcbb54d
merge main
Rich-Harris 888fc31
is_async -> has_await
Rich-Harris 4b7130e
merge main
Rich-Harris 94a4b11
Merge branch 'main' into async
Rich-Harris ab0ec6f
don't update a focused input (may need to add a blur handler later, w…
Rich-Harris cc2b888
merge main
Rich-Harris 521b228
docs
Rich-Harris 037e289
fix
Rich-Harris 6688eb8
remove indirection
Rich-Harris cb2f68e
QOL
Rich-Harris 4f45033
move stuff
Rich-Harris a469c39
update test to not rely on props
Rich-Harris 43457cc
.
Rich-Harris 8b691e9
rename
Rich-Harris 81f066f
update test
Rich-Harris a840f00
tweak
Rich-Harris 3fe77cd
tweak
Rich-Harris b7c3995
tweak
Rich-Harris 2620a21
tweak
Rich-Harris 0abc0a8
tweak
Rich-Harris 2797036
Merge branch 'main' into async
Rich-Harris ce09353
tidy up
Rich-Harris e49f81f
dont use flushSync
Rich-Harris e0e48b3
WIP
Rich-Harris 8cc5961
tweak
Rich-Harris b48c12b
out of date
Rich-Harris e247f66
more
Rich-Harris d42b358
guarantee fork
Rich-Harris 5000aae
forks.js -> batch.js
Rich-Harris d465537
rename forks to batches
Rich-Harris 9b5f00b
fix
Rich-Harris 5a3f7c2
simplify
Rich-Harris 011741e
note to self
Rich-Harris 623fb50
tweak
Rich-Harris 4a56c2a
tweak
Rich-Harris f30fd26
privatise
Rich-Harris 6eac199
failing test
Rich-Harris 1f02fdf
note to self
Rich-Harris 3ee25bb
reinstate scheduling optimisation
Rich-Harris e5579fd
WIP
Rich-Harris 2e813f1
consistent behaviour
Rich-Harris 6e26478
simplify
Rich-Harris 5518e98
WIP
Rich-Harris c0ff1d0
tidy
Rich-Harris 0f5b3cd
tweak
Rich-Harris 32f753d
fix
Rich-Harris f73a5e9
compile playground with dev: false
Rich-Harris 2087b3e
failing test
Rich-Harris ec81491
shuffle
Rich-Harris 45f4cc5
WIP
Rich-Harris 9e0bd4f
WIP
Rich-Harris 0bc6e69
WIP
Rich-Harris 43eeca9
WIP
Rich-Harris 1cb4e24
WIP
Rich-Harris 21e4c44
WIP
Rich-Harris 1c31363
WIP
Rich-Harris 4680f38
WIP
Rich-Harris 29147fb
WIP
Rich-Harris abba96c
WIP
Rich-Harris 6f8abda
fix
Rich-Harris 48293d2
fix
Rich-Harris d7d528c
fix `$effect.pending()`
Rich-Harris b805245
fix
Rich-Harris 734f56c
fix
Rich-Harris 77e0e60
merge main
Rich-Harris d7f580d
fix changeset
Rich-Harris 399bda5
lint
Rich-Harris a98b5ea
note to self
Rich-Harris fc18e26
failing test
Rich-Harris ed17212
fix
Rich-Harris 78dd1e2
DRY
Rich-Harris 13a9b70
failing test for linear order
Rich-Harris 1dd383e
enforce linear order
Rich-Harris 7762f29
update test
Rich-Harris 8baf164
fix
Rich-Harris 666a148
implement getAbortSignal
Rich-Harris 357ff47
docs
Rich-Harris b61c6ad
fix
Rich-Harris b68dcdc
note to self
Rich-Harris 5e8bcfa
tweak/fix
Rich-Harris 3d0b6f7
update test
Rich-Harris 48a781e
fix
Rich-Harris 693262a
fix
Rich-Harris c599807
implement `settled`
Rich-Harris 53b9b8f
merge main
Rich-Harris 29406c9
merge main
Rich-Harris 449ca14
merge main
Rich-Harris c72d091
oops
Rich-Harris 95b9605
fix
Rich-Harris 6625971
work around some quirk of the test environment
Rich-Harris 15ea2df
Merge branch 'main' into async
Rich-Harris 4136cf2
fix
Rich-Harris fcd51d4
tidy up
Rich-Harris f584d0d
fix
Rich-Harris 7dc2019
lint
Rich-Harris a2bc5f7
add flag
Rich-Harris bc050c3
make everything non-breaking for people who dont opt in
Rich-Harris 4d05ed1
disallow late setContext calls
Rich-Harris 9b1e182
another test
Rich-Harris eaaee83
regenerate
Rich-Harris 7e83cda
move
Rich-Harris 2071160
keep order
Rich-Harris 1a094e7
lint
Rich-Harris 03273b7
chore: better HTML normalization test helper
Rich-Harris 7c10b23
simplify
Rich-Harris 73796c4
simplify/robustify
Rich-Harris 3cf0b9e
Merge branch 'better-normalize-html' into async
Rich-Harris 302dff2
don't write values to deriveds when time travelling
Rich-Harris b608ee2
add failing test
Rich-Harris 1a42fc8
fix
Rich-Harris f72d1a6
merge
Rich-Harris 8557077
we can remove this now
Rich-Harris c96d310
failing test
Rich-Harris 17b2f22
fix
Rich-Harris d131e28
unused
Rich-Harris f8e4651
failing test
Rich-Harris fdb7a6d
fix
Rich-Harris 23bd5c2
DRY
Rich-Harris 00ba548
simplify
Rich-Harris cd24e51
tweak
Rich-Harris c8e47cc
tidy
Rich-Harris 7f0072b
tidy
Rich-Harris dfa8d6b
yes it can, apparently
Rich-Harris aec7368
tidy up
Rich-Harris 541ab97
unused
Rich-Harris b1960ce
complete merge
Rich-Harris 37333df
WIP
Rich-Harris 42d5c7e
simplify
Rich-Harris 54e720b
merge
Rich-Harris 0530c2c
debugging help
Rich-Harris c3ad8c4
WIP
Rich-Harris f3b7ce0
unused
Rich-Harris 6cd7ef9
partial merge
Rich-Harris 84e0790
merge main
Rich-Harris 520d893
WIP
Rich-Harris c566d56
WIP
Rich-Harris 60f8653
fix
Rich-Harris 858dc35
add test
Rich-Harris 68e2eee
rename
Rich-Harris 5a05dc5
fix
Rich-Harris 0bd5310
unused
Rich-Harris bc1a4ca
oops
Rich-Harris fe6c00d
merge main
Rich-Harris 6e1c89f
merge main
Rich-Harris 8733a5d
Merge branch 'main' into async
Rich-Harris 1fb0b1f
merge main
Rich-Harris 6efdc23
merge main
Rich-Harris 61a11a5
chore: merge main into async branch (#16197)
dummdidumm 3156a24
merge main
Rich-Harris 5fda011
make batch.#deferred private
Rich-Harris ea0e269
fix settled when awaits occur inside pending boundary
Rich-Harris 6b9f860
tweak
Rich-Harris 66635c5
change behaviour of `tick()` to be requestAnimationFrame-based
Rich-Harris 8d20a9a
get rid of a bunch of Promise.resolve chains
Rich-Harris 2ae79f3
more
Rich-Harris 0be1f6a
more
Rich-Harris 680cb6a
Merge branch 'main' into async
Rich-Harris ac7b4a7
Merge branch 'main' into async
Rich-Harris e912f88
fix test
Rich-Harris 0430c76
disallow `flushSync()` inside effects
Rich-Harris b400780
regenerate
Rich-Harris 951d8e6
handle errors in block expressions
Rich-Harris fdd009b
make validate_each_keys async-aware
dummdidumm 5c0a4a0
for unowned deriveds, throw errors lazily
Rich-Harris a0dba34
rename ASYNC_ERROR -> ERROR_VALUE, and avoid conflicts with other fla…
Rich-Harris da5b74a
invoke boundary directly
Rich-Harris c80d165
local effect pending
Rich-Harris ee21d9f
update test
Rich-Harris 516ab3b
Merge branch 'async' into async-local-effect-pending
Rich-Harris 8cd5635
fix
Rich-Harris 8300327
fix
Rich-Harris c04a13b
fix weird bug in tests
Rich-Harris 8a1ab92
Merge branch 'async-local-effect-pending' into async
Rich-Harris 5c1ff99
delete old changeset that somehow got left over here
Rich-Harris 042598c
Update .changeset/eleven-weeks-dance.md
Rich-Harris 758c39d
update error details
Rich-Harris 163009d
unused
Rich-Harris 2961124
simplify
Rich-Harris f388568
tweak
Rich-Harris f34f28e
tweak
Rich-Harris 1e2e57f
tweak
Rich-Harris a01249e
tweak
Rich-Harris 2c2557a
tidy up
Rich-Harris 2fd7628
handle errors in async block expressions
Rich-Harris 5694c06
tweak
Rich-Harris 591aeb0
groundwork for async attribute_effect
Rich-Harris 7144f11
dry out
Rich-Harris d7a99b6
fix async directives
Rich-Harris 650144a
tidy up
Rich-Harris 334adc0
initialize option values before initing select values
Rich-Harris d89f318
simplify init_select
Rich-Harris 58918e3
simplify
Rich-Harris 38d458a
tweak
Rich-Harris 39b7f41
tidy up
Rich-Harris 5615fd3
tweak
Rich-Harris b459bb0
on second thoughts just simplify it here
Rich-Harris 0c4af38
merge
Rich-Harris 3070b9a
tidy
Rich-Harris 336a526
merge main
Rich-Harris a018796
handle awaits in `<slot>`
Rich-Harris 94d74f2
unused
Rich-Harris 0c24129
tidy up
Rich-Harris 12fffb9
tidy up
Rich-Harris 2b44100
dry out
Rich-Harris 2585516
dry out
Rich-Harris 3eee9d5
Revert "dry out"
Rich-Harris 7d6b603
dry out
Rich-Harris 7bbb640
dry out
Rich-Harris a1a289e
use let for block-scoped stuff
Rich-Harris 97f8110
dry out
Rich-Harris 53137a1
dry out
Rich-Harris b3bcdaf
tidy up
Rich-Harris aa14305
only wrap awaits in `$.save` when necessary
Rich-Harris 1c66278
oops
Rich-Harris 88b9fdb
Merge branch 'main' into async
dummdidumm 1a6cd7d
merge main
Rich-Harris aff0f50
merge main
Rich-Harris 4d05b1b
remove TODO comment (just checked)
Rich-Harris 73fb7a1
oops, leftover
Rich-Harris 80de2ca
simplify
Rich-Harris ff0662a
unused
Rich-Harris e2bcd8c
remove logging
Rich-Harris 2e854de
tweak
Rich-Harris f6976fd
unused
Rich-Harris 9386b77
unused
Rich-Harris d96991a
remove logging
Rich-Harris 36947c5
partial fix
Rich-Harris 923d8f6
fix
Rich-Harris 09792a0
merge main
Rich-Harris File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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': minor | ||
--- | ||
|
||
feat: support `await` in components when using the `experimental.async` compiler option |
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
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
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
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
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 |
---|---|---|
@@ -1,5 +1,13 @@ | ||
<!-- This file is generated by scripts/process-messages/index.js. Do not edit! --> | ||
|
||
### await_outside_boundary | ||
|
||
``` | ||
Cannot await outside a `<svelte:boundary>` with a `pending` snippet | ||
``` | ||
|
||
TODO | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO |
||
|
||
### invalid_default_snippet | ||
|
||
``` | ||
|
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
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
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
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
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
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
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
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
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
30 changes: 30 additions & 0 deletions
30
packages/svelte/src/compiler/phases/2-analyze/visitors/AwaitExpression.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,30 @@ | ||
/** @import { AwaitExpression } from 'estree' */ | ||
/** @import { Context } from '../types' */ | ||
import * as e from '../../../errors.js'; | ||
|
||
/** | ||
* @param {AwaitExpression} node | ||
* @param {Context} context | ||
*/ | ||
export function AwaitExpression(node, context) { | ||
let suspend = context.state.ast_type === 'instance' && context.state.function_depth === 1; | ||
|
||
if (context.state.expression) { | ||
context.state.expression.has_await = true; | ||
suspend = true; | ||
} | ||
|
||
// disallow top-level `await` or `await` in template expressions | ||
// unless a) in runes mode and b) opted into `experimental.async` | ||
if (suspend) { | ||
if (!context.state.options.experimental.async) { | ||
e.experimental_async(node); | ||
} | ||
|
||
if (!context.state.analysis.runes) { | ||
e.legacy_await_invalid(node); | ||
} | ||
} | ||
|
||
context.next(); | ||
} |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO (and below)