Skip to content

Commit f06beb3

Browse files
dominikgdummdidumm
andauthored
docs(vitePreprocess): ts is no longer preprocessed by default (#974)
* docs(vitePreprocess): change wording to show that script is no longer preprocessed by default * docs(vitePreprocess): more details around new script default * Apply suggestions from code review Co-authored-by: Simon H <[email protected]> --------- Co-authored-by: Simon H <[email protected]>
1 parent 18d53e3 commit f06beb3

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

docs/preprocess.md

+24-11
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
`vite-plugin-svelte` also exports Vite preprocessors to preprocess Svelte components using Vite's built-in transformers.
44

5-
Compared to [`svelte-preprocess`](https://github.com/sveltejs/svelte-preprocess), Vite preprocessors share the same CSS configuration from the Vite config so you don't have to configure them twice. [`esbuild`](http://esbuild.github.io) is also used to transform TypeScript by default.
5+
Compared to [`svelte-preprocess`](https://github.com/sveltejs/svelte-preprocess), Vite preprocessors share the same CSS configuration from the Vite config so you don't have to configure them twice. [`esbuild`](http://esbuild.github.io) can also be used to transform TypeScript.
66

77
However, `svelte-preprocess` does provide extra functionalities not available with Vite preprocessors, such as [template tag](https://github.com/sveltejs/svelte-preprocess#template-tag), [external files](https://github.com/sveltejs/svelte-preprocess#external-files), and [global styles](https://github.com/sveltejs/svelte-preprocess#global-style) ([though it's recommended to use import instead](./faq.md#where-should-i-put-my-global-styles)). If those features are required, you can still use `svelte-preprocess`, but make sure to turn off it's script and style preprocessing options.
88

99
## vitePreprocess
1010

1111
- **Type:** `{ script?: boolean, style?: boolean | InlineConfig | ResolvedConfig }`
12-
- **Default:** `{ script: true, style: true }`
12+
- **Default:** `{ script: false, style: true }`
1313

1414
A Svelte preprocessor that supports transforming TypeScript, PostCSS, SCSS, Less, Stylus, and SugarSS. These are transformed when the script or style tags have the respective `lang` attribute.
1515

@@ -20,16 +20,29 @@ However, `svelte-preprocess` does provide extra functionalities not available wi
2020
- SugarSS: `<style lang="sss">`
2121

2222
By default, PostCSS or LightningCSS ([if configured in Vite](https://vitejs.dev/config/shared-options.html#css-transformer)) is applied to all `<style>` tags.
23+
If required, you can turn transforming off by setting the `style` option to `false`. The `style` option also accepts Vite's `InlineConfig` and `ResolvedConfig` types for advanced usage.
2324

24-
If required, you can turn script or style transforming off by setting the `script` or `style` option to `false`. The `style` option also accepts Vite's `InlineConfig` and `ResolvedConfig` types for advanced usage.
25+
TypeScript is no longer preprocessed by default as Svelte 5 understands most syntax natively.
26+
If you use TypeScript features that emit code (like `enum`, `using`, `accessors`, decorators or class declarations with visibility modifiers), you have to enable the script preprocessor by setting the `script` option to `true`.
2527

26-
**Example:**
28+
### Examples
2729

28-
```js
29-
// svelte.config.js
30-
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
30+
#### default
3131

32-
export default {
33-
preprocess: [vitePreprocess()]
34-
};
35-
```
32+
```js
33+
// svelte.config.js
34+
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
35+
export default {
36+
preprocess: [vitePreprocess()]
37+
};
38+
```
39+
40+
#### enable script preprocessing for advanced TypeScript syntax use
41+
42+
```js
43+
// svelte.config.js
44+
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
45+
export default {
46+
preprocess: [vitePreprocess({ script: true })]
47+
};
48+
```

0 commit comments

Comments
 (0)