tauri2.xrc-svelte5 Svelte Themes

Tauri2.xrc Svelte5

Tauri Javascript Logical OR operator throws SyntaxError Repro

[tauri] Javascript Logical OR operator throws SyntaxError Repro

To run this repro, follow the commands below:

# clone the repo to local machine
git clone https://github.com/lnfel/tauri2.xrc-svelte5.git
# cd into project
cd tauri2.xrc-svelte5
# install dependencies
pnpm i
# build sveltekit, tauri uses the build directory as the frontendDist
pnpm build
# run tauri with front-end
pnpm tauri dev

After running tauri, the window should appear with nothing being displayed, this is due to a Syntax Error within tauri/wry/tao (or something that tries to validate javascript syntax). Open the console window console by pressing the key shortcut:

# on macOS
alt + cmd + i
# on windows
ctrl + shift + i

The error is shown to occur on the line where ||= is located, this is a valid Javascript operator, but for some reason, tauri deems it as not valid:

await (pending_invalidate ||= Promise.resolve());

We can override the local code and change it to something like:

pending_invalidate = pending_invalidate || Promise.resolve();

And the tauri app window should update with our greeting component, the functionality also works.

Top categories

svelte logo

Need a Svelte website built?

Hire a professional Svelte developer today.
Loading Svelte Themes