calebdwilliams/element-internals-polyfill

Is there any way to lazy import polyfill in Lit

Closed this issue · 1 comments

Hi all,
We have a design system project named Baklava. We built it with lit and esbuild.
We want to dynamically import this polyfill when the user's browser is Safari. However, we don't want to add this in the released package, because it will add ~5KB in gzip. Is there any way to do this?

Thank you in advance.

You can certainly do feature checking for Safari if you want, but it will likely be at the app level as long as the polyfill is available before the registration of any components.

I wish there were a better answer for you and someone out there might have one, but the nature of this kind of project is that it has to be available before the first tool that uses the APIs are added.

I'm going to close this for now as it's not an issue with the polyfill itself, but rather its application. If you want to continue having this conversation, I'm happy to chime in or accept any other thoughts or ideas you have.