-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Reactive declarations are reordered in compiled files and run in unexpected order #5905
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
Comments
Very good |
They're ordered according to the dependencies that the compiler can see in the reactive blocks. |
Following up on Conduitry's general explanation, here's how you do it in your case: $: init(object)
$: if (indentsLocked) {
changeRidgeIndentRight(object);
}
$: if (overhangsLocked) changeOverhangSide(object) -> no assignment to |
@Conduitry thanks for clarification, but what is the recommended way to enforce the correct order if compiler does it wrongly? |
Describe the bug
It seems that developer cannot control the order of execution of reactive statements prefixed with
$:
Given the source (where it is very important to run init first):
The compiler reorders the init to be last:
Logs
Not relevant
To Reproduce
https://svelte.dev/repl/f1ae2c3d30034d519c13cd647989d0b0?version=3.31.2
Expected behavior
Developer can control the order of execution, Preferably, the order is the same as defined in source file.
Stacktraces
If you have a stack trace to include, we recommend putting inside a
<details>
block for the sake of the thread's readability:Information about your Svelte project:
System:
OS: Linux 5.4 Ubuntu 20.04.1 LTS (Focal Fossa)
CPU: (8) x64 Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz
Memory: 2.97 GB / 15.59 GB
Container: Yes
Shell: 5.0.17 - /bin/bash
Binaries:
Node: 15.0.1 - /usr/local/bin/node
npm: 7.0.3 - /usr/local/bin/npm
Browsers:
Chrome: 87.0.4280.141
Firefox: 84.0.2
npmPackages:
svelte: ^3.31.2 => 3.31.2
We use snowpack (probably not relevant)
Severity
Not easy to find a workaround, because reordering of reactive statements is undocumented.
The text was updated successfully, but these errors were encountered: