Repository navigation
Refactor browser demos and Emscripten build output - #2721
Conversation
This comprehensive modernization of the WABT web demos and Emscripten build output includes the following major improvements: * Separate WASM payload: Updated CMake and Makefile to output a separate `libwabt.wasm` file instead of inlining it in JS. This drastically reduces the `libwabt.js` size from ~1.24MB to ~26KB. * ES6 and async/await Modernization: Refactored `wabt.post.js` and demo scripts to use modern ES6 syntax (classes, const/let, arrow functions) and properly load the WebAssembly binary asynchronously. * Dynamic feature flags: Demos now dynamically generate feature checkboxes by inspecting `wabt.FEATURES`, rather than hardcoding them in HTML. * NPM Dependency Bundling: Migrated third-party demo dependencies (CodeMirror, Split.js) into a `package.json`-based build, generating a clean `third_party.bundle.js`. Consolidated shared demo logic into `share.js`. * Emscripten exports: Added missing features (`compact_imports`, `custom_page_sizes`, and `wide_arithmetic`) to `emscripten-exports.txt` to prevent instantiation errors.
sbc100
left a comment
There was a problem hiding this comment.
Thanks for splitting this out! Much appreciated.
LGTM.
With a couple of questions:
- I assume you tested this locally somehow to make sure it works?
- What cmake command was used to build the demo binary (i.e. debug vs release,etc)
|
Let me dig through your questions before you land this! |
Yep! Both apps. Make sure all of the boxes work and that I can edit code and it runs!
Just I think this is ready to land! |
|
|
||
| USE_NINJA ?= 1 | ||
| EMSCRIPTEN_DIR ?= $(dir $(shell which emcc)) | ||
| EMSCRIPTEN_DIR ?= $(shell em-config EMSCRIPTEN_ROOT 2>/dev/null || dirname $(shell which emcc)) |
There was a problem hiding this comment.
I agree this might be needed, but maybe in a different PR?
BTW, did you run into this issue yourself building against homebrew version of emscripten?
I wonder if we should instead switch to emcmake which is a command we takes care of the cmake/Modules/Platform/Emscripten.cmake thing for us.
|
Let me know when you are ready and I will land this, and we can test the live version. |
|
Done! Land it! |
|
gah! no! Let me fix! |
|
oh. nevermind. all good. 😮💨 |
This comprehensive modernization of the WABT web demos and Emscripten
build output includes the following major improvements:
libwabt.wasmfile instead of inlining it in JS. This drasticallyreduces the
libwabt.jssize from ~1.24MB to ~26KB.wabt.post.jsand demoscripts to use modern ES6 syntax (classes, const/let, arrow functions)
and properly load the WebAssembly binary asynchronously.
by inspecting
wabt.FEATURES, rather than hardcoding them in HTML.(CodeMirror, Split.js) into a
package.json-based build, generatinga clean
third_party.bundle.js. Consolidated shared demo logic intoshare.js.compact_imports,custom_page_sizes, andwide_arithmetic) toemscripten-exports.txtto prevent instantiation errors.