Remix-Design / RemixIcon

Open source neutral style icon system
https://remixicon.com
Apache License 2.0
6.49k stars 469 forks source link

Issues with Named Exports using ESM #746

Closed mooxl closed 4 months ago

mooxl commented 5 months ago

Hello,

firstly, I want to express my appreciation for the fantastic icon pack you've created. It's clean, intuitive, and seamlessly integrates with our design.

However, I've encountered an issue while using the remixicon package. Here are the details:

The application I'm building is in SPA mode using Vite and Remix. I received an error stating that the named export {ReactComponent} was not found. The error message specifies that '@remixicon/react' is a CommonJS module that may not support all module.exports as named exports.

Here is the full log:

[vite] Internal server error: [vite] Named export 'RiErrorWarningLine' not found. The requested module '@remixicon/react' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from '@remixicon/react';
const {RiErrorWarningLine} = pkg;

To work around this issue, I found a solution:

ssr: { noExternal: ["@remixicon/react"], },

Ideally, it would be great if the used components could be bundled without specifying this workaround. Are there any plans to switch to ESM?

Thank you in advance!

wendygaoyuan commented 4 months ago

In 4.2.0, we fixed it