handlebars-rust icon indicating copy to clipboard operation
handlebars-rust copied to clipboard

Experiment: Making a JavaScript API for handlebars in WebAssembly (WIP)

Open sunng87 opened this issue 8 years ago • 5 comments

This is an experiment for making a JavaScript API for handlebars wasm. The result is expected as similar as original handlebarsjs library.

sunng87 avatar Jun 24 '17 09:06 sunng87

I'm using this setup https://medium.com/@ianjsikes/get-started-with-rust-webassembly-and-webpack-58d28e219635 to compile. As of 2017-06-24, Chromium 59.0.3071.109, Firefox 54 and emscripten 1.37.14, I'm getting this error when call my compile function:

Uncaught (in promise) RuntimeError: memory access out of bounds
    at _free (<WASM>[10741]+71)
    at ___rust_deallocate (<WASM>[10589]+11)
    at __ZN5alloc4heap10deallocate17hf3dde7510a423132E (<WASM>[1433]+82)
    at __ZN73__LT_alloc__raw_vec__RawVec_LT_T_GT__u20_as_u20_core__ops__drop__Drop_GT_4drop17ha752346b60305a9dE (<WASM>[1631]+210)
    at __ZN4core3ptr13drop_in_place17h9359bd02a9689a59E (<WASM>[1132]+38)
    at __ZN4core3ptr13drop_in_place17h1a7890a117fe321dE (<WASM>[1086]+140)
    at __ZN4core3ptr13drop_in_place17h01dc571daf330272E (<WASM>[1070]+38)
    at _compile (<WASM>[1817]+1296)
    at Module._compile (http://127.0.0.1:8080/build/bundle.js:19509:83)
    at eval (eval at cwrap (http://127.0.0.1:8080/build/bundle.js:13901:12), <anonymous>:13:28)

sunng87 avatar Jun 24 '17 09:06 sunng87

Any update on this?

dbousamra avatar Apr 01 '21 03:04 dbousamra

@dbousamra handlebars now compiles on webassembly. But a JavaScript API is not ready. If you are interested I can offer help for you to hack on it.

sunng87 avatar Apr 01 '21 06:04 sunng87

@sunng87 thanks for getting back to me.

I came across this project, because we are running into some performance issues with handlebars-js (used within a nodejs backend), and were considering using handlebars-rust, via a JS API, as a stop gap to buy us some more time.

dbousamra avatar Apr 01 '21 07:04 dbousamra

@dbousamra if you are on nodejs, perhaps handlebars-rust can be loaded as a native dependency, instead of webassembly module. Libraries like neon may help.

sunng87 avatar Apr 01 '21 14:04 sunng87