Proposal: Break <pf-icon>
's javascript APIs in 4.0 for better webpack compatibility
#2765
bennypowers
started this conversation in
Ideas
Replies: 3 comments 4 replies
-
@bennypowers I think that's reasonable. Product Trials mostly relies on RHDC to load and configure PFE icon. There are a few instances were we reference the icon node directly in our components, but it sounds like the proposed changes won't impact that usage. Example: import * as InfoCircle from '@patternfly/elements/pf-icon/icons/fas/info-circle.js';
renderTooltip() {
return html`
<rh-tooltip part="tooltip">
${InfoCircle.default.cloneNode(true)}
<slot slot="content" name="authenticated-tooltip"></slot>
</rh-tooltip>
`;
} |
Beta Was this translation helpful? Give feedback.
2 replies
-
The catalog uses the
|
Beta Was this translation helpful? Give feedback.
1 reply
-
thanks! |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
tl;dr: webpack has trouble with pf-icon and i think the only solution is a breaking change
PfIcon
contains a dynamic import which references an expressionspec
:patternfly-elements/elements/pf-icon/BaseIcon.ts
Lines 139 to 162 in 9702278
in particular line 151 there:
patternfly-elements/elements/pf-icon/BaseIcon.ts
Line 151 in 9702278
This works fine in every runtime, but some bundlers (cough webpack) simply refuse to allow it.
We can fix this with a breaking change to pf-icon. I don't believe it's possible to do a "soft-deprecation" (i.e. to retain the existing apis but warn when they are used) because the existence of this import expression in the code in any form will cause this problem. the
/* webpackIgnore */
comment does not help.I've prepared some minimal reproductions (attached) which demonstrate that vite and rollup work fine, but webpack is unfortunately obstinate.
Vite 👍 Works
Reproduction
Rollup 👍 Works
Reproduction
Webpack 💣 Fails so hard
Reproduction
Proposal
I propose to remove the overridable static
getIconUrl
method and to change the signature of the static methodaddIconSet
in a backwards-incompatible way.I also propose adding a new overridable static
resolve()
method, similar to the oldgetIconUrl
, which would return a promise of the icon node to render, rather than the url to import it from.Beta Was this translation helpful? Give feedback.
All reactions