Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create ESM bundle for ESM related projects (Astro, Svelte, Vite, and newer version of Next.js) #801

Open
xiaolin opened this issue Aug 22, 2024 · 2 comments

Comments

@xiaolin
Copy link
Owner

xiaolin commented Aug 22, 2024

Describe the bug
The current webpack bundle only builds UMD which is causing issues with projects in ESM environment.

Image Gallery Version
What version of react-image-gallery are you using?

To Reproduce
Steps to reproduce the behavior:

  1. Create a project using Astro
  2. Import this library
  3. It breaks

Expected behavior
It should work with ESM projects

@xiaolin
Copy link
Owner Author

xiaolin commented Aug 22, 2024

Current workaround for ESM projects is to do the below.

import Gallery from 'react-image-gallery';
const ImageGallery = Gallery.default ? Gallery.default : Gallery;

@xiaolin xiaolin changed the title Create ESM package for ESM related projects (Astro, Svelte, Vite, and newer version of Next.js) Create ESM bundle for ESM related projects (Astro, Svelte, Vite, and newer version of Next.js) Aug 22, 2024
@YakovL
Copy link

YakovL commented Jan 4, 2025

Is this the reason why in Vite I'm getting something like this? (It was supposed to show just one image, i.e. the gallery; instead, the page gets huge overflow by those extra images)

image

I'm using Vite and TypeScript, and using

import Gallery from 'react-image-gallery'
const ImageGallery = (Gallery as any).default ? (Gallery as any).default : Gallery

instead of

import ImageGallery from 'react-image-gallery'

didn't help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants