Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constructor not defined in production #105

Open
MrChaker opened this issue Apr 3, 2023 · 4 comments
Open

Constructor not defined in production #105

MrChaker opened this issue Apr 3, 2023 · 4 comments

Comments

@MrChaker
Copy link

MrChaker commented Apr 3, 2023

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
Copy link
Contributor

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
Copy link
Author

MrChaker commented Apr 3, 2023

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

@MrChaker
Copy link
Author

MrChaker commented Apr 3, 2023

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

@OchotaDariusz
Copy link
Contributor

@MrChaker vitejs/vite#9703 (comment) here you can read more about that problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants