prismicio / prismic-helpers

Set of helpers to manage Prismic data
https://prismic.io/docs/technical-reference/prismicio-helpers
Apache License 2.0
15 stars 9 forks source link

.asHtml not recognized in prismicH.asHtml (using Vite, Vue 3 and Nuxt 3) #68

Open carbdias opened 11 months ago

carbdias commented 11 months ago

Hello, I'm having an issue while implementing prismic-helpers in replacement of old prismic-dom library. Also I wanted to check if it is compatible with Vite and Nuxt 3, because after implementing all the changes I'm having

[nuxt] [request error] [unhandled] [500] __vite_ssr_import_0__.asHtml is not a function at Proxy.dynamicComponent (./src/components/content/PrismicField.vue:47:48)
at ReactiveEffect.run (./node_modules/@vue/reactivity/dist/reactivity.cjs.js:162:19)
at get value [as value] (./node_modules/@vue/reactivity/dist/reactivity.cjs.js:1131:33)
at Object.get [as dynamicComponent] (./node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:3410:22)
at _sfc_ssrRender (./src/components/content/PrismicField.vue:89:136)
at renderComponentSubTree (./node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:683:9)
at renderComponentVNode (./node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:631:12)
at renderVNode (./node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:743:14)
at renderVNodeChildren (./node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:759:5)
at renderElementVNode (./node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:806:9)

when I try to call this method the new way :

       ${prismicH.asHtml(
           this.field,
           // null param because this prismic function need normaly a link-resolver param
           // doc : https://prismic.io/docs/javascript/templating/rich-text
           // but we put the link-resolver in the back-end so we do no longer need link-resolver in front
           null,
           htmlSerializer
      )}</div>`,

      I have the import here in the vue file 
      import * as prismicH from '@prismicio/helpers';

      and I also have the htmlSerializer defined in another file.

      But the error comes right away when calling prismicH.asHtml.

      What should I do ?

PS: Package.json is like this :

"devDependencies": {
      "@nuxt/devtools": "latest",
      "nuxt": "^3.8.1",
      "sass": "^1.69.5",
      "sass-loader": "^13.3.2",
      "vue": "^3.3.8",
      "vue-router": "^4.2.5"
  },
"dependencies": {
      "@bootstrap-vue-next/nuxt": "^0.14.10",
      "@nuxtjs/i18n": "^8.0.0-rc.5",
      "@pinia/nuxt": "^0.5.1",
      "@popperjs/core": "^2.11.8",
      "@prismicio/helpers": "^2.3.9",
      "bootstrap": "^5.3.2",
      "bootstrap-vue-next": "^0.14.10",
      "nuxt-jsonld": "^2.0.8",
      "vite-svg-loader": "^4.0.0"
}
github-actions[bot] commented 11 months ago

This issue has been labeled as a bug since it was created using the 🚨 Bug Report Template.

Hi there, thank you so much for the report!

Following our Maintenance Process, we will review your bug report and get back to you next Wednesday. To ensure a smooth review of your issue and avoid unnecessary delays, please make sure your issue includes the following:

If you have identified the cause of the bug described in your report and know how to fix it, you're more than welcome to open a pull request addressing it. Check out our quick start guide for a simple contribution process.

If you think your issue is a question (not a bug) and would like quicker support, please close this issue and forward it to an appropriate section on our community forum: https://community.prismic.io

- The Prismic Open-Source Team

carbdias commented 10 months ago

Hello, any news on this ?