ennuicastr / libavjs-webcodecs-polyfill

A polyfill for the WebCodecs API. No, really.
82 stars 8 forks source link

Error when using within a Vue.JS + Vite application #11

Closed benjaminmeysner closed 1 year ago

benjaminmeysner commented 1 year ago

Hi,

I'm currently trying to use this library in a Vue.JS + Vite application. I'm bringing in this dependency via npm and importing it using the following:

import { ... } from 'libavjs-webcodecs-polyfill';

The problem I'm seeing is when I try to use this it knows nothing about it's internal dependency of LibAV.JS. And it throws out a LibAV is not defined error. When I checked in the browser, the internal dependency LibAV.JS isn't even bundling with the rest which is the first weird thing. So I forced a bundling of it by using import 'libav.js'; - in which it does. However, I'm still receiving the following:

image

Is it even possible to use this within an app with bundling?

Thanks!

Yahweasel commented 1 year ago

libavjs-webcodecs-polyfill does not include libav.js, and requires that you include it separately ( https://github.com/ennuicastr/libavjs-webcodecs-polyfill/blob/830a9695158b91b046bf2295d460bddc9c5c37f0/README.md?plain=1#L17 ). It has that dependency for types, not for the actual code; loading the code must be performed separately.

libavjs-webcodecs-polyfill itself is (or at least certainly should be) bundleable, but libav.js is not bundleable, and it would be quite a radical change to its design to make it bundleable. It would also be quite an unhelpful change to its design, since libav.js is (a) huge and (b) very configurable, so bundling it into one particular library would be annoying to any other component that uses it in the same system. A lot of users (OK, this user, anyway) are likely to need specific libav.js configurations for their own needs (e.g., the particular formats they need to mux and demux), and so having it be a full dependency of this library would invert requirements in an annoying way.