Closed bhvngt closed 3 years ago
upgrade to svench@0.2.0-30 (when investigating your problem, I discovered that we had a compatibility issues with latest versions of @sveltejs/vite-plugin-svelte
)
I assumed you were using "type": "module"
in your package.json
move your Svelte plugin config to svelte.config.js
Historically, Svench was CJS based and used proxyquire
wizardry to replace and steal config of your Svelte plugin... Now with native ESM this is way harder to achieve and doesn't seem to be worth the trouble, so we gave up on trying to retrieve the Svelte plugin config from inside your rollup.config.js
, vite.config.js
or so, and instead only base on what's present in svelte.config.js
.
So, in your case:
vite.config.js
:import { defineConfig } from 'vite'
import { svelte } from '@sveltejs/vite-plugin-svelte'
export default defineConfig({
plugins: [svelte()],
})
svelte.config.js
:import preprocess from 'svelte-preprocess'
export default {
preprocess: preprocess({ typescript: true }),
}
Does this work for you?
Thank you so much @rixo for your detailed explanation. You rock man!!! It totally works.
Shift from cjs
to esm
has been quite a learning experience for me too. I am closing this issue and will look forward to using svench
:-)
I am stuck with making
typescript
work withsvench
. It works fine when it is run with onlyvite
. Any hint to solve this will be highly appreciated.Here's my setup
vite.config.js
src/Component.svelte
package.json
tsconfig.json
It throws following error when it sees any typescript syntax
on the vite cli it throws