Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upES6 Refactor #444
ES6 Refactor #444
Comments
This comment has been minimized.
This comment has been minimized.
|
Thanks for your enthusiasm to contribute to WebTorrent! Sorry, but I don't think that it's worth adding a compilation step and using features that don't work in most node.js environments for a bit of synatic sugar. Maybe in a year or two when ES6 is available to the majority of node.js users (i.e. they are running iojs or node v4). Right now, I believe 0.10 is still the most widely used version. If you're looking for a good first issue to work on, take a look at the "good first contribution" and "help wanted" tags. Thanks again! |
This comment has been minimized.
This comment has been minimized.
|
Well, it's been a year and |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@feross It looks like WebTorrent has required Node 4+ since August. c567e67
All the browsers that WebTorrent supports also seem to have mature ES6 support, so no compiling would be necessary.
The arrow functions and classes alone improve the maintainability and readability of a code base enough for me to justify using ES6 features. Another advantage would be the advanced tree shaking that is possible with ES6 style import statements. Since WebTorrent is a rather large code base, it would be really nice to let rollup walk the AST and remove the parts of WebTorrent I am not using. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
We switched to requiring Node v4 because the version of npm in older versions of node couldn't install git dependencies. ES6 is cool, but it's not worth completely breaking the demos on https://webtorrent.io for IE11 and the the previous version of Safari (9) just for a little syntactic sugar. There are also lots of users depending on the fallback to web seeds in browsers without WebRTC support. If we gain something from the switch, like being able to use a dependency we really want/need, then I'm okay with ES6 in this codebase. The tree shaking argument is interesting, but I'm skeptical that webtorrent's size can be reduced much. I've combed through the codebase meticulously to minimize file size. As it stands, we have an entire torrent client in 77kb, which is really great as far as I'm concerned
|
This comment has been minimized.
This comment has been minimized.
|
That said, if you want to contribute to WebTorrent development and insist on not sullying your fingers with any ES5 keystrokes, you can check out |
This comment has been minimized.
This comment has been minimized.
|
@feross I whipped up a proof of concept and pushed it to deckar01/webtorrent/444-es6. I don't expect you to do anything with it, but I may merge in upstream changes occasionally. Here is a summary of how I found the new ES6 syntax to be useful:
There were some other refactoring opportunities I found that did not rely on ES6 features. There are some excessively nested closures that are much easier to understand once they are decoupled into class methods. I got the tests passing on Firefox and Chrome, but I couldn't get sauce to start IE. I found a thread where you had a similar issue in the past. Any help would be appreciated. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
I'm not sure if market share is the right question. |
This comment has been minimized.
This comment has been minimized.
|
This thread has been automatically locked because it has not had recent activity. To discuss futher, please open a new issue. |
This comment has been minimized.
This comment has been minimized.
|
Continued here: #1443 |




Would Webtorrent consider an ES6 refactor if it was sent as a PR? Maybe not all of it at once but part-by-part.
Would probably use Babel for transpiling but could use shims instead.