Skip to content

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

@leopiccionia

Description

@leopiccionia

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ❗ p4-importantPriority 4: this fixes bugs that violate documented behavior, or significantly improves perf.🐞 bugSomething isn't workinghas workaroundA workaround has been found to avoid the problemscope: compiler

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions