-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
webpack-terser-plugin slices console calls and shaka crashes #5032
Comments
I think it's up for debate whether this is a bug or not and I'm curious about the Shaka teams view on this. I would say that, when stripping code out of pre-bundled dependencies, unexpected behaviour should be expected. I believe the norm is to not include dependencies in transpilation when they are already bundled/transpiled. I think it's reasonable to want to remove all console logs from production environments, so in that sense it feels like a bug. In the mean time, Terser accepts an exclude pattern that can be used (as I'm sure you're aware of): module.exports = {
optimization: {
minimizer: [
new TerserPlugin({
exclude: /node_modules/, // or path to shaka package
}),
],
},
}; |
@martinstark for sure it is debatable. We knew I flagged this as a bug because it is not a feature nor a question, so the most suitable was it. I'm curious too about the Shaka team's view on this. |
In the general case I'm not sure if we should be changing our code so that it works better with tools that post-process the code. In this case though, it seems like a fairly simple fix so we might as well do it.
Because we didn't think to check the log function when deprecating IE, probably. Might as well change that at the same time. |
This removes some workarounds that were in the logging code for the sake of Internet Explorer. We no longer support IE, so those workarounds are no longer necessary. Issue shaka-project#5032
I disagree. Interoperability is good, and our single bundle of JS is increasingly unusual in the ecosystem as everyone moves to modules and TypeScript. Thanks for working on the fix, @theodab! |
Also, one thing that is easy to mistake here is that we never supported IE 8 and 9 for Shaka Player, but the bundle was designed not to throw at load-time on those older browsers (we began the project in 2014) so that we could at least return |
This removes some workarounds that were in the logging code for the sake of Internet Explorer. We no longer support IE, so those workarounds are no longer necessary. Closes #5032
This removes some workarounds that were in the logging code for the sake of Internet Explorer. We no longer support IE, so those workarounds are no longer necessary. Closes #5032
This removes some workarounds that were in the logging code for the sake of Internet Explorer. We no longer support IE, so those workarounds are no longer necessary. Closes #5032
Have you read the FAQ and checked for duplicate open issues?
Yes
What version of Shaka Player are you using?
v3.3.15, but the code is the same in v4
Can you reproduce the issue with our latest release version?
Yes
Can you reproduce the issue with the latest code from
main
?I guess so, didn't test
Are you using the demo app or your own custom app?
Custom app
If custom app, can you reproduce the issue using our demo app?
Not needed
What browser and OS are you using?
Whatever modern browser is good for this issue
For embedded devices (smart TVs, etc.), what model and firmware version are you using?
_
What are the manifest and license server URIs?
What configuration are you using? What is the output of
player.getConfiguration()
?What did you do?
See discussion below
What did you expect to happen?
See discussion below
What actually happened?
In our custom application, we are adding
webpack-terser-plugin
, which uses https://github.com/terser/terser under the hood.We have a lot of
console.log
s that we want to remove in the production build. Therefore we set in Webpack the following configuration:This configuration trims all the
console.*
, even those in shaka.We were experiencing an error which we investigated up and found out to be something like:
Minified something like this:
This was being triggered by the fact that through shaka v3 we are still using
addTextTrack
instead ofaddTextTrackAsync
, so we were actually able to fix this on our side, but this issue might still happen with other methods, theoretically.Why does it happen? We found out the responsible is this piece of code, available both on v3 and v4:
shaka-player/lib/debug/log.js
Lines 137 to 155 in c7c5e94
Which, I guess is done to let deprecation warnings to always get shown.
The issue is that, when using
webpack-terser-plugin
, that code becomes this.First image is the compiled one:
Second image is after terser compilation:
So, it is clear that
z
receivedundefined
as value and whenshaka.log.alwaysWarn
is invoked, this crashes becausee.console
(so,window.console
) still exists, but the bindings were actually removed.Thank you.
P.s. why do bindings still exist if it was a workaround for IE 8 and 9, if they are not supported anymore?
/cc @salvatore-esposito-green (my colleague)
The text was updated successfully, but these errors were encountered: