diff --git a/.changeset/eleven-hats-search.md b/.changeset/eleven-hats-search.md new file mode 100644 index 000000000..88d3a9934 --- /dev/null +++ b/.changeset/eleven-hats-search.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/vite-plugin-svelte': patch +--- + +feat: support Svelte 5 compiler API diff --git a/packages/e2e-tests/autoprefixer-browerslist/package.json b/packages/e2e-tests/autoprefixer-browerslist/package.json index 1935658d5..f6099b39c 100644 --- a/packages/e2e-tests/autoprefixer-browerslist/package.json +++ b/packages/e2e-tests/autoprefixer-browerslist/package.json @@ -13,7 +13,7 @@ "devDependencies": { "@sveltejs/vite-plugin-svelte": "workspace:^", "autoprefixer": "^10.4.15", - "postcss": "^8.4.29", + "postcss": "^8.4.31", "postcss-load-config": "^4.0.1", "svelte": "^4.2.0", "svelte-preprocess": "^5.0.4", diff --git a/packages/vite-plugin-svelte/src/index.js b/packages/vite-plugin-svelte/src/index.js index 04b484d4e..8020a09ca 100644 --- a/packages/vite-plugin-svelte/src/index.js +++ b/packages/vite-plugin-svelte/src/index.js @@ -298,7 +298,7 @@ export function svelte(inlineOptions) { try { // @ts-ignore doesn't exist in Svelte 4 const compileResult = await svelteCompiler.compileModule(code, { - generate: ssr ? 'ssr' : 'dom', + generate: isSvelte5 ? (ssr ? 'server' : 'client') : ssr ? 'ssr' : 'dom', filename: moduleRequest.filename }); logCompilerWarnings(moduleRequest, compileResult.warnings, options); diff --git a/packages/vite-plugin-svelte/src/utils/compile.js b/packages/vite-plugin-svelte/src/utils/compile.js index 11c975035..3ac308784 100644 --- a/packages/vite-plugin-svelte/src/utils/compile.js +++ b/packages/vite-plugin-svelte/src/utils/compile.js @@ -9,7 +9,7 @@ import { mapToRelative } from './sourcemaps.js'; const scriptLangRE = /