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

Generate ESM/CJS variants of dynamicIconImports #2437

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dan-lee
Copy link

@dan-lee dan-lee commented Sep 6, 2024

Probably fixes #2366

What is the purpose of this pull request?

  • New Icon
  • 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:

  1. Set the "type": "module" in the package.json
  2. Use .mjs as extension
  3. 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

@github-actions github-actions bot added 📦 dependencies Pull requests that update a dependency file ⚛️ react package Lucide React Package labels Sep 6, 2024
Copy link

github-actions bot commented Oct 7, 2024

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 5 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 dependencies Pull requests that update a dependency file ⚛️ react package Lucide React Package Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JEST: => export { dynamicIconImports as default }; SyntaxError: Unexpected token 'export'
1 participant