-
Notifications
You must be signed in to change notification settings - Fork 412
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
Building workspace fails #642
Comments
repro'd immediately. thanks for giving the example repo! it's very helpful. i believe this is failing because wasm-pack wants to create a package.json for your project and give it a name. it will look for that name in the what would you want wasm-pack to name your package in this situation? once we sort that i think we can work this out! are you at all interested in contributing? if not, no worries, but i always like to ask :) thanks again for the details and easily repro'd report. |
Hey! Thanks for looking into this! I think it should just, build 2 packages? Letting the $ tree .
.
├── Cargo.lock
├── Cargo.toml
├── LICENSE-APACHE
├── LICENSE-MIT
├── README.md
├── package.json
├── src
│ └── examples
│ ├── example-01
│ │ ├── Cargo.toml
│ │ ├── index.html
│ │ └── src
│ │ ├── entry.js
│ │ ├── lib.rs
│ │ └── utils.rs
│ ├── example-02
│ │ ├── Cargo.toml
│ │ ├── index.html
│ │ └── src
│ │ ├── entry.js
│ │ ├── lib.rs
│ │ └── utils.rs
│ └── index.html
└── yarn.lock … and then after $ tree .
.
├── Cargo.lock
├── Cargo.toml
├── LICENSE-APACHE
├── LICENSE-MIT
├── README.md
├── package.json
├── src
│ └── examples
│ ├── example-01
│ │ ├── Cargo.toml
│ │ ├── index.html
│ │ ├── pkg
│ │ │ ├── example_01.d.ts
│ │ │ ├── example_01.js
│ │ │ ├── example_01_bg.d.ts
│ │ │ ├── example_01_bg.wasm
│ │ │ └── package.json
│ │ └── src
│ │ ├── entry.js
│ │ ├── lib.rs
│ │ └── utils.rs
│ ├── example-02
│ │ ├── Cargo.toml
│ │ ├── index.html
│ │ ├── pkg
│ │ │ ├── example_02.d.ts
│ │ │ ├── example_02.js
│ │ │ ├── example_02_bg.d.ts
│ │ │ ├── example_02_bg.wasm
│ │ │ └── package.json
│ │ └── src
│ │ ├── entry.js
│ │ ├── lib.rs
│ │ └── utils.rs
│ └── index.html
├── target
│ # lots of Rust/Cargo stuff here
└── yarn.lock I think that makes sense, you could publish multiple packages or crates from the same repo … maybe there's a future where like Cargo workspaces and Lerna/npm/Yarn workspaces could be pretty synonymous and not so much like a David Lynch movie (in the sense that like, all the pieces are there but they don't quite fit together). I'm happy to help if I can. My background is in frontend/web/JS and I'm just starting to pick up/get the hang of Rust … I might need some pointers. |
The whole point of workspaces in Rust is the ability not to build every crate separately and share the intermediate results, so building crates separately with wasm-pack seems like a bad idea to me. I have a similar problem. I was using wasm-pack but I cannot anymore as I'm switching to workspaces :( Wasm-pack is so amazing that I would rather not leave it behind. Is this bug planned to be solved? :) If so, I would love to ask you to make it high-priority, as workspaces are crucial part of bigger rust projects. And as we all want Rust to become a great player in the WASM world, we need to support bigger projects, not only 1-crate examples! :) |
@wdanilo Internally, |
@Pauan Oh, thats interesting! You are right, I just tested it and it works! You saved my life, thank you ❤️ The only downside is that my compile instruction is a little bit strange, but this is a very minor issue: |
@wdanilo Indeed, and that's what this feature request is about: polishing the experience to make it nicer. |
Any update on this feature request? I've started my first toy wasm example, and I immediately want a workspace, because I want a primary crate for web frontend application logic, then multiple supporting crates, so for example @wdanilo does this match your use? Can you describe your workspace layout and which directory you run that |
@nathan-at-least wasm-pack works fine with workspaces, you just have to run it once for each crate. Or you can use an external plugin, such as rollup-plugin-rust (which allows you to build multiple crates). I've used this successfully in many of my own projects. |
Ok so it works if you cd into the crate, ie
It'd be lovely if it 'just works' with no config. |
Here is another (related) point: cd crates/my_crate && wasm-pack build
# or
wasm-pack build crates/my_crate It's not a big thing, and can be solved by copying the license file over in advance or manually after building. But it would be nice if there would be a way for wasm-pack to recognize the LICENSE in the workspace root (unless the license differs or there is a local LICENSE file of course).
|
🐛 Bug description
Running
wasm-pack build
in a workspace (e.g. the rootCargo.toml
has[workspace]
andmembers
) fails with:$ wasm-pack build Error: failed to parse manifest: ./Cargo.toml Caused by: missing field `package`
🤔 Expected Behavior
wasm-pack build
should build all the member crates into a common root-levelpkg
(or whatever) directory. This is the current behavior withcargo build --target wasm32-unknown-unknown
(only it builds intotarget/wasm32-unknown-unknown/debug
).👟 Steps to reproduce
I created a minimal repro repo here: https://github.com/mysterycommand/wasm-pack-workspace … clone the repo, cd into the root, run
wasm-pack build
, share my pain.🌍 Your environment
The text was updated successfully, but these errors were encountered: