I'm unable to import icons when I use an alias to reference them. I noticed the problem specifically with from @fortawesome/free-regular-svg-icons
. You sometimes need to use an alias because there might be a duplicate name for an icon in libraries and you want to import them both.
This is code that was working prior to a small Angular upgrade (7.1 -> 7.2). Here's the guidance from the fontawesome documentation. See the last section on the page.
I've tried upgrading fortawesome packages and screwing around with the aliases and icons being imported. I noticed that removing the alias allowed me to import the icons just fine.
app module
import { library, dom } from '@fortawesome/fontawesome-svg-core';
import { faSpinner, faCopy } from '@fortawesome/free-solid-svg-icons';
library.add(faSpinner, faCopy);
import { faCopy as farCopy } from '@fortawesome/free-regular-svg-icons';
library.add(farCopy); // <-- This is where the error is thrown
dom.watch();
relevant packages
"@angular/common": "^7.2.15",
"@angular/compiler": "^7.2.15",
"@angular/core": "^7.2.15",
"@angular/forms": "^7.2.15",
"@angular/http": "^7.2.15",
"@angular/material": "^7.2.0",
"@fortawesome/angular-fontawesome": "^0.3.0",
"@fortawesome/fontawesome-common-types": "^0.2.21",
"@fortawesome/fontawesome-svg-core": "^1.2.21",
"@fortawesome/free-regular-svg-icons": "^5.10.1",
"@fortawesome/free-solid-svg-icons": "^5.10.1",
Browser Error
Uncaught ReferenceError: farCopy is not defined