bvibber / ogv.js

JavaScript media player using Ogg/Vorbis/Theora/Opus/WebM libs compiled with Emscripten
https://brooke.vibber.net/misc/ogv.js/demo/
Other
1.19k stars 99 forks source link

Fix exports of `ogv-support.js`/`ogv-version.js` + some JS build clean-up #620

Open Mesoptier opened 1 year ago

Mesoptier commented 1 year ago

The main reason for this PR is to fix the issue where the compiled ogv-support.js and ogv-version.js files don't actually export anything, where you'd expect the OGVCompat and OGVVersion exports. In fact, these files would only assign those values to the global object.

I've fixed this by specifying the output.library.type: 'umd' option for these entries in the webpack config. This will make the exports work as expected in AMD/CommonJS module environments.

Additionally, by omitting output.library.name, the exports will be assigned directly to the window object when loaded in a <script> tag. Therefore, I've also removed the explicit window-assignments from the main three entrypoints.

See also: https://webpack.js.org/configuration/output/#type-umd


Other small changes to the JS build: