It seems that some websites have a global "define" object set to null.
This caused our module loader to break when Shaka Player was loaded.
By checking for "define" to have a "function" type, rather than just
being defined at all, we can avoid this problem.
Closes#2847
Change-Id: I645f61687b9ec298bcc51c8d128398cdad3dd3b9
This fixes all the license headers in the main library, which corrects
the appearance of the main license in the compiled output.
It seems that the `!` in the header forces the compiler to keep it in
the output. I believe older compiler releases did this purely based
on `@license`.
Issue #2638
Change-Id: I7f0e918caad10c9af689c9d07672b7fe9be7b2f3
The module wrapper expects to be in charge of exporting to module
loaders, but so does eme-encryption-scheme-polyfill, which is compiled
into the bundle. To resolve this, the wrapper can hide the "module"
symbol from the inner part of the bundle, preventing it from doing its
own exports.
In v2.5.x, this was hidden by an apparent compiler bug that resulted
in module.exports being renamed in the compiled bundle. Since "Unfork
Closure base and update the compiler", Change-Id
I62ec61e82d4edf342b2c576c2d4f89f11562ee65, this is no longer the case.
Closes#2549
Change-Id: Id26002bc1c51ed423d77e7b3e7daf40b714b9f2f
This updates our wrapper in several ways:
- Adds comments and whitespace and meaningful variable names
- Makes the CommonJS loader compatible with Electron, fixing #1463
- Adds a "global" parameter to the inner scope, fixing #1455
- Strips whitespace and comments from the wrapper during the build
The wrapper is much more readable and debuggable, which should help
maintain support for these various module loaders in the future.
Tested and working with the new wrapper:
- CommonJS (NodeJS, etc.)
- AMD (requirejs)
- Electron (loads into global scope without loader, no longer
conflicts with CommonJS)
- ES modules (partially supported, loads into global scope)
Since the wrapper is now fixed in a way that avoids #1455 and
google/closure-compiler#2957, this also reverts
"Patch Closure Compiler to fix polyfill+wrapper",
commit 962ec0a22d.
Closes#1463
Change-Id: I5d3ac056cb8db04dc714afee0cb069f2a45a456d
This will allow support-testing to work on older browsers so that
application developers can still load the library and query for
support to show an appropriate error message.
To accomplish this, we avoid load-time uses of Function.bind, avoid
certain polyfills if modern types are not available, and compile down
to ES3 to avoid errors caused by use of the reserved word "catch" on
Promises.
This has been tested back to IE6, Safari 5.1, iOS 6.0, Firefox 6,
Chrome 15, and Opera 16.
Change-Id: I9deed106a7736758e04452ef85bae40f37c6fe62
To prevent crashing with other module loaders that support `define`, but are not full AMD module loaders, check for `define.amd` as well before defining the AMD module.
The new wrapper has been tested using:
* commonJS in node.js
* requireJS in node.js
* requireJS in a browser
* directly in a browser
This also corrects the exports for commonJS to omit the "shaka"
namespace. For example, you now get "module.exports.player" instead
of "module.exports.shaka.player".
Change-Id: Idf6b05d7d667aded925818001f730747ceeae2e9