prismicio / prismic-dom

Set of helpers to manage Prismic data
https://prismic.io/docs/technologies/prismic-dom-technical-reference
44 stars 16 forks source link

Cannot destructure RichText when importing PrismicDOM #49

Open flayks opened 3 years ago

flayks commented 3 years ago

When trying to destructure PrismicDOM like that:

import { RichText } from 'prismic-dom'

I get this error:

The requested module '../../_snowpack/pkg/prismic-dom.js' does not provide an export named 'RichText'

Using Snowpack 3

lihbr commented 3 years ago

Hey @flayks, nice catch!

I was able to reproduce on my end with Snowpack 3, not sure what could cause that though, perhaps because the package is built with webpack?

flayks commented 3 years ago

@lihbr not quite sure, maybe it needs to be exported as a ES module?

flayks commented 3 years ago

More generally the plugin doesn't seem to be compatible with an ESM environment, as using it with SvelteKit, I got imports errors from Vite:

TypeError: Cannot destructure property 'RichText' of '__vite_ssr_import_2__.default' as it is undefined.

Any solutions to that?

lihbr commented 3 years ago

Hey @flayks, I'm really sorry we didn't manage to make progress on that one since January.

Are you still able to use the prismic-dom package without destructuring it though?

We should be reworking those helpers pretty soon, changing their bundler also :)

cc @samlfair

flayks commented 3 years ago

No worries. Since SvelteKit went with Vite, unfortunately no, it is not really working as it. Oh ok, cool! That would be nice.

lihbr commented 3 years ago

Hey, sorry for the late notice: we've been making great progress on revamping our kits!

I think you'd be interested to give a try to @prismicio/helpers@alpha, our revamp of prismic-dom which should allow proper import of everything ☺️

I know we also have an example of using Prismic x Svelte on the way with our new kits, cc @priyaprafful