Skip to content

Commit 25ce39c

Browse files
committed
chore: deprecate plugin.api.sveltePreprocess
1 parent e8089d3 commit 25ce39c

File tree

3 files changed

+8
-30
lines changed

3 files changed

+8
-30
lines changed

.changeset/two-facts-sink.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/vite-plugin-svelte': patch
3+
---
4+
5+
deprecate `plugin.api.sveltePreprocess`

docs/faq.md

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,7 @@ However, `cssHash` is respected in production builds as HMR is a dev-only featur
8282

8383
### How do I add a Svelte preprocessor from a Vite plugin?
8484

85-
If you are building a Vite plugin that transforms CSS or JS, you can add a `api.sveltePreprocess: PreprocessorGroup` to your Vite plugin definition and it will be added to the list of Svelte preprocessors used at runtime.
86-
87-
```js
88-
const vitePluginCoolCss = {
89-
name: 'vite-plugin-coolcss',
90-
api: {
91-
sveltePreprocess: {
92-
/* your PreprocessorGroup here */
93-
}
94-
}
95-
/*... your cool css plugin implementation here .. */
96-
};
97-
```
85+
You don't have to anymore. See [advanced usage](advanced-usage.md) for examples how to put transform hooks before or after Svelte preprocess or compile
9886

9987
### What is going on with Vite and `Pre-bundling dependencies:`?
10088

packages/vite-plugin-svelte/src/utils/preprocess.js

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,13 @@ function buildExtraPreprocessors(options, config) {
1515
/** @type {import('svelte/compiler').PreprocessorGroup[]} */
1616
const appendPreprocessors = [];
1717

18-
// @ts-expect-error not typed
19-
const pluginsWithPreprocessorsDeprecated = config.plugins.filter((p) => p?.sveltePreprocess);
18+
const pluginsWithPreprocessorsDeprecated = config.plugins.filter((p) => p.api?.sveltePreprocess);
2019
if (pluginsWithPreprocessorsDeprecated.length > 0) {
2120
log.warn(
22-
`The following plugins use the deprecated 'plugin.sveltePreprocess' field. Please contact their maintainers and ask them to move it to 'plugin.api.sveltePreprocess': ${pluginsWithPreprocessorsDeprecated
21+
`The following plugins use the deprecated 'plugin.api.sveltePreprocess' field. Please contact their maintainers and ask them to use a vite plugin transform instead: ${pluginsWithPreprocessorsDeprecated
2322
.map((p) => p.name)
2423
.join(', ')}`
2524
);
26-
// patch plugin to avoid breaking
27-
pluginsWithPreprocessorsDeprecated.forEach((p) => {
28-
if (!p.api) {
29-
p.api = {};
30-
}
31-
if (p.api.sveltePreprocess === undefined) {
32-
// @ts-expect-error not typed
33-
p.api.sveltePreprocess = p.sveltePreprocess;
34-
} else {
35-
log.error(
36-
`ignoring plugin.sveltePreprocess of ${p.name} because it already defined plugin.api.sveltePreprocess.`
37-
);
38-
}
39-
});
4025
}
4126
/** @type {import('vite').Plugin[]} */
4227
const pluginsWithPreprocessors = config.plugins.filter((p) => p?.api?.sveltePreprocess);

0 commit comments

Comments
 (0)