Open Jamiewarb opened 2 years ago
@danielroe I don't think it's related, but I see the same error is mentioned in nuxt/nuxt.js#13077 when discussing vue test utils
Another strange occurrence: if I change the component template to this (replace the <button>
element with a HTML comment) it still happens:
<template>
<div>
<input @change="test" />
<!-- test -->
</div>
</template>
<script>
export default defineComponent({
name: 'BaseButton',
methods: {
test() {
console.log('test')
},
},
})
</script>
And even if it's just two comments:
<template>
<div>
<!-- test -->
<!-- test -->
</div>
</template>
<script>
export default defineComponent({
name: 'BaseButton',
})
</script>
@Jamiewarb I am experiencing the same, did you find any other solutions besides importing it with an alias.
Same here :/
Working example here: https://github.com/rodrigogs/juquinha/blob/master/modules/web/pages/dashboard.vue
To make it break, just remove the defineComponent
alias.
Same problem here, without alias is not possible to work around it. Any solutions?
cc: @antfu
any news on this issue please?
Environment
Nuxt CLI v3.0.0-27333388.c824905 16:10:20 RootDir: /Users/jamie/Sites/bignight/define-component 16:10:20 Nuxt project info: 16:10:20
Darwin
v16.13.0
2.16.0-27332655.777a4b7f
yarn@1.22.17
Webpack
head
,css
,plugins
,components
,buildModules
,modules
,build
-
Build Modules:
@nuxtjs/stylelint-module@4.1.0
,@nuxt/bridge@3.0.0-27333388.c824905
Reproduction
Please see this repo for a full reproduction: https://github.com/Jamiewarb/repro-define-component
Describe the bug
When adding a component that handles an event with
v-on
, I'm sometimes getting the errordefineComponent is not defined
.In the reproduction, this occurs when there are two elements in the component that both have a
v-on
. Later investigation shows that this also occurs when either or both of those elements are simple html comments<!-- -->
as well.Additional context
To get the error:
yarn dev
and open localhost:3000 in a browser.To circumvent the error:
<input>
element or the entire<button>
element.The docs say you can also import from
#imports
directly, but this gives another error:import { defineComponent } from '#imports';
inside the<script>
tagModule parse failed: Identifier 'defineComponent' has already been declared (10:9)
error in terminalHowever, importing it under an alias successfully circumvents this problem entirely:
import { defineComponent as dC } from '#imports'
.export default dC({ ... })
.Logs