Error on traversing SFC with both script & script-setup tags
Closed this issue ยท 2 comments
Hello ๐
The babelParser (I guess ?) seems unable to correctly parse a vue file containing 2 script tags, one with the setup
attribute and one without, which according to the doc should be valid (we're using this as a way to set inheritAttrs: false
to some components in Vue 2.7).
Reproduction case which triggers the error in your transform
test file :
<template>
<div>hello {{ sample }}</div>
</template>
<script setup>
import { ref } from 'vue'
const sample = ref(0)
</script>
<script>
export default {
name: 'Test',
}
</script>
I'm not quite sure how that should be handled by vue-metamorph though, should those 2 tags return 2 different scriptAst
?
If this is considered too much of an edge case I would understand, I can quite easily modify those files beforehand and then run vue-metamorph, I just figured you might want to know this.
cheers
๐ I had no idea this was even possible to have a <script setup>
and a <script>
in the same SFC.
Thanks for raising this issue - I'll work on this later.
I just published v2.0.0, which adds support for multiple <script>
tags in a SFC. The scriptAST
parameter in transform()
and find()
plugin function which had a type of Program | null
is now scriptASTs
, and has a type of Program[]