Skip to content

Commit

Permalink
fix: bundle svelte without styles (#464)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhmushan committed Nov 23, 2021
1 parent 8c8f19f commit 3fb9b8e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/esbuild/svelte.ts
Expand Up @@ -65,7 +65,7 @@ export const sveltePlugin = ({
})

let contents = result.js.code
if (css && result.css) {
if (css && result.css.code) {
const cssPath = useSvelteCssExtension(filename)
css.set(cssPath, result.css.code)
// Directly prepend the `import` statement as sourcemap doesn't matter for now
Expand Down
24 changes: 24 additions & 0 deletions test/index.test.ts
Expand Up @@ -768,6 +768,30 @@ test('bundle svelte', async () => {
`)
})

test('bundle svelte without styles', async () => {
const { outFiles } = await run(
getTestName(),
{
'input.ts': `import App from './App.svelte'
export { App }
`,
'App.svelte': `
<script>
let msg = 'hello svelte'
</script>
<span>{msg}</span>
`,
}
)

expect(outFiles).toMatchInlineSnapshot(`
Array [
"input.js",
]
`)
})

test('onSuccess', async () => {
const randomNumber = Math.random() + ''
const { logs } = await run(
Expand Down

1 comment on commit 3fb9b8e

@vercel
Copy link

@vercel vercel bot commented on 3fb9b8e Nov 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.