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

Require videojs-vtt.js via require rather than concat #3919

Merged
merged 2 commits into from
Jan 11, 2017
Merged

Require videojs-vtt.js via require rather than concat #3919

merged 2 commits into from
Jan 11, 2017

Conversation

brandonocasey
Copy link
Contributor

@brandonocasey brandonocasey commented Jan 5, 2017

Description

Use require on videojs-vtt.js rather than adding on to the end of the bundle after building.
This PR replaces #3794

Specific Changes

  • cleanup build/grunt.js for browserify
  • use aliasify to exclude videojs-vtt.js for novtt builds
  • allow fallback to old script vtt include
  • fix a bug where shell:babel was passing --w to babel rather than -w or --watch

Requirements Checklist

  • Feature implemented / Bug fixed
  • If necessary, more likely in a feature request than a bug fix
    • Change has been verified in an actual browser (Chome, Firefox, IE)
  • Reviewed by Two Core Contributors

use aliasify to include/exclude vtt.js require
allow fallback to old script vtt include
fix a bug where shell:babel was passing --w rather than -w or --watch to babel
@gkatsev
Copy link
Member

gkatsev commented Jan 6, 2017

As you mentioned @brandonocasey, we should look at how safe it is to bring this in as a minor since it's theoretically possible. Would make it a bit easier for current suers.

@@ -326,32 +318,39 @@ module.exports = function(grunt) {
}
},
browserify: {
options: browserifyGruntOptions(),
build: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, build is now the main task and takes the job of both build and dist?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the difference between the two was that dist would replace the vtt.js string path with a url to the cdn. Since we will require vtt.js by default when we build it isn't really needed to do them separately

buildDependents.map(task => task === 'browserify:build' ? 'browserify:dist' : task)
);

grunt.registerTask('build:dist', buildDependents.map(task => task));
Copy link
Member

@gkatsev gkatsev Jan 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to map here anymore. Or we could just get rid of it this task.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we may just want to get rid of the task

*/
addWebVttScript_() {
if (!window.WebVTT && this.el().parentNode !== null && this.el().parentNode !== undefined) {
const vtt = require('videojs-vtt.js');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, basically, this requires vttjs and then below, we make sure that it becomes available globally unless the vttjs option was provided. In the novtt build, a transform tells browserify not to include this file in the output?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we use the vtt.js option if we have it, if not we use the require if it is available (which it won't be for novtt builds), otherwise we use the cdn url.

The transform that you mention works like this:
aliasify when passed false for a package alias will turn the require call into an empty object {} before browserify includes in in the bundle.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, just wanted to confirm I'm understanding it correctly.

*/
addWebVttScript_() {
if (!window.WebVTT && this.el().parentNode !== null && this.el().parentNode !== undefined) {
const vtt = require('videojs-vtt.js');

// load via require if avialable and vtt.js script location
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

av*i*alable to ava*i*lable (i after the a).

@brandonocasey
Copy link
Contributor Author

@gkatsev fixed the typo and removed build:dist ready for re-review when you get the time.

@gkatsev gkatsev merged commit d290db1 into videojs:master Jan 11, 2017
@brandonocasey brandonocasey deleted the chore/browserify-novtt branch February 2, 2017 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants