Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore!: remove useVitePreprocess #538

Merged
merged 2 commits into from Dec 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fast-ligers-sort.md
@@ -0,0 +1,5 @@
---
'@sveltejs/vite-plugin-svelte': patch
---

Remove `experimental.useVitePreprocess` option in favour of `vitePreprocess`
7 changes: 0 additions & 7 deletions docs/config.md
Expand Up @@ -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:**
Expand Down
8 changes: 3 additions & 5 deletions 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;
Expand Down
1 change: 0 additions & 1 deletion packages/vite-plugin-svelte/src/index.ts
Expand Up @@ -89,7 +89,6 @@ export function svelte(inlineOptions?: Partial<Options>): 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;
}
},
Expand Down
9 changes: 0 additions & 9 deletions packages/vite-plugin-svelte/src/utils/options.ts
Expand Up @@ -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
*
Expand Down
17 changes: 0 additions & 17 deletions 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
Expand Down Expand Up @@ -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) {
Expand Down