melonjs / melonJS

a fresh, modern & lightweight HTML5 game engine
https://melonjs.org
MIT License
5.9k stars 645 forks source link

Make Melon.js a compiler plugin #1109

Open L1lith opened 2 years ago

L1lith commented 2 years ago

I wonder how much compiler optimization we could do under the hood. It could also increase performance in cross-platform environments. For example all Melon.js API calls are an abstraction over the native APIs, so we could write our library for melon.js, and then at compile time we could remove the melon.js library all together from their code and replace their function calls with native API functions for better performance.

This would also be cool because we could compile for other targets more easily like console or mobile without any performance penalties besides the JS runtime itself (meaning no melon library to load and no bridge needed at runtime between the melon JS internals and the native APIs)

This does sound like it could be a lot of work but I think it would be a super nifty feature if anyone feels like figuring out how to do this. I'm currently doing research on doing this on one of my libraries so I might write an update on what I've learned.

L1lith commented 2 years ago

See Also: https://github.com/melonjs/melonJS/issues/1134

L1lith commented 2 years ago

I don't think this should be a big priority for now tbh. Ironing out ES6 modules should give us pretty great performance as is.