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