-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Also provide a light ES module (without the worker) #5484
Comments
Hi @Chocobozzz, Would you consider contributing the change in the form of a PR? The configuration you as asking for is missing from build-config.js: Lines 273 to 298 in 093a41c
|
Sure! #5486 |
Hey @Chocobozzz do you have the error message you get? If it’s due to the wrapping function name getting mangled we might be able to fix that |
If you have a link to the broken build so I can reproduce it that would be awesome |
The broken build is on https://peertube2.cpy.re/videos/embed/tKQmHcqdYZRdCszLUiWM3V The webpack configuration that provides such build is https://github.com/Chocobozzz/PeerTube/blob/develop/client/webpack/webpack.video-embed.js You can re-create the build by:
|
Thanks but I get a 401 on that url atm |
Arf sorry. Here is a public link: https://peertube2.cpy.re/videos/embed/aXCh29qwRKFFmuNVFNL7vT |
Apparently the name that is being mangled by webpack/terser is I was able to work around this by passing |
Here's a very minimal broken build: https://github.com/pasieronen/hlsjs-terser-bug |
Thanks @pasieronen that was super helpful. So webpack without minification rewrites: (function (global, factory) {
console.log('factory', factory);
console.log('typeof exports', typeof exports);
console.log('typeof module', typeof module, module);
console.log('typeof define', typeof define, define);
console.log('global', global);
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Hls = factory());
})(this, (function () { 'use strict'; to (function (global, factory) {
console.log('factory', factory);
console.log('typeof exports', typeof exports);
console.log('typeof module', "object", module);
console.log('typeof define', "function", __webpack_require__.amdD);
console.log('global', global);
true ? module.exports = factory() :
0;
})(this, (function () { 'use strict'; which when loaded in a worker would actually fail on Without the console logs though the unminified one works because outside the worker there is a When webpack minifies though the So yep marking I think a way for us to avoid this would be a custom amd header that also knows if it's running in the worker, which then could bail early and just run the factory function. Something like (function __HLSJS_BUNDLE__(inWorker, global, factory) {
if (inWorker) { factory(); return; }
//...
})(false, this, (function () { 'use strict'; where when the code is built for the worker I've approved #5486 though because I think it makes sense to also offer that build :) |
Actually I think we could move the |
Is your feature request related to a problem? Please describe.
With 1.4, minification using esbuild or terser broke the worker module (from
hls.js
orhls.light.js
) when hls.js is bundled inside our client application (webpack bundled).I was able to use the ES module with the worker thread using the following options:
Unfortunately current NPM dist files don't include a
hls.light.mjs
so our bundle size increased even if we don't need alternate-audio, subtitles, CMCD, EME (DRM), or Variable Substitution support features.Describe the solution you'd like
Provide a
hls.light.mjs
dist fileAdditional context
Thanks for your work, very appreciated 👏
The text was updated successfully, but these errors were encountered: