})
test('treat custom blocks as raw text', () => {
- const { errors, descriptor } = parse(`<foo> <-& </foo>`)
+ const { errors, descriptor } = parse(
+ `<template><input></template><foo> <-& </foo>`
+ )
expect(errors.length).toBe(0)
expect(descriptor.customBlocks[0].content).toBe(` <-& `)
})
).errors.length
).toBe(0)
})
+
+ // # 6676
+ test('should throw error if no <template> or <script> is present', () => {
+ assertWarning(
+ parse(`import { ref } from 'vue'`).errors,
+ `At least one <template> or <script> is required in a single file component`
+ )
+ })
})
})
errors.push(e)
}
})
-
ast.children.forEach(node => {
if (node.type !== NodeTypes.ELEMENT) {
return
break
}
})
-
+ if (!descriptor.template && !descriptor.script && !descriptor.scriptSetup) {
+ errors.push(
+ new SyntaxError(
+ `At least one <template> or <script> is required in a single file component.`
+ )
+ )
+ }
if (descriptor.scriptSetup) {
if (descriptor.scriptSetup.src) {
errors.push(