smogon / pokemon-showdown-client

The client for Pokémon Showdown
http://pokemonshowdown.com
GNU Affero General Public License v3.0
560 stars 786 forks source link

Modularizing client js files with RequireJS? #25

Closed dillonforrest closed 7 years ago

dillonforrest commented 11 years ago

Hey guys! I'm new here. Love this battle simulator so much!! :)

I realized that the javascript files are really massive. I'm interested in submitting a pull request to implement RequireJS. I'm wondering, are you guys openminded to that? Have you guys discussed this before?

Zarel commented 11 years ago

Yeah, Pokémon Showdown was my first major project, so I really didn't have a good idea of best practices when I started.

Well, in the most recent overhaul of the client, I rewrote the uglier parts of sim.js and split it into client.js, client-mainmenu.js, client-battle.js, and client-chat.js, which was nice since the old sim.js used to be the worst code in the entire repository (in addition to having a mildly non-indicative name).

That leaves battle.js as the main file left to be refactored, which I'll probably get to in due time.

I'm open to RequireJS, but I'm not sure if it's the hard part about breaking up large files... the hard part is refactoring, so they can be broken up, isn't it?

In general I guess I'm used to moderately large files: the client-battle.js at 33 KB is a pretty normal size for me; I wouldn't split it up further. I've seen projects that have a lot of much smaller files and it's always pretty annoying to figure out which code is in which file.

Not that I'm opposed to refactoring into more smaller files if that's what's best practice nowadays, but I guess first I'd like to know, how small are we talking? Which files would you split up, and how would you split them up?

Zarel commented 8 years ago

Browserify isn't compatible with the version of NWjs we're using on the desktop client, as I just learned... :/

Zarel commented 8 years ago

We can manually fix it, but ick.

Zarel commented 7 years ago

This hasn't been done in over a year, so I'm guessing this is dead. Any major client overhaul should probably be done with a TypeScript refactor, anyway.