-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Export shaka as ES6 module #1509
Comments
First, we now compile the wrapper template, so that text will no longer be used directly in the compiled bundle. If I add But if I manually change the compiled bundle to add that to the beginning, no browser can read it. Even Chrome gives a syntax error when it tries to read that file; that would require using an ES6 module loader, you can't load that in a But that wrapper is designed to support different module loaders, maybe we could support what you want to use too. See the comments in the current wrapper.template.js file. How are you loading Shaka Player that it needs this? Does it work without it? |
You can load ES6 modules now in a |
We use JSPM for package management and bundling. I'm not intimately familiar with JSPM, but based on my reading, it is configured to read shaka-player.compiled.js as a CommonJS module, and then expose this to use in ES6 module style. Could the method of export be configured at build time via a flag? |
Important detail I forgot to mention: we don't track Shaka as a dependency via npm. I believe there was once a reason for this but I'm hard-pressed to think of it now. Switching it over to npm may obviate the need for es6 module definition. Let me get back to you. |
We could have a build-time flag to export as an ES6 module. What we could to is have a second version of I am curious though, if JSPM is loading using CommonJS, why doesn't it work? We support loading as a CommonJS module (which doesn't use ES6). |
So I realize I never followed up on this. Part of the reason is that our build was undergoing some changes. Now it is quite different. We use Rollup for concatenation and use rollup-plugin-commonjs to bundle Shaka. We publish our library in ES6 now. Shaka is our only external dependency, so if it was possible to import it as an ES6 module, we wouldn't need to worry about commonjs at all. We're going through some continued refactoring and migration to TypeScript, so if we think there's some benefit we may file a PR to add ES6 module export support to Shaka. |
What's about the ES6 Module about shaka-player ? I'm try to implement the player in WebComponent.... Insert the global shaka object brokes my element isolation policy. |
(Edit: updated because at first I was looking at an old version of the template)
I would like to change wrapper.template.js to return
shaka
from the IIFE so that it can be exported as an ES6 module. It seems the compiler also transpiles the template, which I don't want.Currently we enable
import shaka
via a JSPM configuration. I don't see the need for this configuration, and I would like to remove it, ifshaka
could be exported as an ES6 module. Could the template be changed, or would this be a problem for users who need to support legacy browsers?To be clear, the change I am proposing is:
wrapper.template.js
The text was updated successfully, but these errors were encountered: