-
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: promote experimental.dynamicCompileOptions (#765)
* feat: promote experimental.dynamicCompileOptions * fix: prevent prettier from removing leading ws of testcase
- Loading branch information
Showing
16 changed files
with
163 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@sveltejs/vite-plugin-svelte': patch | ||
--- | ||
|
||
feat(compile): promote experimental.dynamicCompileOptions to stable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
packages/e2e-tests/dynamic-compile-options/__tests__/dynamic-compile-options.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { getText } from '~utils'; | ||
|
||
test('should respect dynamic compile option preserveWhitespace: true for A', async () => { | ||
expect(await getText('#A')).toBe(' preserved leading whitespace'); | ||
expect(await getText('#B')).toBe('removed leading whitespace'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width,initial-scale=1" /> | ||
|
||
<title>Svelte app</title> | ||
|
||
<script type="module" src="/src/main.js"></script> | ||
</head> | ||
|
||
<body></body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "e2e-tests-custom-extensions", | ||
"private": true, | ||
"version": "1.0.0", | ||
"scripts": { | ||
"build": "vite build", | ||
"dev": "vite", | ||
"preview": "vite preview" | ||
}, | ||
"devDependencies": { | ||
"@sveltejs/vite-plugin-svelte": "workspace:^", | ||
"svelte": "^4.2.1", | ||
"vite": "^5.0.0-beta.4" | ||
}, | ||
"type": "module" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<script> | ||
import A from './components/A.svelte'; | ||
import B from './components/B.svelte'; | ||
</script> | ||
|
||
<A /> | ||
<B /> |
1 change: 1 addition & 0 deletions
1
packages/e2e-tests/dynamic-compile-options/src/components/A.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<div id="A"> preserved leading whitespace</div> |
1 change: 1 addition & 0 deletions
1
packages/e2e-tests/dynamic-compile-options/src/components/B.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<div id="B">removed leading whitespace</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import App from './App.svelte'; | ||
|
||
const app = new App({ | ||
target: document.body | ||
}); | ||
|
||
export default app; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { svelte } from '@sveltejs/vite-plugin-svelte'; | ||
import { defineConfig } from 'vite'; | ||
|
||
export default defineConfig(() => { | ||
return { | ||
plugins: [ | ||
svelte({ | ||
dynamicCompileOptions({ filename }) { | ||
if (filename.endsWith('A.svelte')) { | ||
return { | ||
preserveWhitespace: true | ||
}; | ||
} | ||
} | ||
}) | ||
], | ||
build: { | ||
// make build faster by skipping transforms and minification | ||
target: 'esnext', | ||
minify: false | ||
}, | ||
server: { | ||
watch: { | ||
// During tests we edit the files too fast and sometimes chokidar | ||
// misses change events, so enforce polling for consistency | ||
usePolling: true, | ||
interval: 100 | ||
} | ||
} | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.