diff --git a/src/esbuild/svelte.ts b/src/esbuild/svelte.ts index e2c92d5c..2ebe347d 100644 --- a/src/esbuild/svelte.ts +++ b/src/esbuild/svelte.ts @@ -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 diff --git a/test/index.test.ts b/test/index.test.ts index a124bcdb..06ab72bc 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -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': ` + + + {msg} + `, + } + ) + + expect(outFiles).toMatchInlineSnapshot(` + Array [ + "input.js", + ] + `) +}) + test('onSuccess', async () => { const randomNumber = Math.random() + '' const { logs } = await run(