unplugin / unplugin-vue2-script-setup

💡 Bring `<script setup>` to Vue 2.
MIT License
603 stars 39 forks source link

fix: avoid native tag as component #159

Closed jaw52 closed 1 year ago

jaw52 commented 1 year ago

Description

<script setup lang="ts">
let p = "not ok";
</script>

<template>
  <p>{{ p }}</p>
</template>

variable p will be misinterpreted as a component (Component names in vue avoid using html tag)

Linked Issues

This closes https://github.com/antfu/unplugin-vue2-script-setup/issues/133 ,closes https://github.com/antfu/unplugin-vue2-script-setup/issues/135

Additional context

xiaoxiangmoe commented 1 year ago

How about


<script setup lang="ts">
import button from './button.vue'
</script>

<template>
  <button>{{ button }}</button>
</template>
jaw52 commented 1 year ago

How about

<script setup lang="ts">
import button from './button.vue'
</script>

<template>
  <button>{{ button }}</button>
</template>

This is the effect of the official scaffolding ofvite + vue3 demo: https://stackblitz.com/edit/vitejs-vite-beh2mo?file=src%2FApp.vue

image

And. This is the effect of running after this commit image

jaw52 commented 1 year ago

Do we need to add more test cases?

xiaoxiangmoe commented 1 year ago

Yes, we need more test case.

Include

import button from './button.vue'
import Button from './button.vue'
jaw52 commented 1 year ago

Is there any work to be done about this PR @xiaoxiangmoe

jaw52 commented 1 year ago

@xiaoxiangmoe I'm ready to review, bro ^_^