portabletext/react-portabletext

Build Fail due to ReferenceError: createElement is not defined

opr-inzn opened this issue · 6 comments

I can’t build my application anymore on the pages that use Portable Text. In Vercel, I get this build error:

ReferenceError: createElement is not defined
--
12:09:13.246 | at renderBlock (/vercel/path0/web/node_modules/@portabletext/react/dist/react-portable-text.js:397:5)
12:09:13.247 | at renderNode (/vercel/path0/web/node_modules/@portabletext/react/dist/react-portable-text.js:274:14)
12:09:13.247 | at /vercel/path0/web/node_modules/@portabletext/react/dist/react-portable-text.js:245:48
12:09:13.247 | at Array.map (<anonymous>)
12:09:13.247 | at PortableText (/vercel/path0/web/node_modules/@portabletext/react/dist/react-portable-text.js:245:27)
12:09:13.247 | at Wc (/vercel/path0/web/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:68:44)
12:09:13.247 | at Zc (/vercel/path0/web/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:70:253)
12:09:13.247 | at Z (/vercel/path0/web/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:89)
12:09:13.248 | at $c (/vercel/path0/web/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:78:98)
12:09:13.248 | at bd (/vercel/path0/web/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:77:404)

Running Next.js 13.5.4, happens locally and when deploying.

FreiBj commented

Got the same error

FreiBj commented

@opr-inzn Fixed by installing @portabletext/react@3.0.9

yarn add @portabletext/react@3.0.9

@FreiBj works! thanks for sharing!

I have the same problem after upgrading to version 3.0.10. After researching, I found the issue comes from the bump in @portabletext/types.
There is a breaking change on the library "sanity-io/pkg-utils" https://github.com/sanity-io/pkg-utils/blob/main/CHANGELOG.md, and it seems like it is breaking this library as a side effect.

I hope we find a better solution soon than downgrading to 3.0.9. Also, out of curiosity, how can a major version be propagated as a minor version if there are breaking changes?

Looks like 3.0.11 has been released to roll things back, installing the latest version should work again now.

Fixed by #113 in v3.0.11 as previously mentioned 🙌 We had a faulty setting in our tsconfig.json that have always been ignored, until we updated to the latest versions of rollup and esbuild 😅