Skip to content

Commit

Permalink
docs: fix TS config for Svelte 5
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
dummdidumm committed Oct 9, 2024
1 parent 87434dd commit 5fdc8b5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: /(?<!\.svelte)\.ts$/,
loader: "ts-loader",
},
{
// Svelte 5+:
Expand Down

0 comments on commit 5fdc8b5

Please sign in to comment.