mattelen / vue3-runtime-template

Vue component for compiling templates on the fly using a v-html like API
MIT License
47 stars 12 forks source link

Doesn't work with latest Nuxt3 #11

Closed MartinHeinz closed 3 months ago

MartinHeinz commented 2 years ago

Hi, the package doesn't seem to work with latest Nuxt3 (3.0.0-27500163.51ae426).

With minimal application (app.vue):

<template>
  <div>
    <v-runtime-template :template="template"></v-runtime-template>
  </div>
</template>

<script>
import VRuntimeTemplate from "vue3-runtime-template";

export default {
  data: () => ({
    name: "Mellow",
    template: `
      <div>Hello {{ name }}!</div>
    `
  }),
  components: {
    VRuntimeTemplate
  }
};
</script>

nuxt.config.ts:

import { defineNuxtConfig } from 'nuxt3'

export default defineNuxtConfig({
    hooks: {
        'vite:extendConfig': (config, { isClient, isServer }) => {
          if (isClient) {
            config.resolve.alias.vue = 'vue/dist/vue.esm-bundler'
          }
        },
      },
})

Development mode works fine (yarn dev), but production build (yarn build) throws:

file:///.../nuxt3-app/.output/server/chunks/index.mjs:9857
  return (compileCache[cacheKey] = Function('require', code)(commonjsRequire));
  ^

TypeError: Cannot convert object to primitive value
  at Function (<anonymous>)
  at ssrCompile (file:///.../nuxt3-app/.output/server/chunks/index.mjs:9857:38)
  at renderComponentSubTree (file:///.../nuxt3-app/.output/server/chunks/index.mjs:9948:30)
  at renderComponentVNode (file:///.../nuxt3-app/.output/server/chunks/index.mjs:9934:16)
  at renderVNode (file:///.../nuxt3-app/.output/server/chunks/index.mjs:10030:22)
  at renderComponentSubTree (file:///.../nuxt3-app/.output/server/chunks/index.mjs:9995:13)
  at renderComponentVNode (file:///.../nuxt3-app/.output/server/chunks/index.mjs:9934:16)
  at Object.ssrRenderComponent (file:///.../nuxt3-app/.output/server/chunks/index.mjs:10349:12)
  at _sfc_ssrRender (file:///.../nuxt3-app/.output/server/chunks/app/server.mjs:3896:32)
  at renderComponentSubTree (file:///.../nuxt3-app/.output/server/chunks/index.mjs:9989:13)
error Command failed with exit code 1.
verweb commented 2 years ago

The same problem

tkjaergaard commented 2 years ago

I'm experiencing the same issue unfortunately with nuxt@3.0.0-rc.4 😞

tkjaergaard commented 2 years ago

https://github.com/nuxt/nuxt.js/issues/13843

mattelen commented 3 months ago

I see the attached Nuxt issue is fixed. I'm assuming that this will be fixed with that change, so will close this issue