I would love to add this to a more modern usage with webpack, tree shaking and "all the fancy gimmicks". For that to work the class would need to be exported and we run the initialization in our own scripts. For instance, in lite-yt-embed.js remove customElements.define('lite-youtube', LiteYTEmbed); and add
export default LiteYTEmbed
and in the using script import it and initialize it
import {LiteYTEmbed} from `lite-youtube-embed`
customElements.define('lite-youtube', LiteYTEmbed);
That would require a type: module in package.json and "main": "path to lite-yt-embed.js" so the module resolves the script properly.
I am sure it can be possible to keep the current setup for older users and add ESM functionality.
I would love to add this to a more modern usage with webpack, tree shaking and "all the fancy gimmicks". For that to work the class would need to be exported and we run the initialization in our own scripts. For instance, in
lite-yt-embed.js
removecustomElements.define('lite-youtube', LiteYTEmbed);
and addand in the using script import it and initialize it
That would require a
type: module
inpackage.json
and"main": "path to lite-yt-embed.js"
so the module resolves the script properly.I am sure it can be possible to keep the current setup for older users and add ESM functionality.
Would you consider that?