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

Modularize lucide-react imports #464

Closed
wants to merge 4 commits into from
Closed

Modularize lucide-react imports #464

wants to merge 4 commits into from

Conversation

ap-1
Copy link

@ap-1 ap-1 commented May 26, 2023

Closes #267

@vercel
Copy link

vercel bot commented May 26, 2023

@ap-1 is attempting to deploy a commit to the shadcn-pro Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Collaborator

@shadcn shadcn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is handy. Thank you.

@vercel
Copy link

vercel bot commented May 29, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ui ❌ Failed (Inspect) May 29, 2023 4:33pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
next-template ⬜️ Ignored (Inspect) Visit Preview May 29, 2023 4:33pm

@shadcn
Copy link
Collaborator

shadcn commented May 29, 2023

@ap-1 This is failing with the following error:

./app/examples/forms/account/account-form.tsx
Module not found: Can't resolve 'lucide-react/dist/esm/icons/calendar-icon'

@ap-1
Copy link
Author

ap-1 commented May 29, 2023

./app/examples/forms/account/account-form.tsx
Module not found: Can't resolve 'lucide-react/dist/esm/icons/calendar-icon'

The issue seems to occur when an alias for the icon is used instead of the original file. For example:

/* apps/www/components/mobile-nav.tsx */

import { SidebarOpen } from "lucide-react" // errors
import { PanelLeftOpen as SidebarOpen } from "lucide-react" // works fine
/* node_modules/lucide-react/dist/lucide-react.d.ts */

// PanelLeftOpen aliases
export declare const PanelLeftOpenIcon: LucideIcon;
export declare const LucidePanelLeftOpen: LucideIcon;
export declare const SidebarOpen: LucideIcon;

I'm not quite sure how to work around this in modularizeImports, so here's what we could do:

  1. Hold off on this until we figure out how to make modularizeImports work with aliases
  2. Create an eslint rule that enforces the use of the original lucide-react icon names instead of their aliases
    • I'm not sure if this is a good idea. It sounds pretty instrusive.

@ap-1 ap-1 marked this pull request as draft June 2, 2023 00:02
@shadcn
Copy link
Collaborator

shadcn commented Aug 3, 2023

@ap-1 Thanks for the fix. This is now supported out of the box in Next.js. See vercel/next.js#53051

(Closing this as completed. Feel free to reopen if not).

@shadcn shadcn closed this Aug 3, 2023
u007 pushed a commit to u007/ui that referenced this pull request Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve development speed - modularise lucide imports
2 participants