Kubessandra / react-google-calendar-api

An api to manage your google calendar
MIT License
215 stars 88 forks source link

Constructor not defined in production #105

Open MrChaker opened 1 year ago

MrChaker commented 1 year ago

I'm using the library in a react vite project , in development it's working normally in production I get this error Uncaught TypeError: mD is not a constructor , this is from index.js in dist folder where mD is suppose to be ApiCalendar class

OchotaDariusz commented 1 year ago

Add to your vite.config.ts two properties build and optimizeDeps:

export default defineConfig({
  // ...
  build: {
    commonjsOptions: { include: [] },
  },
  optimizeDeps: {
    disabled: false,
  },
});

example:

export default defineConfig({
  plugins: [react(), eslintPlugin()],
  server: {
    port: 3000,
  },
  build: {
    commonjsOptions: { include: [] },
  },
  optimizeDeps: {
    disabled: false,
  },
});
MrChaker commented 1 year ago

@OchotaDariusz thanks , only commongjsOptions was enough , what's the reason for optimizeDeps ??

MrChaker commented 1 year ago

@OchotaDariusz Oh never mind , without optimizeDeps I got another build error

OchotaDariusz commented 1 year ago

@MrChaker https://github.com/vitejs/vite/issues/9703#issuecomment-1216662109 here you can read more about that problem