browser-image-compression
browser-image-compression copied to clipboard
The file given is not an instance of Blob or File with v2.0.0 on Next.js
As of v2.0.0, your Next.js example appears to only work when you start Next.js in development mode, not production. Could this be related to core-js being dropped?
The docs say this polyfill is for IE only, but this issue affects Next.js on the latest version of Chrome, Firefox, and Safari.
yarn dev

yarn start

Here's a temporary fix for anyone looking for it:
yarn add [email protected] --exact
@maxproske I couldn't reproduce this issue. Can you provide more details? Such as the image file, OS platform, and browser version.
You may also try to run again yarn build followed by yarn start. It works for me on Windows 10 Chrome 100.0.4896.88 with both PNG and JPG file.
@maxproske I am having the same issue.
Please find the following detail OS: MacOS 12.3.1 Chrome: 102.0.5005.115
The image

@tom555my Here is the result of your image using the production mode of the example Nextjs app (https://github.com/Donaldcwl/browser-image-compression/tree/master/example/Nextjs%20App)

I tested on both Win and MacOS Chrome. Could you provide more information about the issues you faced?
I faced with the exact same issue. This might be related to the swcMinify option, which is available in newer Next.js versions (details). With swcMinify, the production build breaks and browser-image-compression refuses to output compressed images. If I set swcMinify to false, this error disappears.
I also confirmed that the example is not broken with/without newer Next.js versions, as swcMinify seems to be not enabled by default.
@3c1u I just tested [email protected] on [email protected], [email protected] with swcMinify enable (true). I can't reproduce the issue. Could you share your source code that has the issue?
The nextjs source code I tested can be found here: https://github.com/Donaldcwl/browser-image-compression/tree/master/example/Nextjs%20App
It seems that the problem was fixed in newer Next.js versions (i.e. this was just a Next.js/swc issue, not browser-image-compression).
To reproduce, downgrade Next.js to v12.1.5 or v12.1.6. I used the exact same example found in here.