Skip to content

Commit 2895496

Browse files
When Webpack sees this dynamic import with template literals, it tries to bundle ALL matching .js files in the @fortawesome/ directories. This includes import.macro.js which is a Babel macro file that requires an internal FontAwesome development tool (@fortawesome-internal-tools/fontawesome-icons/canonical) that isn't published to npm.
The /* webpackExclude: /import\.macro/ */ magic comment tells Webpack to exclude any files matching the regex pattern import.macro when building the dynamic import context. This prevents Webpack from trying to bundle import.macro.js and its problematic internal dependency.
1 parent 2ec5cda commit 2895496

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/lib/components/icon/Icon.component.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,10 @@ function NonWrappedIcon({
272272
}
273273

274274
// Handle FontAwesome icons with dynamic import
275-
import(`@fortawesome/${fontAwesomeType}/${iconClass}.js`).then((module) => {
275+
import(
276+
/* webpackExclude: /import\.macro/ */
277+
`@fortawesome/${fontAwesomeType}/${iconClass}.js`
278+
).then((module) => {
276279
setIcon(module[iconClass]);
277280
iconCache[cacheKey] = module[iconClass];
278281
});

0 commit comments

Comments
 (0)