Error [ERR_REQUIRE_ESM]: require() of ES Module when trying to implement Lit Element

default discord avatar
rrums
7 months ago
2

Hey there, I want to use Lit on React for

ui

field on payload. I use

@lit-labs/react

to do it.



always got


Error [ERR_REQUIRE_ESM]: require() of ES Module /path/payload/node_modules/lit-element/index.js from /path/payload/src/lit-components/test/my-element.js not supported.
Instead change the require of index.js in /path/payload/src/lit-components/test/my-element.js to a dynamic import() which is available in all CommonJS modules.


Is there any way to implement Lit with Payload?


Has someone done this (Lit+React) in payload before?

  • discord user avatar
    denolfe
    Payload Team
    6 months ago

    That package appears to be ESM-only, so this won't be possible currently unless you introduce some sort of bundling to get a cjs output. This is an node-wide ecosystem problem at the moment.

  • default discord avatar
    rrums
    6 months ago

    yeah already solved using rollup, to have cjs output

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.