Eui: [EuiIcon] Dynamic async module is not really compatible with all bundlers.

Created on 22 Oct 2019  ·  4Comments  ·  Source: elastic/eui

Hello,

I am currently bundling my app with Parcel and the dynamic async import into EuiIcon is lost while bundling because the path is dynamically set and so it can't be detected at build time.
https://github.com/elastic/eui/blob/8d0fdee6c8e7319290e2b847caa645aea0aa0282/src/components/icon/icon.tsx#L491

When it loads, the assets path does'nt exist, of course. I don't have a good solution for that instead of importing them all statically and bet on tree-shaking to clean the code at build time.

Has anybody already have this problem or know how to solve it simply?

Thanks.

engineer needs triage stale-issue stale-issue-closed

Most helpful comment

We have just released v24.1.0 which includes an appendIconComponentCache method which can be used to pre-load specific icons and avoid the dynamic fetching. See _consuming.md_ for more details. This is more of a band-aid on the problem to enable these types of projects to work, than a proper solution.

From what I have seen, there is still no agreed-upon way for these next generation bundlers/unbundlers to handle dynamic imports, _especially_ when in a node_module package, and we will continue to track the evolution of ideas in this area. If anyone has links to more up-to-date information please leave them in a comment!

All 4 comments

I have the same issue. And it looks like there is no traction. If anyone points to me a solution, I could spend some time and raise a PR.

We have just released v24.1.0 which includes an appendIconComponentCache method which can be used to pre-load specific icons and avoid the dynamic fetching. See _consuming.md_ for more details. This is more of a band-aid on the problem to enable these types of projects to work, than a proper solution.

From what I have seen, there is still no agreed-upon way for these next generation bundlers/unbundlers to handle dynamic imports, _especially_ when in a node_module package, and we will continue to track the evolution of ideas in this area. If anyone has links to more up-to-date information please leave them in a comment!

👋 Hey there. This issue hasn't had any activity for 180 days. We'll automatically close it if that trend continues for another week. If you feel this issue is still valid and needs attention please let us know with a comment.

❌ We're automatically closing this issue due to lack of activity. Please comment if you feel this was done in error.

Was this page helpful?
0 / 5 - 0 ratings