laurentpayot / minidenticons

Super lightweight SVG identicon (pixelated avatar) generator
https://laurentpayot.github.io/minidenticons
MIT License
408 stars 19 forks source link

Vite hot reload fail #8

Closed Thykof closed 3 months ago

Thykof commented 3 months ago

With react vite application, I got

DOMException: CustomElementRegistry.define: 'identicon-svg' has already been defined as a custom element

and

[hmr] Failed to reload /src/App.tsx. This could be due to syntax errors or importing non-existent modules. (see errors above)

This is because a custom element can only be defined once. A solution would be to do something like:

if (!customElements.get('identicon-svg')) { customElements.define('identicon-svg', HTMLTheElement); }

here https://github.com/laurentpayot/minidenticons/blob/73799010a80aeb5d0ee8f5fc1600017ff2489017/minidenticons.js#L41

laurentpayot commented 3 months ago

Hi @Thykof, thank you for this bug report and for the fix idea.

I just released v4.2.1 to fix this issue. Can you tell me if it works for you now?

Thykof commented 3 months ago

Thanks a lot, it works!