Skip to content

Plugin fails when parsing .vue-file without <template> #15

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
johannes-z opened this issue Jun 22, 2022 · 0 comments
Closed

Plugin fails when parsing .vue-file without <template> #15

johannes-z opened this issue Jun 22, 2022 · 0 comments

Comments

@johannes-z
Copy link

johannes-z commented Jun 22, 2022

There is already an open pull request: #11


I have several Components in my project that use render functions, but are defined as .vue to allow using <style> tags. This plugin fails if no <template> is specified.

[vite] Internal server error: Cannot read properties of null (reading 'lang'

The error stems from this LOC:

if (!template.lang && !template.src) {
(template is undefined).

This if should also check for an undefined template.

Repro: https://github.com/johannes-z/repro_vite-plugin-vue2-templates

Works

<template>
  <div>
    <!-- dummy -->
  </div>
</template>

<script lang="ts">
import Vue, { h, defineComponent } from 'vue'
export default defineComponent({
  setup() {
    return () => h('div', 'Test')
  }
})
</script>

Doesn't Work

<script lang="ts">
import Vue, { h, defineComponent } from 'vue'
export default defineComponent({
  setup() {
    return () => h('div', 'Test')
  }
})
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant