https://github.com/LoopbackApp/widgets/blob/main/packages/widget-custom-element/src/lib/custom-element.svelte
That's the Svelte component that creates the custom element. Definitely reply here or DM me if you have questions.
Also happy to screen share if that's more convenient.
That's the Svelte component that creates the custom element. Definitely reply here or DM me if you have questions.
Also happy to screen share if that's more convenient.
Comments
https://github.com/LoopbackApp/widgets/blob/main/packages%2Fwidget-custom-element%2Fvite.config.ts
And consumers can import the JS, and nothing else?
Why iife? 🤔
The actual script customers add to their website is https://github.com/LoopbackApp/widgets/blob/main/packages%2Fwidget-js-script%2Fsrc%2Floopback.js.
That adds the web component to the site, but you don't necessarily need that. We use it to have more control over what we load from where etc.
Iife... Maybe not needed
Someone should write a guide/blog post on how to set all of this up, looks simpler than I had imagined! 👀
I spent days making it work 😅.
Our setup also allows for local development via query string parameters to load the widget from localhost so you get hot module reloading!
Our customers use anything from React to WordPress to static HTML :).
What I have started to look into though for the last few weeks is Wasm components.
That would bring nice encapsulation and could even be used server side, e.g. for product analytics.