aws-samples / amazon-ivs-player-web-sample

This project contains code samples demonstrating how to build, package, and integrate with the Amazon IVS Player Web SDK.
https://docs.aws.amazon.com/ivs/
MIT No Attribution
81 stars 32 forks source link

Uncaught Error: Module "events" has been externalized for browser compatibility. Cannot access "events.EventEmitter" in client code #56

Closed dtgbao closed 2 years ago

dtgbao commented 2 years ago

Describe the bug Error appear in console and cannot play video when running npm-sdk sample code on Vitejs

Package info "amazon-ivs-player": "^1.12.0"

Sample Code: https://stackblitz.com/edit/vitejs-aws-ivs?file=src%2Fplayer.ts&terminal=dev

Screenshots

image
johnBartos commented 2 years ago

I'm not familiar with Vite, is this an issue with that library? I see something similar in their issue tracker https://github.com/vitejs/vite/discussions/4479

If there's an improvement we can make to support Vite, let me know.

florence-wolfe commented 2 years ago

Webpack defaults to using node-libs-browser when specifying the web platform. This means that any time it would encounter any of the known compatible node libs it'll be replaced with an equivalent web implementation. In our case, that happens with the events module.

Vite, on the other hand is built on top of rollup which doesn't include this behavior by default but gives you the ability to add it in with its flexible configuration.

There's an open issue in the Vite repo actively discussing this.

Closing as this is a bundler issue and not a player nor sample bug