Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

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

default discord avatar
rrumslast year
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
    last year

    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
    rrumslast year

    yeah already solved using rollup, to have cjs output

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.