Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vue 3 SFC Compiler function call with semicolon bug. #7805

Closed
houd1ni opened this issue Mar 1, 2023 · 6 comments · Fixed by #8535
Closed

Vue 3 SFC Compiler function call with semicolon bug. #7805

houd1ni opened this issue Mar 1, 2023 · 6 comments · Fixed by #8535
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. has PR A pull request has already been submitted to solve the issue 🐞 bug Something isn't working scope: compiler scope: script-setup

Comments

@houd1ni
Copy link

houd1ni commented Mar 1, 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?

😭

@houd1ni
Copy link
Author

houd1ni commented Mar 1, 2023

The compiled part:
image

@houd1ni houd1ni changed the title Vue 3 SFC Compiler semicolon bug. Vue 3 SFC Compiler function call with semicolon bug. Mar 1, 2023
@yangxiuxiu1115
Copy link
Contributor

yangxiuxiu1115 commented Mar 1, 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

@baiwusanyu-c
Copy link
Member

baiwusanyu-c commented Mar 1, 2023

playground

@yangxiuxiu1115
Copy link
Contributor

yangxiuxiu1115 commented Mar 1, 2023

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

@yangxiuxiu1115
Copy link
Contributor

yangxiuxiu1115 commented Mar 1, 2023

#6778
#7423

@yangxiuxiu1115
Copy link
Contributor

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

@sodatea sodatea added has PR A pull request has already been submitted to solve the issue 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. labels Mar 16, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Sep 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. has PR A pull request has already been submitted to solve the issue 🐞 bug Something isn't working scope: compiler scope: script-setup
Projects
None yet
5 participants