The dream of running native code in the browser is not something new. There were many failed attempts. They all taught us a lesson. Those learnings...
For further actions, you may consider blocking this person and/or reporting abuse
How long should it take to bundle? I've been waiting for a really long time... like four minutes, and it still says "wait until bundle finished:"
Okay, it took ~10 minutes, but once it got going, it was able to live-reload in a few seconds.
Here's the JS I used:
And the result (Safari 12.11):
Hold up, I'm going to update my rust and add the optimizations and see what sizes and times we get.
Okay, updated them and compiled with opt-level=3, and wee_alloc on. Compilation took a really long time, but I get that it's a prod feature, not a dev feature. Wasm file was 1.3Mb, though :/
I tried compiling with
sandzto see the file size difference, but it failed to compile when I tried that (it deleted thepkgdirectory and then didn't regenerate it)Anyway, good article, thanks for writing it up :)
What was the error message when you did
sandz? You should pass it as a String.All the above tests are run on rustc
1.37.0-nightly (929b48ec9 2019-06-21)WASM file size is around that value, this may change in the future. π€
Oh, that's probably what I did wrong, I just had
opt-level=s, notopt-level="s"The error wasn't interesting, it was about how it tried to import the index, but the file wasn't there. I'm 90% sure it originated in the browser and that the server was just echoing it for me to see. Other than that, it just said "build failed". Which is interesting, because when I set it to
opt-level=5, it told me that the only valid values were 1-3, and s and z, so it's a bit surprising that I didn't get that error again).It is installing wasm-pack and then wasm bindgen cli. If this the first time, then it might take sometime. Try installing manually and check if it fails. Check out wasm-pack docs for this. successive runs will be faster
So I have been tinkering with this mad project, and now I have learned that c++ is very verbose, do you find rust easier to write, manage and understand. I'm contemplating version 2 in rust with rlua.
Node.js tidal is my experiment to transparently integrate Lua and Lua rocks (TODO) into a simple node library via WASM. *optionally* Want to require Lua scripts from Node and have it give you a table? Want to use node features in Lua?
Tidal Node
Lua was concieved as an embeded language, designed to compliment other languages, Tidal Node is a library which brings Lua to node.js through WebAssembly and c++.
Tidal Node is WIP and not production ready - however I welcome the one or two people in the world that want to use this to get those PR's coming in. You will find most of the emscripten compiler commands in npm package.json "config". There is also a installer task for Lua built in, everything is subject to change.
Requirements
compiler:
emscripten 1.38.30^
runtime:
node 10.0.0^
build tools:
Commands
What is working
Highlights - "It's alive!"
Thats a great idea ππ Yeah Rust is very concise. When you start you have wrap your head around the ownership, lifetimes and others. But when you get the feeling for that, then it will be much more easier and simpler to write.
Thank you for your kind words. So there's no emscripten, sounds interesting! Okay well I'm gonna carry on getting this version done and rolled out before giving this a shot.