Giter Site home page Giter Site logo

dao's Introduction

cargo-刀

  1. if [] == ![] { console.log("javascript sucks") }
  2. The only replacement for JavaScript is WASM
  3. Rust compiles to WASM
  4. Rust is great
  5. Replace Javascript with Rust

What is this?

Currently, the only way to have multiple library outputs from Rust is to use multiple crates. This has a few downsides, especially when you want multiple WASM files.

  1. You need multiple Cargo.toml files, and need to specify dependencies for each one
  2. If you have shared dependencies, you need to specify a separate crate for that as well

cargo-dao is a wrapper for wasm-pack (an excellent tool by the way) that allows you to compile multiple wasm binaries with only one crate. All you need is to add #[cfg(dao = "output_name")] to each part of the code you need for each output binary (quite like features). cargo-dao will automagically detect all instences of #[cfg], and compile a separate binary for each one.

Example

In the wasm-pack-example directory, run cargo dao --target web --out-dir web/pkg, and start a web server in web/. Check the console output on your browser!

dao's People

Contributors

ethanyidong avatar

Watchers

 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.