这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/esbuild/svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ export const sveltePlugin = ({
sourcefile: args.path,
loader: 'ts',
sourcemap: true,
tsconfigRaw: {
compilerOptions: {
importsNotUsedAsValues: 'preserve',
},
},
})
return {
code,
Expand Down
18 changes: 14 additions & 4 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,20 +429,30 @@ test('bundle svelte without styles', async (t) => {
})

test('svelte: typescript support', async (t) => {
const { outFiles } = await run(t.title, {
const { outFiles, output } = await run(t.title, {
'input.ts': `import App from './App.svelte'
export { App }
`,
'App.svelte': `
<script lang="ts">
let msg: string = 'hello svelte'
import Component from './Component.svelte'
let say: string = 'hello'
let name: string = 'svelte'
</script>

<span>{msg}</span>
<Component {name}>{say}</Component>
`,
'Component.svelte': `
<script lang="ts">
export let name: string
</script>

<slot /> {name}
`,
})

t.deepEqual(outFiles, ['input.js'])
t.assert(output.includes('// Component.svelte'))
})

test('onSuccess', async (t) => {
Expand Down Expand Up @@ -643,7 +653,7 @@ test('multiple entry with the same base name', async (t) => {
t.deepEqual(outFiles, ['bar/input.js', 'input.js'])
})

test('windows backslash in entry', async (t) => {
test('windows: backslash in entry', async (t) => {
const { outFiles } = await run(
t.title,
{ 'src/input.ts': `export const foo = 1` },
Expand Down