chatscope / chat-ui-kit-react

Build your own chat UI with React components in few minutes. Chat UI Kit from chatscope is an open source UI toolkit for developing web chat applications.
https://chatscope.io
MIT License
1.34k stars 116 forks source link

The requested module '/node_modules/prop-types/index.js' does not provide an export named 'default' #149

Closed Lodjuret2001 closed 6 months ago

Lodjuret2001 commented 7 months ago

Hi there! I'm encountering an issue while trying to integrate my npm package, which depends on the chat-ui-kit-react package, into a Vite React project.

Problem:

When testing my package in a Vite React project, I encounter a SyntaxError related to the prop-types module. The error message indicates that the module does not provide a default export. Here's the specific error:

Uncaught SyntaxError: The requested module '/node_modules/prop-types/index.js' does not provide an export named 'default' (at Status.js)

Investigation:

Upon further investigation, I found that modifying the import statements within all files inside the "es", folder to use the wildcard import syntax.

(import PropTypes from "prop-types" to ``import * as PropTypes from "prop-types" ) resolved the issue with prop-types. (import classNames from "classnames" to ``import * as classNames from "classnames" ) resolved the issue with classnames.

However, this led to a similar issue with the @fortawesome/free-solid-svg-icons module, where a specific export (faArrowDown) could not be found.

Next Steps:

I'm unsure how to proceed with resolving the issue related to @fortawesome/free-solid-svg-icons. I've ensured that all paths from my OpenReactBot component are correct and that all dependencies are correctly installed in the React app.

Here is my links to my GitHub repositories for reference:

I would greatly appreciate any guidance or assistance on how to resolve this issue. Thank you for your help!

Lodjuret2001 commented 6 months ago

I had to use rollup to bundle my package and make chat-ui-kit-react as a external dependency.

igorjpimenta commented 1 month ago

After struggling a lot, I found a simple solution! I solved it by adding some stuff in vite.config.ts as below.

export default defineConfig({
  ...
  optimizeDeps: {
    include: ['prop-types'],
  },
  resolve: {
    alias: {
      'prop-types': 'prop-types/prop-types.js',
    },
  },
})