Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a project template for writing wasm libraries intended for use by JS #56

Closed
fitzgen opened this issue Feb 14, 2018 · 7 comments
Closed
Labels

Comments

@fitzgen
Copy link
Member

fitzgen commented Feb 14, 2018

It should have

  • the state-of-the-art dependencies already in Cargo.toml
  • extern declarations for those crates already in src/lib.rs
  • #![no_std] declaration
  • panic_fmt handler that doesn't use fmting infrastructure, for small code sizes by default
  • some script or makefile or xargo type thing that does cargo build --release wasm32-unknown-unknown && wasm-gc ... && wasm-opt ...

Open questions:

  • Where should this template live? A new repository?
  • What dependencies should it come with?
    • wasm-bindgen? This seems like a good choice to me.
    • wee_alloc as the global allocator? This is much more opinionated, and is likely not the right choice in many situations, but in the library-for-use-by-JS scenario fairly likely to be a good choice.
    • Other things?
@fitzgen fitzgen added help wanted Extra attention is needed use-case:library-for-JS labels Feb 14, 2018
@mgattozzi
Copy link
Contributor

A while back I had started doing something called cargo-wasm and the idea was eventually use that for building stuff and wrapping the commands needed every time to do it/deal with all the weird manual stuff when setting things up. It might be possible to work out some stuff and create a small config, kind of like xargo does, and have it initialize a project based off it. I might have time to hack in a prototype

Ideally I really wish cargo just had inbuilt templates/automatically choosing a specified target but that's a road that's been fraught with contention for some time and I don't think an RFC has really been pushed through to do it that way.

@fitzgen
Copy link
Member Author

fitzgen commented Feb 15, 2018

Ideally I really wish cargo just had inbuilt templates/automatically choosing a specified target but that's a road that's been fraught with contention for some time and I don't think an RFC has really been pushed through to do it that way.

There was talk between WG domain leads about creating templates for each of our domains in our meeting yesterday, so I think the winds are changing and we can get this to happen.

@mgattozzi
Copy link
Contributor

I think I and many others would be happy. It's something stack does in Haskell that I really wish Rust already had. Either way this sounds good.

@ashleygwilliams
Copy link
Member

this sounds like a great idea! it's a bit blocked on the packaging tool which is blocked on how JS deps are expressed in wasm. to build the packaging tool i have an example template that i'm already working on - so i can help complete this as the packaging tool work moves forward :)

@fitzgen
Copy link
Member Author

fitzgen commented Feb 16, 2018

it's a bit blocked on the packaging tool which is blocked on how JS deps are expressed in wasm

I think we can pursue an incremental approach, where we start without packaging integration and then add it when it's ready.

so i can help complete this as the packaging tool work moves forward :)

Awesome!

@koute
Copy link

koute commented Feb 19, 2018

We might consider having a few different templates here, e.g. pure Rust one, wasm-bindgen-using one, cargo-web for Node.js, cargo-web for the Web through Parcel**, etc.

** - Although my main focus with stdweb and cargo-web is in supporting pure Rust webapps the use case of building JS-callable libraries is also on my agenda, e.g. I have a Parcel plugin with which you can just import a Cargo.toml into a JS frontend project (although due to code-bloat it isn't really that great), and out-of-box you can take the .js generated by cargo-web and require it from Node.js (where code bloat doesn't really matter)

@alexcrichton
Copy link
Contributor

I think this is covered by https://github.com/rustwasm/wasm-pack-template!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants