Skip to content

Commit 3a45ae3

Browse files
authored
feat: promote experimental.dynamicCompileOptions (#765)
* feat: promote experimental.dynamicCompileOptions * fix: prevent prettier from removing leading ws of testcase
1 parent b4b4fdd commit 3a45ae3

File tree

16 files changed

+163
-52
lines changed

16 files changed

+163
-52
lines changed

.changeset/nasty-queens-beam.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+
feat(compile): promote experimental.dynamicCompileOptions to stable

.prettierrc.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,14 @@ export default {
1515
options: { parser: 'typescript' }
1616
},
1717
{
18-
files: ['**/CHANGELOG.md', '.github/renovate.json5'],
18+
files: [
19+
'**/vite.config.js.timestamp-*.mjs',
20+
'**/CHANGELOG.md',
21+
'.github/renovate.json5',
22+
'packages/e2e-tests/dynamic-compile-options/src/components/A.svelte'
23+
],
1924
options: {
20-
requirePragma: true
25+
rangeEnd: 0
2126
}
2227
},
2328
{

docs/config.md

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -221,38 +221,6 @@ A [picomatch pattern](https://github.com/micromatch/picomatch), or array of patt
221221

222222
Inspector mode shows you the file location where the element under cursor is defined and you can click to quickly open your code editor at this location.
223223

224-
## Experimental options
225-
226-
These options are considered experimental and breaking changes to them can occur in any release! Specify them under the `experimental` option.
227-
228-
Either in Vite config:
229-
230-
```js
231-
// vite.config.js
232-
export default defineConfig({
233-
plugins: [
234-
svelte({
235-
experimental: {
236-
// experimental options
237-
}
238-
})
239-
]
240-
});
241-
```
242-
243-
or in Svelte config:
244-
245-
```js
246-
// svelte.config.js
247-
export default {
248-
vitePlugin: {
249-
experimental: {
250-
// experimental options
251-
}
252-
}
253-
};
254-
```
255-
256224
### dynamicCompileOptions
257225

258226
- **Type:**
@@ -287,6 +255,38 @@ export default {
287255
});
288256
```
289257

258+
## Experimental options
259+
260+
These options are considered experimental and breaking changes to them can occur in any release! Specify them under the `experimental` option.
261+
262+
Either in Vite config:
263+
264+
```js
265+
// vite.config.js
266+
export default defineConfig({
267+
plugins: [
268+
svelte({
269+
experimental: {
270+
// experimental options
271+
}
272+
})
273+
]
274+
});
275+
```
276+
277+
or in Svelte config:
278+
279+
```js
280+
// svelte.config.js
281+
export default {
282+
vitePlugin: {
283+
experimental: {
284+
// experimental options
285+
}
286+
}
287+
};
288+
```
289+
290290
### sendWarningsToBrowser
291291

292292
- **Type:** `boolean`
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { getText } from '~utils';
2+
3+
test('should respect dynamic compile option preserveWhitespace: true for A', async () => {
4+
expect(await getText('#A')).toBe(' preserved leading whitespace');
5+
expect(await getText('#B')).toBe('removed leading whitespace');
6+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width,initial-scale=1" />
6+
7+
<title>Svelte app</title>
8+
9+
<script type="module" src="/src/main.js"></script>
10+
</head>
11+
12+
<body></body>
13+
</html>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "e2e-tests-custom-extensions",
3+
"private": true,
4+
"version": "1.0.0",
5+
"scripts": {
6+
"build": "vite build",
7+
"dev": "vite",
8+
"preview": "vite preview"
9+
},
10+
"devDependencies": {
11+
"@sveltejs/vite-plugin-svelte": "workspace:^",
12+
"svelte": "^4.2.1",
13+
"vite": "^5.0.0-beta.4"
14+
},
15+
"type": "module"
16+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<script>
2+
import A from './components/A.svelte';
3+
import B from './components/B.svelte';
4+
</script>
5+
6+
<A />
7+
<B />
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<div id="A"> preserved leading whitespace</div>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<div id="B">removed leading whitespace</div>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import App from './App.svelte';
2+
3+
const app = new App({
4+
target: document.body
5+
});
6+
7+
export default app;

0 commit comments

Comments
 (0)