paramander / contentful-rich-text-vue-renderer

Render Contentful Rich Text field using Vue
https://www.npmjs.com/package/contentful-rich-text-vue-renderer
MIT License
38 stars 12 forks source link

require is not defined in ES module scope, you can use import instead #42

Closed ma-jahn closed 2 years ago

ma-jahn commented 2 years ago

Hi,

we were trying to include your RichTextRenderer in our Nuxt 3 App. Unfortunatly it is not yet working.

After adding import RichText from 'contentful-rich-text-vue-renderer'

we receive the following error:

require is not defined in ES module scope, you can use import instead

Shouldn't the index.esm.js be using import instead of require ?

When explicity importing the Common JS Build like so: import RichText from 'contentful-rich-text-vue-renderer/dist/index.cjs' It's working but this doesn't feel right.

Am i missing something?

tolgap commented 2 years ago

Hi @ma-jahn ,

Thanks for filing this issue. I have investigated it and found that the ESM build was faulty. I have published a beta version for you to test out. Could you run npm install contentful-rich-text-vue-renderer@2.2.0-beta.0 and try it out?

janikontturi commented 2 years ago

Hi @tolgap

I tried this 2.2.0-beta.0 but i get this error on it, running also nuxt3 (3.0.0-rc-6)

Cannot read property 'nodeRenderers' of undefined

jeremy-daude commented 2 years ago

Same thing here :/

tolgap commented 2 years ago

For Nuxt 3 users: I just published v3.0.1. It removed a require statement in index.esm.js that is in use if ESM is enabled. Should fix this issue. If not, please let me know, I'll reopen.

jeremy-daude commented 2 years ago

It works on my end, NUXT3 (3.0.0-rc-6)

Thanks a lot.