eshaz / icecast-metadata-js

Browser and NodeJS packages for playing and reading Icecast compatible streaming audio with realtime metadata updates.
164 stars 20 forks source link

Error while trying to use library with Rollup #149

Closed isiah-lloyd closed 1 year ago

isiah-lloyd commented 1 year ago

Tried testing this library using Rollup and this starter project. First ran into issue #148, after manually adding IcecastReadableStream to the exports, I get the following informational messages while building: image

And when attempting to load in the browser: image

eshaz commented 1 year ago

It looks like you need to configure rollup to use the browser version. There is a NodeJS and browser version of this library, and the error your getting is from the NodeJS specific files that should not be used in a browser environment.

Here's where the browser version is exported. https://github.com/eshaz/icecast-metadata-js/blob/1dfbfcef639fec76166a4c71b79e22a8e6ab339d/src/icecast-metadata-js/package.json#L15

You might try adding this to your rollup configuration. https://stackoverflow.com/a/73342503/14911733

eshaz commented 1 year ago

@isiah-lloyd I just want to follow up and see how this is going. Did my suggestion above help?

isiah-lloyd commented 1 year ago

@eshaz hey there! thanks for following up! been a bit busy but definitely want to get this library working for my Steam Deck radio player.

I tried using the {browser: true} option for the resolve rollup plugin and it fixes #148 (I assume that means it's now using the browser.js entry point instead of index.) But I still get the above errors when trying to build the rollup starter project with this library.

eshaz commented 1 year ago

Ok, I found the problem. I'm using the web-worker library to implement the Worker api in a Node JS environment in a few of my other dependencies used by icecast-metadata-player. Unfortunately, this block in their package.json

https://github.com/developit/web-worker/blob/29fef9775702c91887d3d8733e595edf1a188f31/package.json#L7-L11

is not compatible with the rollup-resolve {browser: true} option.

https://github.com/rollup/plugins/blob/7b6255774053ef170d9302cbbd8f99d5a58485ed/packages/node-resolve/README.md?plain=1#L64-L71

I'll work on getting a fix released here soon.

eshaz commented 1 year ago

I've just released icecast-metadata-player/1.13.2. This should fix the error you were getting. Let me know how it goes!

isiah-lloyd commented 1 year ago

@eshaz It's working now! Thanks.