MikeKovarik / exifr

πŸ“· The fastest and most versatile JS EXIF reading library.

Home Page:https://mutiny.cz/exifr/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue when using SSR + React (next.js)

harshzalavadiya opened this issue Β· comments

Thank you for making such an amazing exif parser, compare to others it's really easy to use πŸ‘

Until exifr v2.x I was able to import exifr normally and use ESM module perfectly fine but in v3 and latest v4 it throws SSR error when rendering page using next.js (works fine client side rendered applications i.e. create-react-app)

pfb minimal example reproducing error if we use v2.x and after restarting CSB server you can see that it works just fine

Example Sandbox
v4: (error) - https://codesandbox.io/s/damp-wood-mgfq5
v2: (works) - https://codesandbox.io/s/fragrant-cookies-jtenv

commented

Hello. Thanks for the kind words. I'm glad you like it. :)

Also thank you for the sandboxes. It always tremendously helps with tracking down the issue. I'm trying to cover everything with tests but I'm unable to use and test all tools and frameworks. ;)

What's going on is the change how Nodejs works with ESM. From Node 13 we can (or should) use "type":"module" in package.json instead of using .mjs extension. Exifr tried to follow this new way of doing ESM but tools and frameworks aren't yet ready for it as it seems.

So I will probably backtrack on this and make UMD (for now while the ecosystem transitions) as the main entry point of the library to make sure it works everywhere. I will also rename dist/full.esm.js to dist/full.esm.mjs so there's the esm variant available as well.

Unless something breaks there will be v5.0.0 in the coming days.

Thank you

commented

4.3.0 released. I hope it solved your problem