question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Refactor client to ES6

See original GitHub issue

Wondering 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:open
  • Created 6 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
3rd-Edencommented, Apr 10, 2017

The main reason would be to have a consistent code base. As the rest of the code is already in ES6.

0reactions
joepie91commented, May 19, 2018

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:

a unified code base here where everything is written in ES6 classes, const, fat arrows

… 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 use let), 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.)

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found