captbaritone / webamp

Winamp 2 reimplemented for the browser
https://webamp.org
MIT License
9.7k stars 640 forks source link

Importing Webamp from bundle inside a module #1239

Open msikma opened 8 months ago

msikma commented 8 months ago

The readme mentions how to get started with Webamp in two situations: minimal, and with webpack.

As I mentioned on Discord, the example links are actually 404, so I'm not sure what they look like. But there's a tertiary option that might be mentioned: minimal, but with a <script type="module"> tag. In this case, you need to import() Webamp:

<script type="module">
await import('./webamp.bundle-1.5.0.js')

const container = document.querySelector('#container')
const webamp = new Webamp()
await webamp.renderWhenReady(container)
</script>

It might be worth mentioning this since it's otherwise not totally straightforward how to use the bundle file in an environment where a module is required.