-
Notifications
You must be signed in to change notification settings - Fork 438
Coordinating with wasm-bingden about versions and list of NPM dependencies #101
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
Comments
Shouldn't that be the responsibility of |
@Pauan indeed! Although |
@alexcrichton Please correct me if I'm wrong, but my understanding is that the plan is that Rust crates will include a So the version information would be in the crate's |
Oh I was thinking that intermediate Rust crates would not ship Currently wasm-bindgen knows very little about Rust crates and dependencies, it purely takes one wasm file as input. It could be the case that I'm also not certain we'd want to ship |
Hmmm... npm dependencies are rather tricky: you have And a And there's a bunch of other So I feel like having a But I suppose an attribute is an okayish substitute. I am very concerned about version conflicts, though: |
@Pauan the goal was for wasm-pack to have a version parser and solver :) @alexcrichton need to read the backscroll a little more closely but i think in general i agree with ur approach |
ok so, addressing a few of @Pauan's concerns
a
this is vaguely true but none of it is enforced by the npm client. this info could be kept anywhere (most people use a i'm quite strongly against requiring a |
@ashleygwilliams do you think that wasm-bindgen should do something like print out by default "please add these dependencies to your |
Also it's possible for wasm-bindgen to do the version resolution here maybe? It could print out itself that there are conflicting versions or otherwise union the version requirements together. That feels more wasm-pack-like though |
yeah i think leaving resolution of deps to wasm-pack makes the most sense here, tho if we really wanted we could do it in a crate that both tools could leverage if we wanted to |
This commit adds a `#[wasm_bindgen(version = "...")]` attribute support. This information is eventually written into a `__wasm_pack_unstable` section. Currently this is a strawman for the proposal in ashleygwilliams/wasm-pack#101
I've opened a PR for this at wasm-bindgen at rustwasm/wasm-bindgen#161 |
This commit adds a `#[wasm_bindgen(version = "...")]` attribute support. This information is eventually written into a `__wasm_pack_unstable` section. Currently this is a strawman for the proposal in ashleygwilliams/wasm-pack#101
This commit adds a `#[wasm_bindgen(version = "...")]` attribute support. This information is eventually written into a `__wasm_pack_unstable` section. Currently this is a strawman for the proposal in ashleygwilliams/wasm-pack#101
This commit adds a `#[wasm_bindgen(version = "...")]` attribute support. This information is eventually written into a `__wasm_pack_unstable` section. Currently this is a strawman for the proposal in ashleygwilliams/wasm-pack#101
Okay, that sounds fine. Though I wonder if wasm-pack actually needs a version solver. Given these Rust crates... #[wasm_bindgen(module = "moment", version = "^2.0.0")] #[wasm_bindgen(module = "moment", version = "^2.4.0")] ...couldn't wasm-pack combine all the versions together, like this: {
"dependencies": {
"moment": "^2.0.0 ^2.4.0"
}
} That would leave the version solving up to npm/yarn/whatever. The biggest downside I can see is that it would result in inferior error messages in the case of conflicts. But it might be good as a temporary solution.
Indeed, that's what I meant.
I don't have a strong preference either way (between |
One of the downsides of the attribute is that it makes it very unclear what dependencies the package has. For Rust crates you can simply look at There is another possibility: specify the npm dependencies in |
@Pauan i'm confused...
is not a valid |
@ashleygwilliams What do you mean? npm's semver allows a space between versions, which it treats as logical and (i.e. set intersection). |
huh @Pauan i guess that is technically true! tho it's a dangerous move because i don't actually know what npm does if the intersection represents a set with no members... i think fundamentally this is something we'd probably want to sort at the wasm-pack level, mostly because i don't want to allow the publish of a package that is not installable [edit, i was curious so i checked] npm does this:
which is not super useful. in all my years working at npm i have to be honest i never saw ANY package.json declare deps like that, so for that reason alone and my desire to not surprise people, i would opt to not do that |
This commit adds a `#[wasm_bindgen(version = "...")]` attribute support. This information is eventually written into a `__wasm_pack_unstable` section. Currently this is a strawman for the proposal in ashleygwilliams/wasm-pack#101
This commit adds a `#[wasm_bindgen(version = "...")]` attribute support. This information is eventually written into a `__wasm_pack_unstable` section. Currently this is a strawman for the proposal in ashleygwilliams/wasm-pack#101
This commit updates `wasm-pack` to read the `__wasm_pack_unstable` section of wasm binaries that it exeutes over. This section is then parsed and NPM dependencies are extracted, if any, and inserted into the generated `package.json`. Closes rustwasm#101
This commit updates `wasm-pack` to read the `__wasm_pack_unstable` section of wasm binaries that it exeutes over. This section is then parsed and NPM dependencies are extracted, if any, and inserted into the generated `package.json`. Closes rustwasm#101
Fair enough. What about my idea of specifying the version information in |
This commit updates `wasm-pack` to read the `__wasm_pack_unstable` section of wasm binaries that it exeutes over. This section is then parsed and NPM dependencies are extracted, if any, and inserted into the generated `package.json`. Closes rustwasm#101
@alexcrichton I too agree to most part of the initial idea.
I think this from @Pauan makes sense too. Why cannot we port this to be in from WDYT? |
Pedagogically I don't have too much of an opinion either way on where this info lives. Technically I'd prefer the attribute because it means I don't have to pull a TOML parser into wasm-bindgen. |
Ergonomically 😜 |
@alexcrichton let's stick with what we have for now... if it turns out that people want something else, we can build it later, based on people's actual experience, and not just guessing ;) |
I strongly disagree with this. A lot of people are already using wasm-bindgen and wasm-pack, and so it will quickly become a de-facto standard, which will be very hard to change later. If we're going to experiment with different things, we should do so now. As I said, there are benefits to using |
Modifying a config file for a different tool other than what that file is for does not sit well with me. Cargo.toml is used to modify how cargo works, not wasm-pack/wasm-bindgen. If you want to do build config things I highly recommend it either be in it's own config file or build.rs as is current convention for Rust projects. |
That is incorrect:
Using a separate config file does work, though that idea was rejected.
|
this issue has become quite contentious! and i really appreciate everyone's efforts here. because this seems like a more complex issue, @alexcrichton and i are going to work on an RFC tomorrow and hopefully post it on friday on the rust-wasm repo. the goal will be that the RFC dives deeply into the tradeoffs of this decision and gives us more structure to have this very important convo! feel free to keep chatting here and we can implement some of the thoughts that have already been shared, but this will likely be closed when we post the RFC :) thanks again ya'll! |
@Pauan Oh I didn't even know about the metadata field! Thanks for letting me know about that :D I think at this point we'll just need to wait for the RFC and we can continue discussion there :) |
That sounds great! As a general principle, I think we should have RFCs for these sorts of issues that have long-term consequences for the entire community and ecosystem. In addition to discussing the system for specifying dependencies, maybe the RFC should also discuss about whether the versions should be semver-by-default or not? |
closing because stale and waiting on an rfc process. |
This is related to https://github.com/rust-lang-nursery/rust-wasm/issues/34 and https://github.com/rust-lang-nursery/rust-wasm/issues/36, but I'd like to propose a strawman idea here.
Right now wasm-bindgen has the ability to say where you're importing functionality from:
If
module = "..."
is omitted it's assumed to come from the ambient environment (aka the browser). Otherwisefoo
is interpreted as an ES module directive and that's where items are imported from in the generated JS that wasm-bindgen emits.The wasm-bindgen output is pretty "dumb" right now in that it's just bland ES module information, it doesn't currently attempt to give extra information like verison requirements for NPM packages. But that's where wasm-pack comes in! Ideally wasm-bindgen would emit information that wasm-pack later reads, parses, and emits a package.json for.
So I'd propose something like:
version = "..."
next tomodule = "..."
in wasm-bindgenmodule = "..."
directives that don't start with.
, require thatversion
is listedwasm-bindgen
emits in the format:__wasm_pack_unstable
{ "module": "string", "version": "string" }
wasm-pack
executes it slurps up the__wasm_pack_unstable
section, if present, and emits these packages into thepackage.json
that's generated.An example of using this would look like:
And
wasm-pack
would automatically generate apackage.json
with:I'm definitely up for changing anything here, this is just an initial strawman! I'd love to hear others' thoughts on this as well.
The text was updated successfully, but these errors were encountered: