-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Describe the bug
SvelteKit 2 does not seem to transform production code correctly when build.target is set to es2015 in vite.config.js.
The following error pops up in the console when opening the demo app in a browser that does not support Logical assignments:
SyntaxError: expected expression, got '='
This is due to the presence of a de||=Promise.resolve() in the built code, even though the build target is set to es2015.
A fresh vanilla Vite 5 project with es2015 target does not reproduce this, and works as it should, transforming logical assignments as expected.
Reproduction
-
Repo is here: https://github.com/bleucitron/sk2-transform-bug
-
Run
npm i
npm run build
npm run preview
- Search for
de||=in the.svelte-kitfolder
or
-
Open built app in a browser that does not support logical assignment syntax (Firefox 78.15 in my tests, you can find sources here)
-
Open the console, and witness the error
Logs
No response
System Info
System:
OS: macOS 14.1.2
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 907.93 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.17.1 - ~/.nvm/versions/node/v18.17.1/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 9.6.7 - ~/.nvm/versions/node/v18.17.1/bin/npm
pnpm: 8.9.0 - /usr/local/bin/pnpm
bun: 1.0.10 - ~/.bun/bin/bun
Watchman: 4.9.0 - /usr/local/bin/watchman
Browsers:
Brave Browser: 120.1.61.116
Chrome: 120.0.6099.216
Edge: 120.0.2210.133
Safari: 17.1.2
npmPackages:
@sveltejs/adapter-auto: ^3.0.0 => 3.1.0
@sveltejs/kit: ^2.3.3 => 2.3.3
@sveltejs/vite-plugin-svelte: ^3.0.0 => 3.0.1
svelte: ^4.2.7 => 4.2.8
vite: ^5.0.11 => 5.0.11Severity
blocking an upgrade
Additional Information
No response