From 5fdc8b519547212f4c9ebe84fd58eb5e11d8a12b Mon Sep 17 00:00:00 2001 From: Simon Holthausen Date: Wed, 9 Oct 2024 23:11:35 +0200 Subject: [PATCH] docs: fix TS config for Svelte 5 - ts-loader needs to come after svelte-loader, as webpack runs them in backwards order - loader config for `.ts` files should exclude `.svelte.ts` file - mention `tsconfig.json` target config to not downlevel for example class features which would result in a weird error ("$state not allowed here") closes #241 --- README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2da46ca4..64f75f8f 100644 --- a/README.md +++ b/README.md @@ -32,10 +32,16 @@ Configure inside your `webpack.config.js`: module: { rules: [ ... - // This is only needed if you use Svelte 5+ with TypeScript + // The following two loader entries are only needed if you use Svelte 5+ with TypeScript. + // Also make sure your tsconfig.json includes `"target": "ESNext"` in order to not downlevel syntax { test: /\.svelte\.ts$/, - use: ['ts-loader', 'svelte-loader'] + use: [ "svelte-loader", "ts-loader"], + }, + // This is the config for other .ts files - the regex makes sure to not process .svelte.ts files twice + { + test: /(?