-
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
Add ES6 Transpiler? #1812
Comments
I'm torn on this one. |
Just to throw my 2-cents in, I like this idea. It would allow us to clean up so much code using string interpolation alone (like I mentioned in #357). |
👍 |
If we go this route (and I'm in the "yes" camp these days, too), I think we should stick to ES6 module syntax and not adopt any browserify/node-isms. Browserify is great but sticking to language features will give us more flexibility if something even more magical pops up in the next year or so. |
I do think that browserify is still the way to go right now. Whether we use the ES6 module syntax or not. |
Case-in point: https://github.com/videojs/video.js/pull/1909/files we wouldn't need to implement or maintain it if we could've just grabbed it from npm/browserifiy. |
I don't see these things as being mutually exclusive (so I think I mostly agree with Gary). My preference would be to use ES6 modules for internal requires, and standard require statements for things coming from NPM. Under the hood, as you said, all these things are converted to Commonjs by Babel anyway, so there isn't any performance penalty there. If we're going to go with ES6 syntax and start transpiling, why would we stop at Commonjs syntax? Going "all in" on ES6 for us would simply mean using a Babel transform in our Browserify step, which would functionally change nothing, but (theoretically) put us in a better position in the future. |
I think it's weird to combine node-requires and ES6-modules. Given that babel compiles it node-requires, I don't see a huge benefit from using ES6-modules yet if we're going to be using node-requires as well. |
We would need to do a spike to confirm everything works as expected, but based on what I'm reading in Babel's docs, we can use import syntax to simply require npm modules as well. |
Sounds like we can do it with the module formatters which has built-in support for commonjs. |
It sounds like everyone's on board with this, yes? @mmcc is going to do a research spike to see what kind of IE8 issues we may run into since it compiles to es5. |
We should make es5-shim a dependency. Either by including it ourselves directly or by requiring users of videojs to load in es5-shim before videojs. |
Ok so I've done a small spike to figure out what this would mean for us in practice.
So, with those two things in mind, if we want to actually do this, I think step 1 is to add Browserify with the Babelify transform and go through and re-do the Browserification work that way. Once we're done with that, we can start to experiment with ES6 syntax in other areas of the code base and see where IE8 starts barfing. Along with all of this, I think this starts to call for an optional IE8 import. Basically, something in the readme along these lines: If you want to support IE8, you'll need to include IE8-specific Javascript and CSS. <!--[if IE 5]>
<link rel="stylesheet" type="text/css" href="ie5.css" />
<script src="video.ie8.js"></script>
<![endif]--> |
Classes like the new class syntax? |
Yeah, it would feel pretty good to be able to do stuff like this: class Component extend CoreObject {
constructor(player, options, ready) {
/* ... */
}
} |
Yes? |
Just noting it. Nothing new, specifically. Though, they do want you to use their polyfill along with es5-shim. I wonder what exactly it adds compared to es5-sham. |
Yeah, sounds like we just need to use loose mode (which doesn't sound bad) and not use new features of the classes yet (static/getters/setters), but even without those we'd at least be using a standard class implementation instead of our own implementation. If we don't need the sham that'd be great. |
Closed by #1976 |
With the addition of browserify we're adding a required build step for running the code (i.e. can't just load the source files directly into the browser). Without going overboard, we could also consider adding other required build steps, like an ES6 transpiler.
A benefit would be that we could write more modern javascript today. A downside would be that it's yet another layer of abstraction adding potential complication to the debugging process.
Any other positives/negatives/comments/thoughts?
As a side note, the addition of ES6 would add the use of
let
, which would be a good point to re-evalute our single-var vs. multiple-var style rule. See #1781.The text was updated successfully, but these errors were encountered: