-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Include vtt.js using require/browserify #3794
Include vtt.js using require/browserify #3794
Conversation
* `browserify-shim` * `envify` * `unreachable-branch-transform`
script.src = this.options_['vtt.js'] || '../node_modules/videojs-vtt.js/dist/vtt.js'; | ||
if (process.env.VTT === false) { | ||
script.src = this.options_['vtt.js'] || 'https://cdn.rawgit.com/gkatsev/vtt.js/vjs-v0.12.1/dist/vtt.js'; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will be changed to true === false
or false === false
depending on envify
configuration. From there unreachable-branch-transform
will remove one of these if statements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dig it. Proper pre-processing! 👍
@@ -24,7 +25,17 @@ module.exports = function(grunt) { | |||
plugin: [ | |||
['bundle-collapser/plugin'], | |||
['browserify-derequire'] | |||
] | |||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does videojs-standard not complain about this trailing comma?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm I think that it should? maybe we ignore the whole build directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it does. Oh well. I don't have a problem with hanging commas. 😆
script.src = this.options_['vtt.js'] || '../node_modules/videojs-vtt.js/dist/vtt.js'; | ||
if (process.env.VTT === false) { | ||
script.src = this.options_['vtt.js'] || 'https://cdn.rawgit.com/gkatsev/vtt.js/vjs-v0.12.1/dist/vtt.js'; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dig it. Proper pre-processing! 👍
I just realized that unfortunately, this doesn't solve all our needs :( |
Looks like both envify and unreachable-branch-transform can be run separately from browserify. We could run those on tech.js after running babel before publishing and that should make it so webpack can require it manually. I guess it'll have to be run manually after the alt and dist files are generated so that they don't step on each others toes. |
Another option is to use something like https://github.com/erikdesjardins/babel-plugin-transform-dead-code-elimination, seems like it supports env vars by default and you can configure babel to run or not run plugins depending on env as well. |
Looks like that package is going to be deprecated in favor of babili. It's possible we can use just parts of babili to do what we want. For example |
I think that we currently have no way to include vtt.js with webpack like your describing (as we concat it onto the browser dist). We default to not including |
See #3919 |
Description
Right now we concat vtt.js right into the video.js bundle.
Specific Changes proposed
envify
to enable or disable a build with vtt.jsunreachable-branch-transform
to remove the require callbrowserify-shim
to wrap vtt.js if it is being includedRequirements Checklist