You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
void <identifier> statements are removed, you can test by running await transform("<input>"):
// input:leta=123;voida// output:leta=123;
Why does this matter?
In Svelte, runes are used to implement reactivity. For example, let a = $state(123) is transformed into let a = $.state(123), and all accesses of the variable are transformed from a to $.get(a). Most importantly, $.get() inside special sections called effects, will be tracked, causing the effect code to re-run whenever the variable changes. Svelte's transformation happens after esbuild.
If esbuild were to run on this code, the void statement won't get removed, as it knows side-effects are possible.
Problem
I couldn't find a combination of options to prevent the void statement from getting removed. Is there an option to stop this from happening? If not, then I think either esbuild shouldn't remove such statements by default, especially when tree-shaking is not enabled, or at least this should be configurable somehow.
The text was updated successfully, but these errors were encountered:
Because of many reasons: this is the Vite pipeline, which uses esbuild before any other plugin, among other things, to transform Typescript into Javascript.
Cause
void <identifier>
statements are removed, you can test by runningawait transform("<input>")
:Why does this matter?
In Svelte, runes are used to implement reactivity. For example,
let a = $state(123)
is transformed intolet a = $.state(123)
, and all accesses of the variable are transformed froma
to$.get(a)
. Most importantly,$.get()
inside special sections called effects, will be tracked, causing the effect code to re-run whenever the variable changes. Svelte's transformation happens after esbuild.Sample transformation:
The correct final output should be:
If esbuild were to run on this code, the void statement won't get removed, as it knows side-effects are possible.
Problem
I couldn't find a combination of options to prevent the
void
statement from getting removed. Is there an option to stop this from happening? If not, then I think either esbuild shouldn't remove such statements by default, especially when tree-shaking is not enabled, or at least this should be configurable somehow.The text was updated successfully, but these errors were encountered: