portabletext/react-portabletext

react-portable-text has no property 'toPlainText"

parkerhutchinson opened this issue ยท 4 comments

when building my site Im running into this error both locally and during deployments to vercel.

--
10:34:43.698 |  
10:34:43.699 | 1 \| import cjs from './react-portable-text.js';
10:34:43.699 | 2 \|
10:34:43.699 | > 3 \| export const toPlainText = cjs.toPlainText;
10:34:43.699 | \|                            ^
10:34:43.699 | 4 \| export const PortableText = cjs.PortableText;
10:34:43.699 | 5 \| export const defaultComponents = cjs.defaultComponents;
10:34:43.699 | 6 \| export const mergeComponents = cjs.mergeComponents;
10:34:43.699 |  
10:34:43.699 |  
10:34:43.699 | WebpackError: TypeError: Cannot read properties of undefined (reading 'toPlain  Text')
10:34:43.699 |  
10:34:43.699 | - react-portable-text.cjs.mjs:3
10:34:43.699 | [retool-dot-com]/[@portabletext]/react/dist/react-portable-text.cjs.mjs:3:28
10:34:43.700 | - bootstrap:19
10:34:43.700 | retool-dot-com/webpack/bootstrap:19:1
10:34:43.700 |  
10:34:43.700 | - pageSanity.js:9
10:34:43.700 | retool-dot-com/src/templates/pageSanity.js:9:9

CleanShot 2023-07-21 at 11 05 23

It makes it seem like this would be the dep packages issue but when using react-portable-text directly there is no issue. it builds and runs perfectly. there is something about the implementation or version of this package in your package that causes these errors.

Gatsby v4.x
node v16.x
babel/core v7.6

tested this on your package from version 2.0.3 -> 3.0.4 all resulted in the same error.
simply installing react-portable-text directly and only replacing the props of that component to be serializers and content this builds and runs with no issues.

Is there a workaround to this?

I'd like to use this module without forking as it's the recommended way by Sanity, but this error is causing all builds to fail.

๐ŸŽ‰ This issue has been resolved in version 3.0.5 ๐ŸŽ‰

The release is available on:

Your semantic-release bot ๐Ÿ“ฆ๐Ÿš€

@parkerhutchinson or @zachgoll can either of you confirm if it's resolved in v3.0.7?

Unable to reproduce this error anymore on our end, so I'm closing the issue :)