Skip to content
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

Support ES6 import in uncompiled mode #466

Closed
mseeley opened this issue Jul 27, 2016 · 6 comments
Closed

Support ES6 import in uncompiled mode #466

mseeley opened this issue Jul 27, 2016 · 6 comments
Assignees
Labels
status: archived Archived and locked; will not be updated type: enhancement New feature or request
Milestone

Comments

@mseeley
Copy link

mseeley commented Jul 27, 2016

Getting started with Shaka is easy. Install shaka-player through npm and step through the basic usage documentation and quickly we're playing a video. This is good thanks.

Our application is build on ES6 modules using WebPack and Babel. Including shaka-player into our player is as simple as: import shaka from 'shaka-player';

Going from this to a uncompiled version is unclear. The good velocity from setup and getting started hit a wall.

To load the library without compiling, you will need to generate a Closure "deps file" by running ./build/gendeps.py. Then, you'll need to bootstrap your application with three < script > tags:

In order to run in uncompiled mode we have to checkout the repo, build deps, then include these files in an HTML document. What's implied is the HTML document is in the root of the shaka-player repo. This is fine when you're debugging isolated test cases. This is nearly impossible to use when debugging integration issues with application logic.

Integrating an uncompiled Shaka Player into an application is unclear. The script element recommendation won't work, dep paths are inaccessible. Importing the three files also doesn't work; they collaborate using global variables and don't understand exports. So, the import approach above doesn't work as:

import 'shaka-player/third_party/closure/goog/base';
import 'shaka-player/dist/deps';
import 'shaka-player/shaka-player.uncompiled';

It was a long shot anyway. I didn't expect the multiple import approach to work, but, hey, grasping for uncompiled straws.

Will you please consider making it easier to debug integration issues? As a developer, quickly swapping a CDNJS link from the compiled to concatenated but not mangled build would be effortless. Same is true to use a import shaka from 'shaka-player/debug'.

I'm unsure if "compiled" means concatenated and minified in the Closure Compiler world. If not, please do consider making debugging flexible while avoiding requiring users build their own players from source.

Thanks for reading!

@joeyparrish
Copy link
Member

"Compiled" in Closure means actually compiled. The Closure compiler not only minifies and concatenates, but also takes into account type information, enforces type-safety, and applies compiler optimizations.

If you're installing from npm, the deps are already generated. The real issue seems to be that you're using ES6 imports instead of script tags, which is honestly not something we anticipated.

As such, I'm renaming this issue as "Support ES6 import in uncompiled mode". I'm not sure how we would do this off-hand, but we will keep it in mind when we start planning our next major release. Thanks!

@joeyparrish joeyparrish changed the title Request: Easier uncompiled library debugging. Support ES6 import in uncompiled mode Jul 27, 2016
@joeyparrish joeyparrish added the type: enhancement New feature or request label Jul 27, 2016
@joeyparrish joeyparrish added this to the v2+ milestone Jul 27, 2016
@ajbeach2
Copy link

ajbeach2 commented Aug 16, 2016

You should be able to do this with webpack. Its probably a case of using the expose-loader

https://webpack.github.io/docs/shimming-modules.html

@ajbeach2
Copy link

I haven't been able to test it but, i believe this is how you would do this:

npm install script-loader
require('script!shaka-player/third_party/closure/goog/base.js');
require('script!shaka-player/dist/deps.js'')
require('script!shaka-player/shaka-player.uncompiled.js')

@joeyparrish joeyparrish modified the milestones: Backlog, v2.1.0 Dec 15, 2016
shaka-bot pushed a commit that referenced this issue Dec 20, 2016
This adds a new option (--debug) to build/build.py which allows
building for debugging.  This will expose all internal members on the
global |shaka| object and will not rename anything.  This allows apps
to import the single compiled file but still perform debugging.

This also changes the file naming a little.  Before, we would create
a |.debug.js| and |.debug.map| file when we compiled.  However this
was not a debug file, it just linked to the source map.  Now it will
always generate the source map and attach it to the compiled file.  If
compiling with --debug it will add |.debug| to the file name.

This should also help with importing the debug library in ES6.
Issue #466

Change-Id: Ic51abbdb04763e8a3687c5d59a23d721436e1c7b
@TheModMaker
Copy link
Contributor

Now you can pass --debug to the ./build/build.py script to not rename anything and expose all private members. This should allow you to import it the same as the non-debug version but still have the normal names.

We will also be adding the debug version of the compiled library to future versions on npm. So you can include shaka-player.compiled.js for your production code and shaka-player.compiled.debug.js for debugging. So once we release v2.1.0 you will be able to just pull the debug version from npm.

@TheModMaker
Copy link
Contributor

@mseeley does this work for you? Can I close this?

@mseeley
Copy link
Author

mseeley commented Jan 26, 2017

Hi @TheModMaker. It sounds like it could; thanks a lot for the ping. :)

Please feel free to close this. I'll open an issue with updated context if we have trouble.

Thanks!

@shaka-project shaka-project locked and limited conversation to collaborators Mar 22, 2018
@shaka-bot shaka-bot added the status: archived Archived and locked; will not be updated label Apr 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: archived Archived and locked; will not be updated type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants