Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bundle svelte without styles #464

Merged
merged 1 commit into from Nov 23, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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