unplugin / unplugin-vue

✨ Transform Vue 3 SFC to JavaScript. Supports Vite, esbuild, Rollup, Webpack and more.
MIT License
175 stars 7 forks source link

v-else on template element throws error #152

Closed mcrampon closed 7 months ago

mcrampon commented 9 months ago

Describe the bug

When using the v-else directive on template, I get an error:

<template>
  <my-modal>
    <template v-if="foo" #body>
      Something if foo is truthy
    </template>
    <template v-else #body>
      Something if foo is falsy
    </template>
  </my-modal>
</template>
✘ [ERROR] v-else/v-else-if has no adjacent v-if or v-else-if. [plugin vue]

    components/my_component.vue:6:0:
      6 │ 
        ╵ ^

Reproduction

esbuild@0.20.1 + unplugin-vue@5.0.3 + vue@3.4.19

System Info

System:
    OS: Linux 6.1 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
    CPU: (16) x64 AMD Ryzen 7 PRO 5850U with Radeon Graphics
    Memory: 2.33 GB / 11.50 GB
    Container: Yes
    Shell: 5.9 - /usr/bin/zsh
  Binaries:
    Node: 18.19.0 - ~/.nvm/versions/node/v18.19.0/bin/node
    Yarn: 1.22.17 - ~/.nvm/versions/node/v18.19.0/bin/yarn
    npm: 10.2.3 - ~/.nvm/versions/node/v18.19.0/bin/npm
  Browsers:
    Chrome: 121.0.6167.184

Used Package Manager

yarn

Validations

sxzz commented 9 months ago

Cannot reproduce. Please provide a minimal reproduction to reopen the issue. Thanks.

Why reproduction is required

mcrampon commented 9 months ago

Here's a more detailed reproduction:

<!-- slotter.vue -->
<template>
  <slot name="body" />
</template>
<!-- slotted.vue -->
<template>
  <slotter>
    <template v-if="true" #body>
      Something
    </template>
    <template v-else #body>
      Something else
    </template>
  </slotter>
</template>

<script>
import Slotter from './slotter.vue';

export default {
  components: {
    Slotter
  }
};
</script>
✘ [ERROR] v-else/v-else-if has no adjacent v-if or v-else-if. [plugin vue]

    components/slotted.vue:7:0:
      7 │ 
        ╵ ^
sxzz commented 9 months ago

Still cannot reproduce. Please at least submit a reproduction repo (GitHub repo) that within the basic setup.

Plus, looks like the errors are not caused by unplugin-vue itself, could be caused by Vue Compiler.