Open kran6a opened 3 months ago
Typically in Vite if you want to use very new syntax like this, you need to configure this Vite config:
esbuild: {
// either this
target: 'es2023',
// or this config also works
supported: {
using: false
}
}
However our preprocessor runs its own setup so that config doesn't influence how it runs in Svelte files:
The target: 'esnext'
prevents any down-transpilation (in this case using
) so it errors in parsing by Svelte next. Seems like the script preprocessor may also need to be influenced by the resolved Vite config like the style preprocessor to support this ootb 🤔
in the interim, you might be able to use svelte-preprocess instead, that uses typescript under the hood.
The reasoning for using target esnext was that the resulting js output is going through vite anyways, so any downleveling would happen there. But obviously this only covers js features, not ts
supported: { using: false }
Tried forking vite-plugin-svelte
and using these configs but neither of them work.
The using
keyword gets transpiled but then the $props()
call end up inside a try block causing $props() can only be used at the top level of components as a variable declaration initializer
.
your reproduction does not contain use of $props and you did not share your fork, so we can't tell whats going on.
Describe the bug
The
using
keyword seems to be unsupported within.svelte
files.Reproduction URL
https://stackblitz.com/edit/vitejs-vite-jnn3rq
Reproduction
No response
Logs
No response
System Info