Skip to content
This repository was archived by the owner on Jan 18, 2022. It is now read-only.

Commit 1b0f1ef

Browse files
authored
:sparkes: Make script tag optional (#47)
Fix #46
1 parent 0bff607 commit 1b0f1ef

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/vueTransform.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,11 @@ function parseTemplate (code) {
161161
}
162162

163163
if (nodes.script.length === 0) {
164-
throw new Error('There must be at least one script tag or one' +
165-
' template tag per *.vue file.')
164+
nodes.script.push({
165+
node: null,
166+
code: 'export default {\n}',
167+
attrs: {}
168+
})
166169
}
167170

168171
return nodes

test/expects/noScript.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
var noScript = { template: "<h1>Test</h1>",
2+
};
3+
4+
export default noScript;

test/fixtures/noScript.vue

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template>
2+
<h1>Test</h1>
3+
</template>

0 commit comments

Comments
 (0)