lucide
lucide copied to clipboard
Generate ESM/CJS variants of `dynamicIconImports`
Probably fixes #2366
What is the purpose of this pull request?
- [ ] New Icon
- [x] Bug fix
- [ ] New Feature
- [ ] Documentation update
- [ ] Other:
Description
When trying to bundle my library with an import of dynamicIconImports
:
import dynamicIconImports from "lucide-react/dynamicIconImports.js";
I get this error:
(node:52646) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
export { dynamicIconImports as default };
^^^^^^
SyntaxError: Unexpected token 'export'
I think there are 3 options to solve this:
- Set the
"type": "module"
in thepackage.json
- Use
.mjs
as extension - Add conditional exports
I chose the second option for simplicity and now it creates two separate files for CJS and ESM. Let me know if there are concerns.
I tried to rename the file locally to .mjs
which resolved the error.
Before Submitting
- [x] I've read the Contribution Guidelines.
- [x] I've checked if there was an existing PR that solves the same issue.