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

icons fail to import from minified bundle #2469

Open
bennypowers opened this issue Apr 4, 2023 · 0 comments
Open

icons fail to import from minified bundle #2469

bennypowers opened this issue Apr 4, 2023 · 0 comments
Labels
bug priority: low Severity level: 3

Comments

@bennypowers
Copy link
Member

bennypowers commented Apr 4, 2023

Description of the issue

PfIcon imports it's icons from ./icons/${set}/${name}.js, relative to the module in which PfIcon is located via import.meta.url.

When bundling PfIcon into pfe.min.js, we should either append setup code that redirects to ./pf-icon/icons/${set}/${name}.js, or we should employ a bundler plugin to rewrite the import URL relative to the new location of import.meta.url. this plugin merely copies the referenced files, but perhaps we could take inspiration. this esbuild issue contains a variety of directions would could go in to solve this on the esbuild config side

Impacted component(s)

  • pf-icon

Steps to reproduce

<script type="module">
// import from minified bundle
import { PfIcon } from 'https://jspm.dev/@patternfly/elements'; 
</script>
<pf-icon set="patternfly" icon="bell"></pf-icon>

Expected behavior

Icon loads without error

Workaround

It remains possible to work around this with a one-liner:

<script type="module">
import { PfIcon } from 'https://jspm.dev/@patternfly/elements';
PfIcon.getIconUrl = (icon, set) => new URL(`/@patternfly/elements/pf-icon/icons/${set}/${icon}.js`, 'https://jspm.dev');
</script>

Related issues

anujsingla/website-webcomponent#1

@bennypowers bennypowers added priority: low Severity level: 3 bug labels Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug priority: low Severity level: 3
Projects
None yet
Development

No branches or pull requests

1 participant