Refactor client to ES6
See original GitHub issueWondering what people’s opinions are on this. Currently, the primus.js
file in the root of this repository is still written in ES5. Would it make sense for a maintenance point of view to transform this to ES6 as well and just have babelify it during the browserify process so we end up with ES5 again?
Obvious downside would be a slight increase in file size due to extra babel helpers and other sorts of polyfills that would be added but it might make more sense to have a unified code base here where everything is written in ES6 classes, const, fat arrows.
The only biggest hurdle we would need to tackle is Node.js support, because we re-use the same client code base from the browser for the Node.js client.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Automated refactoring of client-side JavaScript code to ES6 ...
This work focuses on refactoring client-side web applications for the elimination of code smells, relevant to global variables and functions that are declared ......
Read more >Automated Refactoring of Legacy JavaScript Code to ... - arXiv
js, are refactored to standalone declarations and exported to client modules through. ES6 named export statements. The module structure is ...
Read more >Automated refactoring of client-side JavaScript code to ES6 ...
This work focuses on refactoring client-side web applications ... through automated refactoring to ES6 modules. Our approach.
Read more >Automated refactoring of legacy JavaScript code to ES6 modules ...
We refactor ES5 code to ES6 modules and advanced use of named imports/exports. •. We specify the refactoring identification algorithm and code transformation....
Read more >Refactoring React Components to ES6 Classes
Refactoring React Components to ES6 Classes · Step 1 - Extract `propTypes` and `getDefaultTypes` to properties on the component constructor · Step ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The main reason would be to have a consistent code base. As the rest of the code is already in ES6.
It’s important to keep in mind that ES6 does not replace ES5. It merely adds a number of new features to the language that can help in the cases where they are appropriate (ie. where they fit the requirements well).
Rewriting code to “use ES6 features as much as possible, for the sake of using ES6” is therefore a bad idea. This particularly applies to remarks like:
… which isn’t really what you’d want. The value of ES6 classes is dubious in and of itself,
const
is not necessarily universally applicable (eg. when you need to reassign things you’ll want to uselet
), and arrow functions are not functionally equivalent to regular functions; they have different semantics, so they can’t wholesale replace regular functions.I’m not at all saying it’s a bad idea to start using ES6 features, provided that the transpilation concerns are addressed, but trying to maximize ES6 feature usage makes no sense and will just lead to a bigger maintenance burden.
(On a loosely related note, while ‘consistency’ can be a beneficial factor to readability and maintainability in some cases, it can also work against it; consistency in and of itself should really never be a design goal of any codebase.)