gbdev / rgbds-live

A live Gameboy programming environment in the browser, allowing for realtime assembly programming for the gameboy.
https://gbdev.io/rgbds-live/
MIT License
36 stars 8 forks source link

Replace globals with ES modules #21

Closed surma closed 11 months ago

surma commented 11 months ago

This is my attempt to modularize the code base and remove any implicit global passing. I changed no business logic, only code patterns and structure. This PR might be easier to consume if you go through by commit.

This means that the dependencies of each code module have to be explicit and the bundler (and browser) can automatically take care of running and executing the code in the right and more efficient order.

I tried to turn ACE into an ES module (they publish it as RequireJS), but our current, somewhat outdated version of ACE only let me get so far. I’d like to update ACE to the most recent version in a separate PR where I think I can remove the last remaining global.

I also replaced old-school prototypical inheritances withe ES6 classes and set up prettier to enforce a consistent code style (run npx prettier --write <file>), although I haven’t applied it to all files as it would have just made the PR more noisy.

I did not fully fix up gfxEditor.js as I realized it’s unused and actually broken? I’d love to fix that in a separate PR.

There’s more untangling and streamlining that I’d like to do (like using async/await more), but I figured this PR is prob big enough as it is and now that it’s modularized, I’d feel more confident tackling each module independently. Let me know what you think.