silvermine / videojs-chromecast

MIT License
148 stars 75 forks source link

Using plugin in a SvelteKit app #134

Closed Lootwig closed 2 years ago

Lootwig commented 2 years ago

Is there a way to integrate this (and the airplay) plugin with svelte, i.e. without needing to call require('...') which is not supported?

gkatsev commented 2 years ago

this plugin only exposes commonjs files. From googling around, Svelte uses Vite under the hood for building, so, loading in vite-plugin-commonjs sounds like it'll address the issue: https://github.com/originjs/vite-plugins/tree/main/packages/vite-plugin-commonjs#commonjs-module-in-node_modules

Lootwig commented 2 years ago

Thanks to this very helpful redditor, I was able to get chromecast running:

import videojsChromecast from '@silvermine/videojs-chromecast';
videojsChromecast(videojs);