Font-Awesome icon indicating copy to clipboard operation
Font-Awesome copied to clipboard

Feature request: ES export

Open andreaslarssen opened this issue 1 year ago • 3 comments

Is your feature request related to a problem?

Using the @fortawesome/free-brands-svg-icons pacakge in an Angular app:

FILE_NAME depends on '@fortawesome/free-brands-svg-icons/ICON_NAME'. CommonJS or AMD dependencies can cause optimization bailouts.

Feature description

The package not to use CommonJS exports

Alternatives

No response

Additional context

No response

Feature request checklist

  • [X] The title starts with "Feature request: " and is followed by the requested feature description
  • [X] This is a single feature
  • [X] I have searched for existing issues and to the best of my knowledge this is not a duplicate

andreaslarssen avatar May 23 '23 11:05 andreaslarssen

FA claims to be fully built using ES modules. I get this same build warning when using Angular as well.

From my digging, it seems the Angular build process uses static analysis to look for the require() statement. If found it throws this warning. Lot's of icons have this require() call. But not all of them.

Oddly enough, Angular points to some icons in my project that don't use require(). I don't know enough about the internals to have a solution though.

fish3046 avatar Oct 23 '23 17:10 fish3046

As a quick update, I've had some good luck with the shorted style:

import {faChevronUp} from '@fortawesome/free-solid-svg-icons';

vs the longer (supposedly the same)

import {faChevronUp} from '@fortawesome/free-solid-svg-icons/faChevronUp';

fish3046 avatar Oct 23 '23 17:10 fish3046

how about the final bundle size when using both variants above (short and long imports) ? Is it the same ?

jocafi avatar Mar 16 '24 14:03 jocafi