Skip to content

First import defineProps and defineEmit, compilation result exception #3088

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

Closed
zce opened this issue Jan 23, 2021 · 3 comments
Closed

First import defineProps and defineEmit, compilation result exception #3088

zce opened this issue Jan 23, 2021 · 3 comments
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. has workaround A workaround has been found to avoid the problem 🐞 bug Something isn't working

Comments

@zce
Copy link

zce commented Jan 23, 2021

Version

  • vue: 3.0.5
  • @vue/compiler-sfc: 3.0.5
  • vite: 2.0.0-beta.44

Reproduction link

https://github.com/zce/compiler-sfc-issue

Steps to reproduce

$ npm init @vitejs/app my-app
$ cd myapp
$ npm install

./src/components/HelloWorld.vue

import { defineProps, defineEmit, reactive } from 'vue'

defineProps({
  msg: String
})

defineEmit(['update'])

const state = reactive({ count: 0 })
$ npm run dev

What is expected?

Uncaught SyntaxError: Unexpected token ','

The compiled module code:

import { createHotContext as __vite__createHotContext } from "/@vite/client";import.meta.hot = __vite__createHotContext("/src/components/HelloWorld.vue");
import { , reactive } from '/node_modules/.vite/vue.runtime.esm-bundler.js?v=f3e30e51'

// ...

What is actually happening?

This exception should not occur


-import { defineProps, defineEmit, reactive } from 'vue'
+import { reactive, defineProps, defineEmit } from 'vue'

 defineProps({
   msg: String
 })

 defineEmit(['update'])

 const state = reactive({ count: 0 })

Change the import order to return to normal.

As long as they are not imported first

@posva posva added 🐞 bug Something isn't working 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. has workaround A workaround has been found to avoid the problem labels Jan 23, 2021
@leopiccionia
Copy link
Contributor

Seems to be a duplicate of #2740.

@HcySunYang
Copy link
Member

Yes, close this.

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 workaround A workaround has been found to avoid the problem 🐞 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants