Skip to content

Commit 132dd79

Browse files
authored
docs: preprocessor migration details (#8927)
closes #8916
1 parent 70426be commit 132dd79

File tree

1 file changed

+66
-1
lines changed

1 file changed

+66
-1
lines changed

documentation/docs/05-misc/04-v4-migration-guide.md

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,72 @@ This makes slot bindings more consistent as the behavior is undefined when for e
157157

158158
## Preprocessors
159159

160-
The order in which preprocessors are applied has changed. Now, preprocessors are executed in order, and within one group, the order is markup, script, style. Each preprocessor must also have a name. ([#8618](https://github.com/sveltejs/svelte/issues/8618))
160+
The order in which preprocessors are applied has changed. Now, preprocessors are executed in order, and within one group, the order is markup, script, style.
161+
162+
```js
163+
// @errors: 2304
164+
import { preprocess } from 'svelte/compiler';
165+
166+
const { code } = await preprocess(
167+
source,
168+
[
169+
{
170+
markup: () => {
171+
console.log('markup-1');
172+
},
173+
script: () => {
174+
console.log('script-1');
175+
},
176+
style: () => {
177+
console.log('style-1');
178+
}
179+
},
180+
{
181+
markup: () => {
182+
console.log('markup-2');
183+
},
184+
script: () => {
185+
console.log('script-2');
186+
},
187+
style: () => {
188+
console.log('style-2');
189+
}
190+
}
191+
],
192+
{
193+
filename: 'App.svelte'
194+
}
195+
);
196+
197+
// Svelte 3 logs:
198+
// markup-1
199+
// markup-2
200+
// script-1
201+
// script-2
202+
// style-1
203+
// style-2
204+
205+
// Svelte 4 logs:
206+
// markup-1
207+
// script-1
208+
// style-1
209+
// markup-2
210+
// script-2
211+
// style-2
212+
```
213+
214+
This could affect you for example if you are using `MDsveX` - in which case you should make sure it comes before any script or style preprocessor.
215+
216+
```diff
217+
preprocess: [
218+
- vitePreprocess(),
219+
- mdsvex(mdsvexConfig)
220+
+ mdsvex(mdsvexConfig),
221+
+ vitePreprocess()
222+
]
223+
```
224+
225+
Each preprocessor must also have a name. ([#8618](https://github.com/sveltejs/svelte/issues/8618))
161226

162227
## New eslint package
163228

0 commit comments

Comments
 (0)