From b27e2f2ffa1362d9a9cbacd8661cf0a1ca5a6b47 Mon Sep 17 00:00:00 2001 From: dominikg Date: Fri, 11 Jul 2025 10:43:18 +0200 Subject: [PATCH 1/4] docs: remove cjs config documentation, mention ts extensions --- docs/config.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/config.md b/docs/config.md index 245e00adc..d1badfb8b 100644 --- a/docs/config.md +++ b/docs/config.md @@ -23,7 +23,8 @@ Besides inline options in Vite config, `vite-plugin-svelte` will also automatica - `svelte.config.js` - `svelte.config.mjs` -- `svelte.config.cjs` +- `svelte.config.ts` +- `svelte.config.mts` To set a specific config file, use the `configFile` inline option. The path can be absolute or relative to the [Vite root](https://vitejs.dev/config/#root). For example: @@ -59,10 +60,10 @@ export default { ### Config file extension -Depending on Node's mode, make sure you're using the correct extension and syntax so it can be resolved safely. +The content of svelte config should always be in esm syntax. Depending on Node's mode, make sure you're using the correct extension. -- If `type: "module"` is defined in `package.json`, using `.js` only allows ESM code. Use `.cjs` to allow CJS code. -- If `type: "module"` is not defined, using `.js` only allows CJS code. Use `.mjs` to allows ESM code. +- If `type: "module"` is defined in `package.json`, prefer `.js` or `.ts` +- If `type: "module"` is not defined, use `.mjs` or `.mts` > Try to stick with the `.js` extension whenever possible. From 390dec3390bc48bc0e9f30b76ce3335284f209bc Mon Sep 17 00:00:00 2001 From: dominikg Date: Fri, 11 Jul 2025 10:54:35 +0200 Subject: [PATCH 2/4] add missing options, improve language --- docs/config.md | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/docs/config.md b/docs/config.md index d1badfb8b..7eb3690ab 100644 --- a/docs/config.md +++ b/docs/config.md @@ -44,7 +44,7 @@ A basic Svelte config looks like this: ```js // svelte.config.js export default { - // svelte options + // Svelte options extensions: ['.svelte'], compilerOptions: {}, preprocess: [], @@ -60,7 +60,7 @@ export default { ### Config file extension -The content of svelte config should always be in esm syntax. Depending on Node's mode, make sure you're using the correct extension. +The content of Svelte config should always be in esm syntax. Depending on Node's mode, make sure you're using the correct extension. - If `type: "module"` is defined in `package.json`, prefer `.js` or `.ts` - If `type: "module"` is not defined, use `.mjs` or `.mts` @@ -77,7 +77,7 @@ export default defineConfig({ plugins: [ svelte({ configFile: false - // your svelte config here + // your Svelte config here }) ] }); @@ -158,12 +158,14 @@ These options are specific to the Vite plugin itself. ### include - **Type:** `string | string[]` +- **Default:** unset -A [picomatch pattern](https://github.com/micromatch/picomatch), or array of patterns, which specifies the files the plugin should operate on. By default, all svelte files are included. +A [picomatch pattern](https://github.com/micromatch/picomatch), or array of patterns, which specifies the files the plugin should operate on **in addition** to the files ending with one of the configured extensions. ### exclude - **Type:** `string | string[]` +- **Default:** unset A [picomatch pattern](https://github.com/micromatch/picomatch), or array of patterns, which specifies the files to be ignored by the plugin. By default, no files are ignored. @@ -216,7 +218,7 @@ A [picomatch pattern](https://github.com/micromatch/picomatch), or array of patt - **Type:** `InspectorOptions | boolean` - **Default:** `unset` for dev, always `false` for build - Set to `true` or options object to enable svelte inspector during development. See the [inspector docs](./inspector.md) for the full configuration options. + Set to `true` or options object to enable Svelte inspector during development. See the [inspector docs](./inspector.md) for the full configuration options. Inspector mode shows you the file location where the element under cursor is defined and you can click to quickly open your code editor at this location. @@ -309,7 +311,7 @@ export default { normalizedFilename: string; timestamp: number; warnings: Warning[]; // allWarnings filtered by warnings where onwarn did not call the default handler - allWarnings: Warning[]; // includes warnings filtered by onwarn and our extra vite plugin svelte warnings + allWarnings: Warning[]; // includes warnings filtered by onwarn and our extra vite-plugin-svelte warnings rawWarnings: Warning[]; // raw compiler output }; ``` @@ -319,4 +321,18 @@ export default { - **Type** `boolean` - **Default:** `false` - disable svelte resolve warnings. Note: this is highly discouraged and you should instead fix these packages which will break in the future. + disable Svelte resolve warnings. Note: this is highly discouraged and you should instead fix these packages which will break in the future. + +### disableApiSveltePreprocessWarnings + +- **Type** `boolean` +- **Default:** `false` + + disable api.sveltePreprocess deprecation warnings + +### compileModule + +- **Type** `CompileModuleOptions` +- **Default:** `undefined` + + set custom compile options for compilation Svelte modules (`.svelte.js` files). From a4b97c2ffcf9076b7bca948c45d16b59d761f380 Mon Sep 17 00:00:00 2001 From: "Dominik G." Date: Fri, 11 Jul 2025 09:38:08 +0000 Subject: [PATCH 3/4] Update docs/config.md Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com> --- docs/config.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/config.md b/docs/config.md index 7eb3690ab..8ce941075 100644 --- a/docs/config.md +++ b/docs/config.md @@ -60,7 +60,7 @@ export default { ### Config file extension -The content of Svelte config should always be in esm syntax. Depending on Node's mode, make sure you're using the correct extension. +The Svelte config should always be written in ESM syntax. Depending on Node's mode, make sure you're using the correct extension. - If `type: "module"` is defined in `package.json`, prefer `.js` or `.ts` - If `type: "module"` is not defined, use `.mjs` or `.mts` From 0a20cc9ac5c5152003b5cce5f66b555c16aaec2d Mon Sep 17 00:00:00 2001 From: "Dominik G." Date: Fri, 11 Jul 2025 09:39:49 +0000 Subject: [PATCH 4/4] Update docs/config.md --- docs/config.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/config.md b/docs/config.md index 8ce941075..3d5921236 100644 --- a/docs/config.md +++ b/docs/config.md @@ -335,4 +335,4 @@ export default { - **Type** `CompileModuleOptions` - **Default:** `undefined` - set custom compile options for compilation Svelte modules (`.svelte.js` files). + set custom compile options for compilation of Svelte modules (`.svelte.js` files).