opendal: Tracking issues of OpenDAL wasm32-unknown-unknown target support
WebAssembly (WASM) is a modern binary instruction format for a stack-based virtual machine. It is designed as a portable compilation target for high-level languages like C/C++ and Rust, enabling deployment on the web for client and server applications. WASM aims to enable near-native performance for web applications, providing a more efficient and secure alternative to traditional JavaScript. Its key features include fast loading times, efficient execution, and the ability to run alongside JavaScript, allowing developers to build complex client-side web applications that perform better than those written solely in JavaScript.
By adding WASM support for opendal, we will allow users to use opendal in targets like wasm32-unknown-unknown. In a short word, users can use opendal in web browser!
We have addressed most blockers by https://github.com/apache/incubator-opendal/pull/3796 and adding a basic test for s3 https://github.com/apache/incubator-opendal/pull/3802. It’s time for us to move forward.
This tracking issue is used to track our current progress of wasm support. Welcome to join in us!
Tasks
Add OPFS support
After opendal is ready for WASM, we can start to work for opfs now!
Add support for more services
Please run the following command to check if opendal can build under wasm32 arch:
cargo build --target wasm32-unknown-unknown --no-default-features --features=services-s3
Visit https://github.com/apache/incubator-opendal/pull/3796 for possible fix or ask directly in this issue.
It’s possible that some services can’t support wasm at all, like fs. Please also provide your feedback here. We will collect them into a seperate doc.
- alluxio
- atomicserver
- azblob in https://github.com/apache/incubator-opendal/pull/3806
- azdls
- azfile
- b2
-
cacache(can’t support) - cloudflare_kv
- cos
- d1
- dashmap
- dbfs
- dropbox
-
etcd(can’t support) -
foundationdb(can’t support) -
fs(can’t support) - ftp
- gcs: https://github.com/apache/incubator-opendal/pull/3816
- gdrive in https://github.com/apache/incubator-opendal/pull/3808
- ghac
- gridfs
-
hdfs(can’t support) - http
- huggingface
- ipfs
- ipmfs
- libsql
- memcached
- memory
- mini_moka
- moka
-
mongodb(can’t support) -
mysql(can’t support) - obs
- onedrive
- oss
-
persy(can’t support) -
postgresql(can’t support) -
redb(can’t support) -
redis(can’t support) -
rocksdb(can’t support) - s3 (supported in #3802)
- seafile
-
sftp(can’t support) -
sled(can’t support) -
sqlite(can’t support) - supabase
- swift
-
tikv(can’t support) - upyun
- vercel_artifacts
- webdav
- webhdfs
Testing
- Integrate behavior test for wasm target
Benchmark
- Add benchmarks for opendal wasm
Existing issues
-
wasm-pack test --nodedoesn’t work fors3_read_on_wasm - #3809
About this issue
- Original URL
- State: open
- Created 6 months ago
- Reactions: 4
- Comments: 19 (16 by maintainers)
For now, we can’t use it on both wasm runtimes, because both of the runtimes is based on wasm32-wasi I have reminded it in the previous comment.
The WASI runtime is not support for the wasm-bindgen which is dependent by reqwest now.
If we want to support the wasi runtime, we may need the other HTTP client which is compatible with the WASI spec
Thank you for pointing that out! I’ve tried to compile ring before but it kept failing. Finally, I realized that the llvm comes with macos doesn’t have a backend of wasm. I reinstalled llvm and it compiled successfully. Sorry for the confusion!
Thanks, let’s remove them. I just found that support
wasm32-unknown-unkownis totally different from supportwasm32-wasi. Lesson learnt.After a quick search, it seems that web-sys has a clear mapping to js web api. However I think the most dirty work comes to the data crossing boundaries: wasm (prepare the net calls) -> js (fetch hook) -> wasm (reading the result)
Let’s wait for the stable wasm releases first… LOL
Furthermore, my intention is to use opendal in my 320k downloaded project (
remotely-saveif you are interested). If you want to talk about the user case, you are welcome to DM me (username fyears) on discord .Hi @fyears, thank you for your interest! As @Young-Flash mentioned, our WebAssembly support is still in the early stages and not yet ready for practical use.
Not yet. WASM support is still in active development, and we need to address existing bugs such as https://github.com/apache/incubator-opendal/issues/3810 before proceeding.
We haven’t released it yet. (However, you can create a wasm library by running
cargo add opendaland building it.)We are using
web-sysnow, and I’m not sure ifweb-syssupport this use case.We will not support the
fsservice on wasm, which means there’s no need to provide hooks either. We have a plan to support opfs: https://github.com/apache/incubator-opendal/issues/2442. If users require IndexedDB, we can offer native support for it.Nice question. We want this as well, but I’m not sure how to implement it. We can re-visit this after we have build a usable opendal wasm lib.
Thanks for raising this up! I re-visit the gcs support on wasm, and confirmed that gcs is able to compile on
wasm32-unknown-unknown. I will start a PR to address this.For the record,
wasm-pack test --chrome --headlessandwasm-pack test --chromeis both working.But need some special S3 settings like