yet-another-react-lightbox with Remix app #122
-
I'm using yet-another-react-lightbox in remixJS with typescript. When I try to use the plugins, I get the following error:
<Lightbox
open={index >= 0}
index={index}
close={() => setIndex(-1)}
slides={slides}
slideshow={{ ref: slideshowRef }}
plugins={[Counter]}
/> |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Apparently, Remix is unable to import ESM packages by default. https://remix.run/docs/en/1.16.0/pages/gotchas#importing-esm-packages To fix this, you need to add /** @type {import('@remix-run/dev').AppConfig} */
module.exports = {
ignoredRouteFiles: ["**/.*"],
unstable_dev: true,
serverDependenciesToBundle: [/^yet-another-react-lightbox.*/],
}; Here is a working example - https://codesandbox.io/p/sandbox/yet-another-react-lightbox-122-qsgufv?file=%2Fapp%2Froutes%2Findex.tsx |
Beta Was this translation helpful? Give feedback.
Apparently, Remix is unable to import ESM packages by default.
https://remix.run/docs/en/1.16.0/pages/gotchas#importing-esm-packages
To fix this, you need to add
yet-another-react-lightbox
to theserverDependenciesToBundle
option in yourremix.config.js
file. Please note that I'm using regex that also covers plugins imports.Here is a working example - https://codesandbox.io/p/sandbox/yet-another-react-lightbox-122-qsgufv?file=%2Fapp%2Froutes%2Findex.tsx