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

script setup sometimes generate invalid code when using defineEmit and defineProps #2740

Closed
leopiccionia opened this issue Dec 6, 2020 · 2 comments · Fixed by #2729
Closed
Labels
❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. has workaround A workaround has been found to avoid the problem 🐞 bug Something isn't working scope: compiler

Comments

@leopiccionia
Copy link
Contributor

leopiccionia commented Dec 6, 2020

Version

3.0.4

Reproduction link

https://github.com/leopiccionia/vue-script-setup-emit-repro

Steps to reproduce

Just run the repro, with npm run dev.

What is expected?

Compiler should generate valid code.

What is actually happening?

Code fails with syntax error.

The problem is in this line from output:

import { , ref } from '/@modules/vue.js'

The preceding comma is not valid in this place of import statement.

A workaround is changing the order of imports, so that defineEmit and defineProps are trailing.


I'm not sure if this is a Vite-specific error. I can move the issue, if needed.

@leopiccionia
Copy link
Contributor Author

leopiccionia commented Dec 6, 2020

I think that PR #2729 should be a fix.

@posva posva added 🐞 bug Something isn't working ❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. scope: compiler has workaround A workaround has been found to avoid the problem labels Dec 7, 2020
Wizard67 added a commit to Wizard67/comz that referenced this issue Jan 26, 2021
@HcySunYang
Copy link
Member

I did not notice that #3088 is a duplicate of this issue, and I submitted a fix there. So I also linked my PR here, because there are some differences between my PR and #2729

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. has workaround A workaround has been found to avoid the problem 🐞 bug Something isn't working scope: compiler
Projects
None yet
3 participants