Davidobot / love.js

LÖVE ported to the web using Emscripten, updated to the latest Emscripten and LÖVE (v11.5)
MIT License
605 stars 27 forks source link

Single-file HTML Export #72

Open Davidobot opened 1 year ago

Davidobot commented 1 year ago

Twitter source:

the ability to create single file html loves to use on client browsers like schellingb did?

alexjgriffith commented 4 months ago

For future reference: you can use the EMSCRIPTEN_ARGS --pre-js and --post-js to wrap the wasm build, and setting MODULARIZE=0 should merge output files.

https://stackoverflow.com/questions/29329240/emscripten-with-module-loaders#29332498

SugarRayLua commented 3 months ago

@alexjgriffith, Would you be able to describe the steps one would take to use those EMSCRIPTEN_ARGS to wrap the wasm build produced from love.js (i.e. 1. Execute love.js per npm/github instructions 2. On the .wasm file produced do...)

Trying to go from reading what the stackflow responded recommended to how I'd actually apply that to the love.js output still seems above my novice js skills.

If it is actually too many steps/too involved to explain further on this forum, I understand. If you were able to provide more detail, I think others in the love community would be interested to try your suggestion.

Thanks :-)

alexjgriffith commented 3 months ago

These flags would be used in the build stage of lovejs itself. These are flags emscripten could use to wrap the output of its compilation.

Unfortunately they only solve one of the problems (the need for a seperate index.html and game.js). The other problem is compiling lovejs in a way that embeds the wasm in the output, rather than in its own file.

There are techical limitations on our build right now that limit us from doing that for the release target. Key functions we use were dropped in emscripten v 2.06 and even more were dropped 3.58 (the emscripten team does not do a great job announcing deprecation).

Once we get 3.59 working and stable there should be a way to build a single file html target.

SugarRayLua commented 3 months ago

Thank you very much @alexjgriffith. I'll be very much looking forward to that time :-).