Giter Site home page Giter Site logo

wasm-bindgen-with-worker's Introduction

wasm-bindgen-with-worker

Rustをフロントエンドで使用するための実験リポジトリ

やりたいこと

WebAssemblyでの高速な処理を下記の条件で行いたい。

  • JSON形式でやりとりできること
  • 非同期処理であること

使用技術

  • Rust
  • TypeScript
  • parcel-bundler

メモ

webpack or parcel

RustをWebWorkerから呼び出す場合、どちらのバンドラも少し工夫が必要である。 なお、parcelでは、parcel-plugin-wasm.rsプラグインを使用する

webpackでの課題点

  • エントリーポイントを2つ用意しなければならない(worker-loader + wasmのバグ)
  • 中間ファイル生成(Rust→wasm)が面倒で、ビルドタスクがごちゃごちゃになる

parcelでの課題点

  • Rust側からJavaScriptのコードが呼び出せない?(要検証) 呼び出せた。
    • ただし、相対パスはnode_modules/parcel-plugin-wasm.rs/が基準
    • Worker内での実行のため、DOM操作などはできない
  • Worker読み込み完了後〜wasm読み込み完了の間に処理が書けない
  • Tree Shaking(--experimental-scope-hoistingオプション)で実行時エラー

共通の課題点

  • ライブリロード
    • webpackでは、ワンテンポ遅いタイミングでページ全体のリロードがされる
      • 遅くてイライラ
    • parcelでは、一応差分更新を試みてくれる
      • Rust更新時は反映されない
      • JS更新時はworkerイベントが重複する

wasm-bindgen-with-worker's People

Contributors

imasanari avatar

Stargazers

Seven Chan avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.