Like what we’re doing? Star us on GitHub!

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

rrums
last month
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?

  • denolfe
    Payload Team
    3 weeks 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.

  • rrums
    3 weeks ago

    yeah already solved using rollup, to have cjs output

Open the post
Continue the discussion in Discord
Can't find what you're looking for?
Get help straight from the Payload team with an Enterprise License.Learn More