Skip to content

Commit

Permalink
fix: do not throw when there's no script block in the SFC
Browse files Browse the repository at this point in the history
  • Loading branch information
haoqunjiang committed Sep 9, 2020
1 parent f19f2b3 commit a2262ce
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/templateLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ const TemplateLoader: webpack.loader.Loader = function(source, inMap) {
compilerOptions: {
...options.compilerOptions,
scopeId,
bindingMetadata: JSON.parse(query.bindings as string)
bindingMetadata:
typeof query.bindings === 'string' ? JSON.parse(query.bindings) : {}
},
transformAssetUrls: options.transformAssetUrls || true
})
Expand Down
4 changes: 4 additions & 0 deletions test/core.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ test('basic', async () => {
test('script setup', async () => {
await bundle({ entry: 'ScriptSetup.vue' })
})

test('without script block', async () => {
await bundle({ entry: 'no-script.vue' })
})
9 changes: 9 additions & 0 deletions test/fixtures/no-script.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<template>
<h2 class="red">hello</h2>
</template>

<style>
h2 {
color: #f00;
}
</style>

0 comments on commit a2262ce

Please sign in to comment.