Implemented by reusing the `async_body` function inside `Fragment.js`. Also removes the ability to reference a `{@const ...}` of an implicit child inside a boundary pending/failed snippet:
- existing duplication of consts can have unintended side effects, e.g. async consts would unexpectedly called multiple times
- what if a const is the reason for the failure of a boundary, but is then referenced in the failed snippet?
- what if an async const is referenced in a pending snippet? deadlock
- inconsistent with how it behaves for components where this already does not work
Implemented via the experimental flag so the behavior change only applies there as this is a breaking change strictly speaking. Also added a compiler error for this.
closes#16462
* fix: properly catch top level await errors
async errors within the template and derived etc are properly handled because they know about the last active effect and invoke the error boundary correctly as a response. This logic was missing for our top level await output.
Fixes#16613
* test
* use helper for async bodies (#16641)
* use helper for async bodies
* unused
* fix
* failing test + fix
---------
Co-authored-by: Simon Holthausen <simon.holthausen@vercel.com>
---------
Co-authored-by: Rich Harris <rich.harris@vercel.com>
* fix: skip effects inside dynamic component that is about to be destroyed
When a dynamic component was updated to a different instance and its props were updated at the same time, effects inside the component were still called with the already-changed props.
The fix is to mark the branch as skipped to never got to those effects.
Fixes#16387
* undo accidental commit
* fix: wrap `abort` in `without_reactive_context`
* only call without_reactive_context when the controller exists
---------
Co-authored-by: Rich Harris <rich.harris@vercel.com>
* Update for TS7
I am testing Typescript 7's JS support, which I've largely rewritten
during the switch to Go. That means Javascript code will need to change
much more than Typescript code. Fortunately, most of the changes are for
the better: Javascript semantics are now nearly identical to Typescript
semantics. It's much stricter and no longer has some persistent bugs
that arose from shady JS handling I wrote years ago.
This PR changes Svelte so that it compiles both with TS5.* and TS7,
which means that occasionally there are duplicative or non-obvious
changes. I'll annotate the interesting changes to explain why I made them.
Because TS7 is quite a way off, I don't know whether you'll want to take
this PR. Most of the changes are for the better, because they're due to
stricter TS-aligned checking. But some are neutral and there is the
previously mentioned duplication in a few places.
* add changeset
* revert scribbles mistakenly added
* pnpm run format
* revert mistaken edit
* return to function declarations w/type tag
* add job to ci.yml
* skipLibCheck for now
* no need for a changeset here
---------
Co-authored-by: Rich Harris <rich.harris@vercel.com>
Co-authored-by: Rich Harris <hello@rich-harris.dev>
* fix: emit `snippet_invalid_export` instead of `undefined_export` for exported snippets
* try this
* this should work
* remove some junk (this never did anything)
* add test
---------
Co-authored-by: Rich Harris <rich.harris@vercel.com>
* Add missing hyphen in "server-side rendering"
* Fix incorrect use of "as such"
* regenerate types
---------
Co-authored-by: Chew Tee Ming <chew.tee.ming@nindatech.com>
* Fix double event processing (#16522)
Firefox seems to garbage collect event objects during event propagation if no global reference to the event object is kept.
That discards the __root marker set on the event object to early,
leading to duplicate processing.
* minor tweaks
---------
Co-authored-by: ComputerGuy <63362464+Ocean-OS@users.noreply.github.com>
* use sh instead of bash in source blocks
no bash-specific functionality is used
* regenerate
---------
Co-authored-by: Rich Harris <rich.harris@vercel.com>
* fix: throw on duplicate class field declarations
* doh
* handle assignment in constructor
* fix
* apply suggestion from review
* fix
* fix failing test
mini-cleanup post #16487 - we don't need to do the work of scheduling an effect that's already dirty which means it already scheduled its root effect to run
* don't mark_reactions inside decrement, it can cause infinite loops
* revert mark_reactions changes
* preserve DIRTY/MAYBE_DIRTY status of deferred effects
* changeset
* tweak
* - add state changes resulting from an $effect to a separate new batch
- schedule rerunning effects based on the sources that are dirty, not just rerunning them all blindly (excempting async effects which will have run by that time already)
* test
* better fix
* tests
* this fixes the last test somehow
* fix#16477
* typo
* copy over changeset from #16477
* copy over changeset from #16464
* changeset
* dedupe
* move flushing_sync check inside Batch.ensure
* unused
* flushing_sync -> is_flushing_sync
* remove flush_effects method
* dedupe declaration
* tweak
* tweak
* update comment — it _does_ feel slightly wrong, but no wronger than the rest of this cursed function
---------
Co-authored-by: Simon Holthausen <simon.holthausen@vercel.com>
Increment the version to ensure any dependent deriveds are marked dirty when the subscription is picked up again later. If we didn't do this then the comparison of write versions would determine that the derived has a later version than the subscriber, and it would not be re-run.
Fixes#16311Fixes#15888
The prior logic was wrong because it reexecuted when something was clean, but we want to when it's not. The remaining fix was to also check the reactions: If an effect is destroyed and it was the last reaction of a derived then the derived is set to `MAYBE_DIRTY`. We therefore also need to check if the derived still has anyone listening to it, and only then reexecute it.
Fixes#16363
Since #9070 it's prefered to use the "enhance svelte elements" way of doing things. That's so long ago that we can now remove the other option from the docs, and eventually remove the backwards compatibility that still allows the old way of doing things.
Fixes#16134
* Add a warning when the misuse of `reset` in an `error:boundary` causes an error to be thrown when flushing the boundary content
* Prevent uncaught errors to make test fails when they are expected and are fired during template effects flush
* reset should just be a noop after the first call
* correctly handle errors inside boundary during reset
* handle errors in the correct boundary
---------
Co-authored-by: Rich Harris <rich.harris@vercel.com>
#16268 introduced a slight regression where the state is not reset completely upon compilation. It did reset warnings but not other state, which meant if file A succeeds but file B fails in the parsing state (before the state was reset for real) it would get wrong filename info. This fixes it by setting the filename at the very beginning.