-
Notifications
You must be signed in to change notification settings - Fork 438
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
[meta] Client refactor or rewrite #894
Comments
Continuing from the discussion in my PR
Better test coverage is a great start. TypeScript is very similar to JavaScript; it looks to me that it would be easy enough to understand quickly, especially if the contributor is familiar with other static/strongly typed languages. I tried to look into TypeScript's popularity, and according to GitHub, TypeScript is 4th, while JavaScript is 1st. Stack Overflow's developer survey lists TypeScript as the 3rd most loved language, behind Rust and Clojure, and JavaScript is 15th. I won't look into that too much because it's a very opinionated point. But it is cool to see.
I feel that with the proper tests, then using dependabot and pinning the dependencies to an exact version would be good. Ideally, the CI could run the tests on dependabot pull requests, which would catch any behavior differences the new package adds. That combined with the screenshot tests would hopefully mean that you don't have to do any manual testing on the new dependency. There should only be pull requests for the top-level dependencies (in this case, If we're going to want to start using ES6 features, TypeScript would allow us to use them, but transpile an ES5 JS output. We could also use I don't know if I'm really explaining this well, maybe I'll have to play around with it first before I can. See also: |
While looking at the experimental client code, I think I sort of see how JSvar App = function(conf) {
this.conf = conf;
}
App.prototype.initWidget = function() {
var self = this; // Preserve App object instance context
renderSomething(self.conf);
// [...]
}
// later, in other file:
var app = new App('conf');
app.initWidget() TSclass App {
constructor(conf) {
this.conf = conf;
}
initWidget() {
var self = this; // Preserve App object instance context
renderSomething(self.conf);
// [...]
}
}
// later, in other file:
var app = new app.App('conf');
app.initWidget() To me the TypeScript example is a lot cleaner and more familiar. I actually feel like TypeScript would be easier for people to learn if they don't know JavaScript at all. Another advantage is that editors (such as Visual Studio Code) can give much better suggestions because of the static nature of TS. I asked a few friends who do web development and they told me that your JS example is the normal way to do it in JS, but also that TS is worth it. I think I'll still make my own experimental version, but I'll try and use modern frameworks and all so I can learn them, and so it's not just a second pointless rewrite. Also I found out that adding TypeScript adds only two packages total to the entire ~500 package tree1. And it takes no extra work on the developer's side since Webpack can be easily configured to just transpile the TypeScript before it does its bundling. I tried this on the experimental client, see BBaoVanC/isso-client-experimental@749e5862f37bf28ef61a34fe33e3ff46ad4d485f2 Footnotes
|
That TS only pulls in one mono-package (plus a few for I added you as a collaborator to the repo, feel free to push. |
I've been taking a look and I feel like the way the experimental rewrite is structured is more complicated or harder to understand than the original source here. And I don't know if rewriting it in TS is as much worth it as I thought. Currently I'm trying to figure out if I can make my own version in React & TS to see if it can bring any better structure (hopefully without making it too complicated either), but it'll be a bit before I can know for sure. Hopefully using React to handle internal structure could make it easier to develop on top of. I'll show it soon if I can get a good working client in it. Maybe React.js and it's component-based structure makes it more organized to add extensions? This is something I'll look into as well. I'm also worried about whether rewriting anything is worth it, compared to just gradually improving the existing code. |
I share your hesitation with rewriting things from scratch. You'll notice that the experimental client still shares most of its code with the stock one, so a "rewrite" is probably not the correct term to use.
So a lot of hen-and-egg problems, where we'd need some kind of central arbiter that listeners can register with, that is responsible for keeping state. If adding a framework such as React helps with that or enforces some common best practices, I'm all for it. But I'd rather avoid adding too many dependencies and forcing us into some patterns before we've each deemed that change beneficial and necessary. I'd propose we each do some more research, experiment a bit and then revisit this topic. |
Interesting news, IE is now out of support as of today. And it was really the only reason we weren't using more modern features like CSS variables and ES6 right? What do you think about updating some of the CSS and JS in the near future? |
M$ unilaterally declaring something out-of-date doesn't magically make people stop using it. That being said, if we get ES5 compat "for free" when using TypeScript, I'm all for that. CSS vars: Caniuse currently states 94% browser support. |
Currently, the client is heavily DOM-dependent and written in ES5-compatible syntax.
Testing - although some great improvements with
Jest
andpuppeteer
have been made - is still hard to do.We cannot currently make use of real
Promise
orawait
functionality and other ES6 goodies. The justification for sticking with older source code syntax has been laid out in #834, but this is not official policy but rather the opinion of 1 maintainer, subject to change.Things to think about:
setTimeout
)New or improved features
**
around the cursor (like GitHub, remark42, ...) (idea: cursor)<textarea>
See also
contenteditable
div
withtextarea
#887 (comment)The text was updated successfully, but these errors were encountered: