ijavad805 / react-datepicker

a cool datepicker
https://ijavad805.github.io/react-datepicker/
34 stars 5 forks source link

ReferenceError: require is not defined in production mode (dev mode works fine!) #22

Open penobit opened 10 months ago

penobit commented 10 months ago

Hi there. i have an issue with your package, it works perfectly fine on development mode, but in the build there is an error: ReferenceError: require is not defined image image

im using: package manager: yarn build tool: Vite

System: OS: Windows 11 10.0.22621 CPU: (8) x64 Intel(R) Core(TM) i3-10100 CPU @ 3.60GHz Memory: 2.35 GB / 7.82 GB Binaries: Node: 18.18.1 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD npm: 10.2.0 - C:\Program Files\nodejs\npm.CMD Browsers: Edge: Spartan (44.22621.2283.0), Chromium (120.0.2210.91) Internet Explorer: 11.0.22621.1 npmPackages: vite: ^4.0.0 => 4.5.0

Bravemobin commented 10 months ago

me too do you have any solution?

penobit commented 10 months ago

me too do you have any solution?

Hi there. I tested many things and the didnt work. but for another library i added this code to my vite.config.js

build: {
    commonjsOptions: {
      transformMixedEsModules: true,
    },
  },

and the problem was fixed, But i dont know it will work for this or not. I had to remove the library and use the @mui/x-date-pickers and jalali-moment for persian dates in my project.

hope my answer helped.

Bravemobin commented 10 months ago

oh thanks i find another library have persian big calender 'jalali-react-big-calendar' thanks for your response.

ijavad805 commented 10 months ago

Hello my friends, I'm currently using webpack, and unfortunately, I don't have a deep understanding of what's going on with Vite. I'm quite occupied in the upcoming months and won't be able to dedicate time to work on it for now, however I add it to my to do list.

Thank you for your replies. 🙂