FredrikOseberg / react-chatbot-kit

MIT License
325 stars 155 forks source link

Importing `Chatbot` default export from `"react-chatbot-kit"` is broken in production build #135

Open sjdemartini opened 1 year ago

sjdemartini commented 1 year ago

When using the import:

import Chatbot from "react-chatbot-kit";

and trying to utilize/mount the component in a yarn build built production version of an app, it leads to the following error:

Error: Minified React error #130; visit https://reactjs.org/docs/error-decoder.html?invariant=130&args%5B%5D=object&args%5B%5D= for the full message or use the non-minified dev environment for full errors and additional helpful warnings.

or simply:

Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.

Based on this StackOverflow post, we changed our import to:

import { Chatbot } from "react-chatbot-kit";

instead, and it then worked without issue. Locally using a development server and not a build, either version of the import worked.

We are using Vite (so rollup, esbuild, etc.). I'm assuming react-chatbot-kit's build/index.js is perhaps not constructed in a way that properly supports the default export of Chatbot. We are using many dozens of other packages that do not have this problem, and our Vite config is essentially the default, so it seems like there is a lower-level issue in the assets published for react-chatbot-kit.

Thanks for building and documenting this library!