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

Angular – standalone component compatibility with LucideAngularModule.pick #1288

Closed
R-Bower opened this issue May 17, 2023 · 6 comments · Fixed by #1529
Closed

Angular – standalone component compatibility with LucideAngularModule.pick #1288

R-Bower opened this issue May 17, 2023 · 6 comments · Fixed by #1529
Labels
🐛 bug Something isn't working

Comments

@R-Bower
Copy link

R-Bower commented May 17, 2023

Prerequisites

  • Version: 0.219.0
  • Are you running from source/main: No
  • Are you using a released build: Yes
  • Operating system: MacOS

Step to reproduce

  1. Follow the installation guide on the npm page for lucide-angular.

  2. Try to use with a standalone component.

import {Component} from "@angular/core"
import {Box, LucideAngularModule} from "lucide-angular"

@Component({
  imports: [LucideAngularModule.pick({Box})],
  selector: "test",
  standalone: true,
  template: ``,
})
export class TestComponent {}

Actual behavior

The code does not compile.

Compilation error:

TS2322: Type 'ModuleWithProviders ' is not assignable to type 'readonly any[] | Type '

Notes

The current import strategy is not compatible with Angular's standalone components.

@R-Bower R-Bower added the 🐛 bug Something isn't working label May 17, 2023
@R-Bower R-Bower changed the title LucideAngularModule.pick standalone compatibility Angular – standalone component compatibility with LucideAngularModule.pick May 17, 2023
@karsa-mistmere
Copy link
Member

Thanks for the bug report, @R-Bower, I'm a bit busy at the moment, but I will get to this as soon as my time allows.

@Bonus2712
Copy link

hey, @karsa-mistmere has anything come up on this ticket yet? I want to use the Lucide icons in any case and also just in the combination with angular 16 and standalone components :)

@karsa-mistmere
Copy link
Member

karsa-mistmere commented Aug 25, 2023

@R-Bower, @Bonus2712: This should now be resolved in the latest release https://github.com/lucide-icons/lucide/releases/tag/0.269.0

Sorry this took so long (especially seeing how simple the fix was). Let me know if you run into anything else.
I did consider making LucideAngularComponent standalone to begin with, but that would mean having to drop support for Angular 13.

@seangolob
Copy link

Hi @karsa-mistmere. I appreciate your work on this bug.

I am currently trying to get lucide-angular to work with standalone components as well. I have followed the steps to reproduce and I am still seeing errors in my project. I am using version 0.274.0

I am receiving these errors while running my app:

-NG2012: 'imports' contains a ModuleWithProviders value, likely the result of a 'Module.forRoot()'-style call. These calls are not used to configure components and are not valid in standalone component imports - consider importing them in the application bootstrap instead.

and

error TS2322: Type 'ModuleWithProviders<LucideAngularModule>' is not assignable to type 'readonly any[] | Type<any>'.

Please let me know if there is any other information that will help with your investigation. I would love to use standalone components and lucid-angular!

@karsa-mistmere
Copy link
Member

Hey @seangolob,
The error you get is loud and clear: you cannot use a LucideAngularModule.pick({...}) style import. This is not specific to Lucide, it's how standalone components work.

As a workaround you can do either of the following:

  1. import just LucideAngularModule, no pick() added and then either:
  1. create a custom module that both imports and exports LucideIconModule, with your necessary picks added

(My preferred modus operandi is 1B)

@seangolob
Copy link

@karsa-mistmere Thank you for your guidance. I am new to the angular space and I am still getting my bearings straight. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants