-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Relax same schema version requirement between wasm-bindgen-cli and wasm-bindgen #2544
Labels
Comments
This seems like a reasonable approach to me! I think it'd be fine to hash the |
chinedufn
added a commit
to chinedufn/wasm-bindgen
that referenced
this issue
May 4, 2021
chinedufn
added a commit
to chinedufn/wasm-bindgen
that referenced
this issue
May 4, 2021
chinedufn
added a commit
to chinedufn/wasm-bindgen
that referenced
this issue
May 4, 2021
chinedufn
added a commit
to chinedufn/wasm-bindgen
that referenced
this issue
May 4, 2021
chinedufn
added a commit
to chinedufn/wasm-bindgen
that referenced
this issue
May 4, 2021
chinedufn
added a commit
to chinedufn/wasm-bindgen
that referenced
this issue
May 4, 2021
chinedufn
added a commit
to chinedufn/wasm-bindgen
that referenced
this issue
May 4, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Background / Motivation
After getting lots of awesome mileage out of it, I'm looking to move away from wasm-pack (for reasons that I don't think are important for this issue).
The main problem that wasm-pack solves for me that would be difficult to make up for after moving away is the handling of version conformance between wasm-bindgen-cli (WB-CLI) and wasm-bindgen (WB).
As in, if WB in your Cargo.toml is 0.2.57 and your WB-CLI binary is 0.2.58, wasm-pack will download a different WB-CLI binary at 0.2.57 and use that instead. Nifty.
Current Status
The reason that you're forced to use the same version is because, historically, the schema has been unstable.
Forcing people to use the same version guaranteed that WB and WB-CLI would be using the same data format.
An alternative would be to simply maintain a schema version by hand, however this is prone to human error. Maintainers could forget to bump the schema version. So, I'm all for something human-error proof.
Potential Better Approach
Rather than use the Cargo.toml version as the schema version, it would be nice if the schema version was tied to the actual schema.
This could be accomplished with a build script.
Move all of the relevant schema stuff into one or a few files. Isolated in this way so that when they change we know it's a schema change.
Build script hashes these files and writes the hash to the OUT_DIR.
pub const SCHEMA_VERSION: &str = include_str!(concat!(env!("OUT_DIR"), "/schema-hash"));
End State
By moving towards using a hash of what can actually change instead of an unrelated version, there would be much less churn in the WB and WB-CLI compatibility story.
This would make it feasible to simply depend on WB-CLI directly, and just upgrade the binary when you need to.
For example, as of May 2021, the last time that the shared crate changed was November 2020. If the trend is that this will continue to change less and less frequently, I'm very fine with occasionally needing to upgrade my WB-CLI binary.
Questions
Rather than look for everything that would need to be hashed.. I'd rather just ask someone who already knows. Is it really just some of the stuff in shared's lib.rs, or is there much more to it?
If it's just that file or just a few files, this seems like a no brainer to me. However, I might be missing or overlooking something. Please let me know if I am?
Thanks!
The text was updated successfully, but these errors were encountered: