Skip to content

Commit 5fdc8b5

Browse files
committed
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
1 parent 87434dd commit 5fdc8b5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

README.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,16 @@ Configure inside your `webpack.config.js`:
3232
module: {
3333
rules: [
3434
...
35-
// This is only needed if you use Svelte 5+ with TypeScript
35+
// The following two loader entries are only needed if you use Svelte 5+ with TypeScript.
36+
// Also make sure your tsconfig.json includes `"target": "ESNext"` in order to not downlevel syntax
3637
{
3738
test: /\.svelte\.ts$/,
38-
use: ['ts-loader', 'svelte-loader']
39+
use: [ "svelte-loader", "ts-loader"],
40+
},
41+
// This is the config for other .ts files - the regex makes sure to not process .svelte.ts files twice
42+
{
43+
test: /(?<!\.svelte)\.ts$/,
44+
loader: "ts-loader",
3945
},
4046
{
4147
// Svelte 5+:

0 commit comments

Comments
 (0)