diff --git a/.changeset/fast-ligers-sort.md b/.changeset/fast-ligers-sort.md new file mode 100644 index 000000000..f3349976a --- /dev/null +++ b/.changeset/fast-ligers-sort.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/vite-plugin-svelte': patch +--- + +Remove `experimental.useVitePreprocess` option in favour of `vitePreprocess` diff --git a/docs/config.md b/docs/config.md index f898d319d..cbe9ae0ff 100644 --- a/docs/config.md +++ b/docs/config.md @@ -244,13 +244,6 @@ export default { }; ``` -### useVitePreprocess - -- **Type:** `boolean` -- **Default:** `false` - - Use extra preprocessors that delegate style and TypeScript preprocessing to native Vite plugins. TypeScript will be transformed with esbuild. Styles will be transformed using [Vite's CSS plugin](https://vitejs.dev/guide/features.html#css), which handles `@imports`, `url()` references, PostCSS, CSS Modules, and `.scss`/`.sass`/`.less`/`.styl`/`.stylus` files. Do not use together with TypeScript or style preprocessors from `svelte-preprocess` as attempts to transform the content twice will fail! - ### dynamicCompileOptions - **Type:** diff --git a/packages/e2e-tests/import-queries/svelte.config.js b/packages/e2e-tests/import-queries/svelte.config.js index f3a4f4ccb..4abe56d7f 100644 --- a/packages/e2e-tests/import-queries/svelte.config.js +++ b/packages/e2e-tests/import-queries/svelte.config.js @@ -1,9 +1,7 @@ +import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; + export default { - vitePlugin: { - experimental: { - useVitePreprocess: true - } - }, + preprocess: [vitePreprocess()], onwarn(warning, defaultHandler) { // import query test generates one of these if (warning.code === 'custom-element-no-tag') return; diff --git a/packages/vite-plugin-svelte/src/index.ts b/packages/vite-plugin-svelte/src/index.ts index 48d751b5f..eef2004bf 100644 --- a/packages/vite-plugin-svelte/src/index.ts +++ b/packages/vite-plugin-svelte/src/index.ts @@ -89,7 +89,6 @@ export function svelte(inlineOptions?: Partial): Plugin[] { if (isSvelteMetadataChanged) { // Force Vite to optimize again. Although we mutate the config here, it works because // Vite's optimizer runs after `buildStart()`. - // TODO: verify this works in vite3 viteConfig.optimizeDeps.force = true; } }, diff --git a/packages/vite-plugin-svelte/src/utils/options.ts b/packages/vite-plugin-svelte/src/utils/options.ts index db7efe593..09163b14e 100644 --- a/packages/vite-plugin-svelte/src/utils/options.ts +++ b/packages/vite-plugin-svelte/src/utils/options.ts @@ -680,15 +680,6 @@ export interface SvelteOptions { * These options are considered experimental and breaking changes to them can occur in any release */ export interface ExperimentalOptions { - /** - * Use extra preprocessors that delegate style and TypeScript preprocessing to native Vite plugins - * - * Do not use together with `svelte-preprocess`! - * - * @default false - */ - useVitePreprocess?: boolean; - /** * A function to update `compilerOptions` before compilation * diff --git a/packages/vite-plugin-svelte/src/utils/preprocess.ts b/packages/vite-plugin-svelte/src/utils/preprocess.ts index 4d0c59f27..3223bf6ba 100644 --- a/packages/vite-plugin-svelte/src/utils/preprocess.ts +++ b/packages/vite-plugin-svelte/src/utils/preprocess.ts @@ -1,18 +1,8 @@ import type { ResolvedConfig, Plugin } from 'vite'; import MagicString from 'magic-string'; -import { preprocess } from 'svelte/compiler'; import { PreprocessorGroup, ResolvedOptions } from './options'; import { log } from './log'; import path from 'path'; -import { vitePreprocess } from '../preprocess'; - -function createVitePreprocessorGroup(config: ResolvedConfig): PreprocessorGroup { - return { - markup({ content, filename }) { - return preprocess(content, vitePreprocess({ style: config }), { filename }); - } - }; -} /** * this appends a *{} rule to component styles to force the svelte compiler to add style classes to all nodes @@ -40,13 +30,6 @@ function buildExtraPreprocessors(options: ResolvedOptions, config: ResolvedConfi const prependPreprocessors: PreprocessorGroup[] = []; const appendPreprocessors: PreprocessorGroup[] = []; - if (options.experimental?.useVitePreprocess) { - log.warn( - '`experimental.useVitePreprocess` is deprecated. Use the `vitePreprocess()` preprocessor instead. See https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/preprocess.md for more information.' - ); - prependPreprocessors.push(createVitePreprocessorGroup(config)); - } - // @ts-ignore const pluginsWithPreprocessorsDeprecated = config.plugins.filter((p) => p?.sveltePreprocess); if (pluginsWithPreprocessorsDeprecated.length > 0) {