Subscribe on changes!

Vue 3 SFC Compiler function call with semicolon bug.

avatar
Mar 1st 2023

Vue version

3.2.47

Link to minimal reproduction

https://github.com/houd1ni/vue-issues

Steps to reproduce

  • npm i
  • npm run dev
  • open in a browser (mine is ff latest).
  • See the console.

At first glance, it is a sfc compiler stuff. If it is a vite's issue, I'd open it there and close here, though.

What is expected?

Clean console, Compo.vue output with its' hello.

What is actually happening?

It is crashing because the compiler removes semicolons and moves ;(window) after a function call.

image

System Info

ff111.0b3 @ win10x64 intel 12100 w 32GbDDR43200.
node v19.2.0

Any additional comments?

😭

avatar
Mar 1st 2023

The compiled part: image

avatar
Mar 1st 2023

I think this is a @vue/compile-sfc bug. I debugged it and found the problem。When processing defineProps, it deletes the semicolon of the next line together。 babel think that the semicolon of the next line is the end of the statement location

avatar
Mar 1st 2023
avatar
Mar 1st 2023

In this case, it cannot be parsed normally。 const props = defineProps({ prop: { type: String, required: true }, }), emits = defineEmits(['handleChange']), a = 1 playground

avatar
Mar 1st 2023

#6778 #7423

avatar
Mar 1st 2023

#7810 Sorry, this pr does not solve this problem perfectly. I have to rethink the solution.So I closed it, I'm sorry.