Donaldcwl / browser-image-compression

Image compression in web browser
MIT License
1.3k stars 160 forks source link

React: importing imageCompression... WEBPACK_IMPORTED_MODULE_11___default(...) is not a function #53

Closed Danscap closed 2 years ago

Danscap commented 4 years ago

Installing the latest version of browser-image-compression and importing it in a react project leads to an error no matter what I do.

Note that it works in the example React app in this repo but I cannot use it in any projects. I have tried creating a module out of the component class and putting that in my project. I have also tried matching every dependency in the React app in mine to no avail.

The exact error is:

"Unhandled Rejection (TypeError): browser_image_compressionWEBPACK_IMPORTED_MODULE11default(...) is not a function"

and it occurs at the line where the imageCompression function is called.

Donaldcwl commented 4 years ago

@Danscap Is your project open source? Can I have your repo for debugging?

gabrielavoll commented 4 years ago

I'm experiencing a similar issue, with a Node.js Express React/Redux app, this module was making the whole app crash with no messages 🤕

I'm going to do some investigating and get back to yall

febg11 commented 3 years ago

@Donaldcwl Im getting the same thing using angular 10, did you manage to find a fix?

febg11 commented 3 years ago

Ended up importing it in index.html

  <!-- browser-image-compression -->
  <script
    src="https://cdn.jsdelivr.net/npm/browser-image-compression@1.0.12/dist/browser-image-compression.min.js"></script>

and then using it without type support in my component

// This is imported in the index.html
declare var imageCompression: any;
...
...
await imageCompression(file, options)
elfilalime commented 3 years ago

had the same issue imageCompression is not a function

vu-scoff33 commented 3 years ago

Had the same issue with Angular 11: browser_image_compression__WEBPACK_IMPORTED_MODULE_5__ is not a function

femoraes95 commented 3 years ago

Alguma novidade?