woodser / monero-ts

TypeScript library for using Monero
http://woodser.github.io/monero-ts/typedocs
MIT License
212 stars 71 forks source link

Combine .wasm and .js files [3 XMR] #248

Closed woodser closed 1 month ago

woodser commented 2 months ago

This issue requests combining the .wasm and .js files, as requested in https://github.com/woodser/monero-ts/issues/83.

247 succeeds to combine the .wasm and .js files within dist and is tested to work in the browser.

However, monero_web_worker.js swells to 10.4 mbs, and monero_web_worker.js.map is 14.5 mbs. Ideally, the web worker can remain at or below 1.5 mbs and the source map at 5.5 mbs.

If the file sizes increase too much, it may not be worth it.

In addition, the project should be configured to use the combined .js files "as is", without manually copying them to the public folder for web apps.

github-actions[bot] commented 2 months ago

There is a bounty on this issue. The amount is in the title. The reward will be awarded to the first person or group of people who resolve this issue.

If you are starting to work on this bounty, please write a comment so that we can assign the issue to you. We expect contributors to provide a PR in a reasonable timeframe or, in case of an extensive work, updates on their progress. We will unassign the issue if we feel the assignee is not responsive or has abandoned the task.

Read the full conditions and details of the bounty system.

mainnet-pat commented 2 months ago

Comparing bytesize (see below) of dist compressed and uncompressed artifacts it is clear that compression brings a lot of benefit. Modern webservers do compress the static assets and moder browsers can handle the compressed assets. So the bandwidth consumption will be lower as compared to raw files.

Base64 bloats any binary by a max factor of ceil(n / 3) * 4. But it is itself compressible. Modern libs such as pako take 21kb in space. So maybe a custom solution of compressing b64 wasm data and inflating it before instantiating the worker could be meaningful.

 355534 dist/monero_wallet_full.js
  41542 dist/monero_wallet_full.js.zip
5308255 dist/monero_wallet_full.wasm
1493022 dist/monero_wallet_full.wasm.zip
 113943 dist/monero_wallet_keys.js
  29371 dist/monero_wallet_keys.js.zip
1166793 dist/monero_wallet_keys.wasm
 454443 dist/monero_wallet_keys.wasm.zip
2266447 dist/monero_web_worker.js
   7264 dist/monero_web_worker.js.LICENSE.txt
   2266 dist/monero_web_worker.js.LICENSE.txt.zip
7431614 dist/monero_web_worker.js.map
1762857 dist/monero_web_worker.js.map.zip
 589528 dist/monero_web_worker.js.zip
mainnet-pat commented 2 months ago

Zipped single_file=1 artifacts:

7.4M    dist/monero_wallet_full.js
2.0M    dist/monero_wallet_full.js.zip
1.6M    dist/monero_wallet_keys.js
604K    dist/monero_wallet_keys.js.zip
9.9M    dist/monero_web_worker.js
2.9M    dist/monero_web_worker.js.zip
 14M    dist/monero_web_worker.js.map
3.8M    dist/monero_web_worker.js.map.zip
woodser commented 1 month ago

Resolved with https://github.com/woodser/monero-ts/pull/250, which was incorporated in v0.11.0.