-
-
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.
fix: do not preserve type imports (#20)
* chore: create a playground to demo the bug * fix: do not preserve type imports * fix: only set extra esbuild config when useVitePreprocess is true. Add test * add changeset Co-authored-by: dominikg <[email protected]>
- Loading branch information
Showing
12 changed files
with
129 additions
and
10 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 | ||
--- | ||
|
||
fix: do not preserve types unless useVitePreprocess option is true |
17 changes: 17 additions & 0 deletions
17
packages/playground/ts-type-import/__tests__/ts-type-import.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,17 @@ | ||
import { isBuild, getText, editFileAndWaitForHmrComplete } from '../../testUtils'; | ||
|
||
test('should render App', async () => { | ||
expect(await getText('#hello')).toBe('Hello world'); | ||
}); | ||
|
||
if (!isBuild) { | ||
describe('hmr', () => { | ||
const updateApp = editFileAndWaitForHmrComplete.bind(null, 'src/App.svelte'); | ||
|
||
test('should update App', async () => { | ||
expect(await getText('#hello')).toBe('Hello world'); | ||
await updateApp((content) => content.replace('world', 'foo')); | ||
expect(await getText('#hello')).toBe('Hello foo'); | ||
}); | ||
}); | ||
} |
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,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Test</title> | ||
</head> | ||
<body> | ||
<script src="/src/index.ts" type="module"></script> | ||
</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,17 @@ | ||
{ | ||
"name": "playground-ts-type-import", | ||
"private": true, | ||
"version": "0.0.0", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build", | ||
"serve": "vite preview" | ||
}, | ||
"devDependencies": { | ||
"@sveltejs/vite-plugin-svelte": "workspace:*", | ||
"@tsconfig/svelte": "^1.0.10", | ||
"@types/node": "^14.14.35", | ||
"svelte-preprocess": "^4.6.9", | ||
"vite": "^2.1.2" | ||
} | ||
} |
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 @@ | ||
<script lang="ts"> | ||
let s: string = 'world'; | ||
</script> | ||
|
||
<div id="hello">Hello {s}</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,13 @@ | ||
import { test, Test } from './lib'; | ||
import App from './App.svelte'; | ||
|
||
main(); | ||
|
||
export function main({ arg = true }: Test = {}): void { | ||
if (arg && test()) { | ||
// only create app when test worked | ||
const app = new App({ | ||
target: document.body | ||
}); | ||
} | ||
} |
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 @@ | ||
export interface Test { | ||
arg?: boolean; | ||
} | ||
|
||
export function test(): boolean { | ||
return Date.now() > 1; | ||
} |
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 @@ | ||
const sveltePreprocess = require('svelte-preprocess'); | ||
|
||
module.exports = { | ||
// Consult https://github.com/sveltejs/svelte-preprocess | ||
// for more information about preprocessors | ||
preprocess: sveltePreprocess() | ||
}; |
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 @@ | ||
{ | ||
"extends": "@tsconfig/svelte/tsconfig.json", | ||
"include": ["src/**/*"], | ||
"exclude": ["node_modules"], | ||
} |
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,8 @@ | ||
const svelte = require('@sveltejs/vite-plugin-svelte'); | ||
const { defineConfig } = require('vite'); | ||
|
||
module.exports = defineConfig(() => { | ||
return { | ||
plugins: [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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.