react-datepicker icon indicating copy to clipboard operation
react-datepicker copied to clipboard

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

Open penobit opened this issue 1 year ago • 4 comments

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

penobit avatar Jan 03 '24 08:01 penobit

me too do you have any solution?

Bravemobin avatar Jan 18 '24 08:01 Bravemobin

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.

penobit avatar Jan 18 '24 09:01 penobit

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. 🙂

ijavad805 avatar Jan 18 '24 12:01 ijavad805