diff --git a/README.md b/README.md index 295c960..8e62e02 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ ruby -run -e httpd . -p 8080 ## Todo - [x] explain how to add code outside gems to the image -- [ ] show how to shrink/compress the ruby.wasm file (currently 51MB with debug info, but can be about 10mb or less.) +- [X] ~~show how to shrink/compress the ruby.wasm file (currently 51MB with debug info, but can be about 10mb or less.)~~ - [ ] license + explanation - [ ] ask upstream if they can make a javascript file that doesnt have the .wasm file path hardcoded. - [ ] docker file @@ -54,6 +54,7 @@ ruby -run -e httpd . -p 8080 - [ruby.wasmでrequire_relativeを使えるようにしたい #Ruby - Qiita](https://qiita.com/ledsun/items/3f8ba1ee2699d546c18c#fetch%E3%81%8C%E9%9D%9E%E5%90%8C%E6%9C%9F%E9%96%A2%E6%95%B0) - [RubyでWebAssemblyを試してみよう #ruby #WebAssembly #WASM #WASI - クリエーションライン株式会社](https://www.creationline.com/tech-blog/60328) - [how_to_use_bundler_and_rubygems_on_wasm.md](https://gist.github.com/kateinoigakukun/5caf3b83b2732b1653e91b0e75ce3390) +- [TODO: Shrinking .wasm Size](https://rustwasm.github.io/docs/book/reference/code-size.html) - see contributing.md in ruby.wasm repo ## GPT to convert JavaScript to Ruby code: diff --git a/browser.script.iife.js b/browser.script.iife.js index 7590378..1cca9e0 100644 --- a/browser.script.iife.js +++ b/browser.script.iife.js @@ -2100,8 +2100,7 @@ SOFTWARE. * an array of strings starting with the Ruby program name. */ initialize(args = ["ruby.wasm", "-EUTF-8", "-e_=0"]) { - console.log("tests"); - const c_args = args.map((arg) => arg + "\0"); + const c_args = args.map((arg) => arg + "\0"); this.guest.rubyInit(); this.guest.rubySysinit(c_args); this.guest.rubyOptions(c_args); diff --git a/build.sh b/build.sh index b02c092..4dae41f 100755 --- a/build.sh +++ b/build.sh @@ -4,4 +4,8 @@ cd ruby.wasm bundle exec rake compile rake install cd .. -bundle exec rbwasm --log-level debug build --ruby-version 3.3 --target wasm32-unknown-wasi --build-profile full -o ruby-app.wasm \ No newline at end of file +bundle exec rbwasm --log-level debug build --ruby-version 3.3 --target wasm32-unknown-wasi --build-profile full -o ruby-app.wasm +# Remove the debug info +wasm-opt --strip-debug ruby-app.wasm -o ruby-app.wasm +# Optimize for size without hurting speed as much. +wasm-opt ruby-app.wasm -Os -o ruby-app.wasm \ No newline at end of file diff --git a/ruby-app.wasm b/ruby-app.wasm index 94e0aeb..7f4aea7 100644 Binary files a/ruby-app.wasm and b/ruby-app.wasm differ