-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Use ES6 "class" as module syntax #8359
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
Comments
This is to support browsers that don't yet support ES6 syntax without requiring a transpilation step. Here's a quote from our blog post going over the whole migration that I encourage you to check out:
With that said, having a transpilation is something we want to support in order to use newer ES6 syntax and features. Also from the blog:
I'm going to leave this open as a feature request to use this particular ES6 feature, since even if we do add a transpilation step it would have to be another effort to change how classes are declared. |
@OmarShehata I'm actually going to close this, the use of class will be part of a much larger discussion/decision/change so having this open as a standalone issue isn't really actionable. |
@mramato is there a different (good) place to discuss this publicly? I'm currently consuming Cesium from Typescript (c.f. #5717 #4434 etc) and I think I could fully automate that process if the "class-like" new-able function pattern that Cesium uses were to move to ES2015 class syntax. I explain in the "Typings" issue, but briefly, Typescript can successfully extract type information from JSDoc for almost all of Cesium, except where getter/setter functions are passed to As a small test case, I converted |
I think it's valid to have this issue open:
We will need to discuss the strategy for how to port over code. If we'd like to take a similar approach to how we moved to using prettier, we'd need some sort of automated method. I just came across Lebab, the opposite of Babel, for converting from ES5 syntax to ES6+. We'd need to do a test run to see if its possible to use for our codebase. |
Some brainstorming in terms of the strategy (even though some of that may be obvious): Two important dimensions are
For 1, some options are:
For 2. the options are ... well, at least everything that is listed as "Transforms" on https://github.com/lebab/lebab , and more... (Note: The considerations here are independent of whether we give 'lebab' a try or not. It seems unlikely for me that this could be a one-shot solution in general. And even if it was, technically, the following still has to be kept in mind: ) The possible modernization changes vary wildly in terms of their impact and their potential for "breaking" something. One recommendation from the lebap README is
and this also applies if we did certain changes manually. Note that these are really independent dimensions. For example, we could
I think that 2., "Which updates will be applied", can be answered more generically. A few random examples of the changes that could be part of such a modernization (roughly inspired by the lebab README):
Now... we can argue. Or vote 🙂 |
I'll start by saying I fully support swapping to
Even if this seems like the smallest effort up front I think of all the options this is the only one we should definitely not do. I think this approach can easily turn every PR into a mini-refactor and make them take longer. It also obfuscates the actual change of a PR. Much easier to review 1 pr for some change and a second PR that is only code restructure but should behave identically before and after. I think going section by section could work pretty well and unless we can fully automate transformation through something like
I think we should focus this issue and the subsequent PRs/changes on only the transition from Unrelated to your 2 points we may want to just take a peek at performance. I believe there were articles years ago when Some random articles I found doing a quick google
|
Although it probably does not make sense to try and talk through all degrees of freedom, scenarios, and granularities here, I think it's important to be aware that there are many degrees for this. The point is: There is no clear cut between "applying style and conventions" and "a refactoring". For example, when someone is touching a piece of code, and, say, adds another option to an
then one could make a case to just update this, to
iff (if an only if) the coding guidelines suggest that this is the preferred way (see #12196 ). Similarly, when someone is fixing a bug where some wrong argument is passed to a function as in
one could make a case to not just change the
However, this is related to the question of which changes are (supposed to be) applied. And when there is one, specific change, like the " |
A specific detail: Right now, it is never clear which functions are actually implementations of a certain "interface". In some cases, the JSDoc mentions something like |
Should we even be considering thisI wanted to do some due diligence to make sure there were not going to be any performance implecations with this change. In general I have not found anything that would indicate this is a bad change or would negatively impact our performance overall. If you have seen anything like that please let me know, happy to discuss.
MDN's in depth dive on Inheritance and the Prototype chain makes a couple mentions of performance but mostly focused on the fact that the way we currently do it is more error prone even if there is potentially a small benefit. I think it would be good to switch to Another side note that I find compelling is that All of this is also a completely moot point when considering that a large percentage of users will probably have some sort of build tooling of their own that will re-transform our code and may or may not keep the Couple other links to interesting reads but not directly relevant composition, hidden classes Path forwardSpeaking with @ggetz I think we came up with a pretty good plan to move forward with this that allows us to trial the change and prove out the process without a full refactor of the entire library
|
Small status update with some general findings
Some observations/notes on the process
CC @ggetz |
I have not yet read through all the changes in the branches that you linked to (they are huge, as expected, and identifying the actual changes will probably be easier by looking at the commits, and not the changes as a whole). But one thing that seems to be pretty relevant in this |
Follow up RE: I took a little time over the weekend to take a stab at adding support for |
I am looking into using cesium for a project and this point is important to me. So from an explorability viewpoint this change would be huge. |
So I can extend your class directly using
extends
,and so on.The text was updated successfully, but these errors were encountered: