Skip to content

Import Icon as a separate module #1559

Description

@RobertSasak

Package

  • lucide
  • lucide-angular
  • lucide-flutter
  • lucide-preact
  • lucide-react
  • lucide-react-native
  • lucide-solid
  • lucide-svelte
  • lucide-vue
  • lucide-vue-next
  • Figma plugin
  • all JS packages
  • site

Description

Problem

I would like to reduce overall bundle size. React native(metro) does not support tree shaking so it is up to developer to only import modules that are needed. There is no app that need all icons and only a few are needed at the time.

Solution

Export all icons as a separate sub modules of the lucide-react-native package.

Workaround

It is currently possible to import separate icons from dist subfolder.

import HelpCircleIcon from 'lucide-react-native/dist/esm/icons/help-circle'
import QrCodeIcon from 'lucide-react-native/dist/esm/icons/qr-code'

However those do not have a type and typescript throws error

Could not find a declaration file for module 'lucide-react-native/dist/esm/icons/arrow-left'. 

Use cases

Import only icons that are actually needed.

import HelpCircleIcon from 'lucide-react-native/dist/esm/icons/help-circle'
import QrCodeIcon from 'lucide-react-native/dist/esm/icons/qr-code'

Checklist

  • I have searched the existing issues to make sure this bug has not already been reported.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions