Subscribe on changes!

@vitejs/plugin-vue 4.2.0 cannot use component function

avatar
Apr 26th 2023

Vue version

3.2.47

Link to minimal reproduction

https://play.vuejs.org/#eNpdjs0KgzAQhF9lyUkhGPp3kRjovW9QexAbSiDqYqIUJO/eTUKL9DTDzuzut7ErYrUumtVMej2g7bxW7Qggn2ZNhuzNOO+gtiRNy6K0DESuidyTYrctXT8b9GC78UUL3r2p77RfkMJ+Gh1FdAQauB84HDmcOJw5XB7fND9sAOcJSRUUf0hbSqp4pRo6LAx9//USszVqi9MgBdk8LsuwZy4jdkZVLHwAOh5VKg==

Steps to reproduce

<template>
  <div>
    <Lists :list="list" />
  </div>
</template>
<script lang="tsx" setup>
const list = [1, 2, 3, 4, 5]
const Lists = props => (
  <div>
    {props.list.map(item => (
      <li>{item}</li>
    ))}
  </div>
)
</script>

package.json

{
  "dependencies": {
    "@vitejs/plugin-vue-jsx": "^3.0.1",
    "vue": "^3.2.47"
  },
  "devDependencies": {
    "@vitejs/plugin-vue": "^4.2.0",
    "typescript": "^5.0.4",
    "vite": "^4.3.2",
    "vue-tsc": "^1.4.4"
  }
}

@vitejs/plugin-vue 4.1.0 is run well

What is expected?

show list

What is actually happening?

Expected "}" but found "." 9 | const Lists = props => ( 10 |

11 | {props.list.map(item => ( | ^ 12 |
  • {item}
  • 13 | ))}

    System Info

    No response

    Any additional comments?

    No response

    avatar
    Apr 26th 2023

    If you want to use JSX syntax in SFC, you should use the corresponding plugin.

    avatar
    Apr 26th 2023

    If you want to use JSX syntax in SFC, you should use the corresponding plugin.

    I have use @vitejs/plugin-vue-jsx

    my vite.config

    import { defineConfig } from 'vite'
    import vue from '@vitejs/plugin-vue'
    import vueJsx from '@vitejs/plugin-vue-jsx'
    
    export default defineConfig({
      plugins: [
        vue(),
        vueJsx(),
      ]
    })
    

    not work when I use @vitejs/plugin-vue 4.1.0 it's work well

    avatar
    May 5th 2023

    update @vitejs/plugin-vue to 4.2.1 fixed