Open ivanros opened 2 years ago
Related issue reported to vitejs https://github.com/vitejs/vite/issues/4935, looks like the commonjs2 build target is not compatible with the default vite config.
Was anyone able to use this library with vite somehow? dying to know..
I got the same error , someone fixed this?
Same problem. Vite 3.0
same issue
Same issue
same issue
Alright I figured out a solution
https://github.com/onurzorluer/react-image-file-resizer/blob/3a0fab44211f985aaf048b4fa71027b7149da90e/src/index.js
Resizer.js
in your src directory in react. import Resizer from "relative path to Resizer.js";
import Resizer from "react-image-file-resizer";
wherever it is usedThis is not really helpful. I don't want to locally fork the module
My workaround is to do
import Resizer from "react-image-file-resizer";
// @ts-expect-error https://github.com/onurzorluer/react-image-file-resizer/issues/68
const resizer: typeof Resizer = (Resizer.default || Resizer);
any updates on this?
same issue
same issue typeError: buildExports.imageFileResizer is not a function at onChange
Alright I figured out a solution
- First thing go here and copy the whole file
https://github.com/onurzorluer/react-image-file-resizer/blob/3a0fab44211f985aaf048b4fa71027b7149da90e/src/index.js
- Make a file called
Resizer.js
in your src directory in react.- Paste the code you copied in this file
- Whenever you want to use this function
import Resizer from "relative path to Resizer.js";
- Remove
import Resizer from "react-image-file-resizer";
wherever it is used
it works , thanks for your help
Alright I figured out a solution
- First thing go here and copy the whole file
https://github.com/onurzorluer/react-image-file-resizer/blob/3a0fab44211f985aaf048b4fa71027b7149da90e/src/index.js
- Make a file called
Resizer.js
in your src directory in react.- Paste the code you copied in this file
- Whenever you want to use this function
import Resizer from "relative path to Resizer.js";
- Remove
import Resizer from "react-image-file-resizer";
wherever it is used
It worked.. thanks :)
Describe the bug Using Vitejs this is the only library that is unable to compile correctly in production. I understand that it is related to the way of compiling the library because if I copy and paste the code in my repository I get the Resizer to compile correctly.
Uncaught (in promise) TypeError: er.imageFileResizer is not a function
It may have related with the construction of the project in CommonJS.To Reproduce Steps to reproduce the behavior: Build project with Vitejs.
Expected behavior Well, it would be awesome if it would just work. :)
Desktop (please complete the following information): OS: Ubuntu 20.04 Browser Chrome Edge
This is basically the same problem that this user had in issue https://github.com/onurzorluer/react-image-file-resizer/issues/60