Skip to content

Commit fc7ea74

Browse files
authored
fix: remove references to compiler options no longer available in svelte5 (#1010)
* fix: remove references to compiler options no longer available in svelte5 * chore: replace immutable with runes in examples to avoid using a deprecated option
1 parent 339e8d3 commit fc7ea74

File tree

7 files changed

+20
-27
lines changed

7 files changed

+20
-27
lines changed

.changeset/hungry-pans-check.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+
removed references to compiler options no longer available in svelte5

docs/advanced-usage.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,26 +100,22 @@ add `&sourcemap` to `?(raw|direct)&svelte&type=(script|style|all)` queries to in
100100
```js
101101
const compilerOptions = {
102102
dev: false,
103-
generate: 'dom',
104-
css: false,
105-
hydratable: false,
106-
enableSourcemap: false // or {js: true} or {css:true} if sourcemap query is set
103+
generate: 'client',
104+
css: 'external'
107105
};
108106
```
109107
110108
to get output with different compilerOptions, append them as json like this:
111109
112110
```js
113111
//get ssr output of svelte.compile js as {code, map, dependencies}
114-
import script from 'File.svelte?raw&svelte&type=script&compilerOptions={"generate":"ssr"}';
112+
import script from 'File.svelte?raw&svelte&type=script&compilerOptions={"generate":"server"}';
115113
```
116114
117115
only a subset of compilerOptions is supported
118116
119117
- generate
120118
- dev
121119
- css
122-
- hydratable
123120
- customElement
124121
- immutable
125-
- enableSourcemap

docs/config.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,9 @@ A [picomatch pattern](https://github.com/micromatch/picomatch), or array of patt
240240
plugins: [
241241
svelte({
242242
dynamicCompileOptions({ filename, compileOptions }) {
243-
// Dynamically set hydration per Svelte file
244-
if (compileWithHydratable(filename) && !compileOptions.hydratable) {
245-
return { hydratable: true };
243+
// Dynamically set runes mode per Svelte file
244+
if (forceRunesMode(filename) && !compileOptions.runes) {
245+
return { runes: true };
246246
}
247247
}
248248
})

packages/playground/big-component-library-vite-ssr/vite.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { svelte } from '@sveltejs/vite-plugin-svelte';
22
import { defineConfig } from 'vite';
33

44
export default defineConfig({
5-
plugins: [svelte({ prebundleSvelteLibraries: true, compilerOptions: { hydratable: true } })],
5+
plugins: [svelte({ prebundleSvelteLibraries: true })],
66
optimizeDeps: {
77
include: ['carbon-components-svelte', 'carbon-icons-svelte']
88
},

packages/vite-plugin-svelte/src/public.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ export interface PluginOptions {
9292
* @example
9393
* ```
9494
* ({ filename, compileOptions }) => {
95-
* // Dynamically set hydration per Svelte file
96-
* if (compileWithHydratable(filename) && !compileOptions.hydratable) {
97-
* return { hydratable: true };
95+
* // Dynamically set runes mode per Svelte file
96+
* if (forceRunesMode(filename) && !compileOptions.runes) {
97+
* return { runes: true };
9898
* }
9999
* }
100100
* ```

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,7 @@ import { DEFAULT_SVELTE_MODULE_EXT, DEFAULT_SVELTE_MODULE_INFIX } from './consta
88
const VITE_FS_PREFIX = '/@fs/';
99
const IS_WINDOWS = process.platform === 'win32';
1010

11-
const SUPPORTED_COMPILER_OPTIONS = [
12-
'generate',
13-
'dev',
14-
'css',
15-
'hydratable',
16-
'customElement',
17-
'immutable',
18-
'enableSourcemap'
19-
];
11+
const SUPPORTED_COMPILER_OPTIONS = ['generate', 'dev', 'css', 'customElement', 'immutable'];
2012
const TYPES_WITH_COMPILER_OPTIONS = ['style', 'script', 'all'];
2113

2214
/**
@@ -102,7 +94,7 @@ function parseRequestQuery(rawQuery) {
10294
throw new Error(
10395
`Invalid compilerOptions in query ${rawQuery}. CompilerOptions are only supported for raw or direct queries with type in "${TYPES_WITH_COMPILER_OPTIONS.join(
10496
', '
105-
)}" e.g. '?svelte&raw&type=script&compilerOptions={"generate":"ssr","dev":false}`
97+
)}" e.g. '?svelte&raw&type=script&compilerOptions={"generate":"server","dev":false}`
10698
);
10799
}
108100
try {

packages/vite-plugin-svelte/types/index.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ declare module '@sveltejs/vite-plugin-svelte' {
9292
* @example
9393
* ```
9494
* ({ filename, compileOptions }) => {
95-
* // Dynamically set hydration per Svelte file
96-
* if (compileWithHydratable(filename) && !compileOptions.hydratable) {
97-
* return { hydratable: true };
95+
* // Dynamically set runes mode per Svelte file
96+
* if (forceRunesMode(filename) && !compileOptions.runes) {
97+
* return { runes: true };
9898
* }
9999
* }
100100
* ```

0 commit comments

Comments
 (0)