-
Notifications
You must be signed in to change notification settings - Fork 61
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
feat: support semver aware exclusions #459
feat: support semver aware exclusions #459
Conversation
4d08207
to
97aba74
Compare
@vados-cosmonic incredible; thank you for working on this!
There should already be a working upstream implementation pulled in. I checked with wasmtime to make sure that a working |
Hey @yoshuawuyts thanks for chiming in, so it turns out I was using the git dep for
|
Oh, rightt - yeah that's the "semver-aware exports" feature wasmtime was missing and only recently implemented (to my surprise that went faster than expected!). My assumption was (and this might be wrong) that both I'm not sure what the exact right path here will be. What I do know is that Wasmtime 0.23 will be released in two weeks - which is about a week before we're set to release WASI 0.2.1. So one option might be to have a patch ready which we can merge the moment a new wasmtime version is released, making it part of the jco release a few days later. That does cut it a little close for my taste, so ideally we could land + test the patch well before then. I don't know what our options beyond that would be? - Floating patches? Pulling a non-release version of wasmtime? Ask wasmtime to pretty please push a patch version of |
Ahhh thanks for laying this out -- this helped me understand a lot more of the high level plan -- happy to hear how best to move forward here. IIRC @ricochet is also capable of helping with the upstream release if necessary here. Right now with the code in this branch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting the tests right seems like the most important first step here - checking the inclusion and exclusion respectively for both imports and exports across the gates. Left some suggestions as to how we might better structure that, and then we just need to ensure we have the correct test coverage.
Note the TS bindgen will also need to be implemented along with this in the ts-bindgen.rs
file.
a9eebcc
to
38c1a50
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The feature gating needs to be moved into the bindgen functions for:
exports
in https://github.com/bytecodealliance/jco/blob/main/crates/js-component-bindgen/src/transpile_bindgen.rs#L1740imports
in https://github.com/bytecodealliance/jco/blob/main/crates/js-component-bindgen/src/transpile_bindgen.rs#L1057
For the TypeScript generation, it looks like you've got per-interface filtering of functions and also the filtering of exports and imports. While all interfaces may still be written, that seems like it should be roughly correct? Would be good to clearly enumerate what cases are missing.
8287f6f
to
390d934
Compare
So after some discussion on Zulip it looks like the use case of trying to use [EDIT] - NOTE: one more upstream change is needed here -- in addition to [EDIT2] - Upstream PR |
888ad93
to
c163919
Compare
So the upstream PR is still ongoing, but the tests here now reflect at least some of the intended flow. Since it looks like feature gated items with a version newer than the package itself won't be allowed in the future, we actually don't have to test Since |
c163919
to
162db63
Compare
162db63
to
f42c295
Compare
Ah looks like there are some other errors due to the updated code -- will look into these. A bit odd because the primary issue seems to be saying that I missed the
But it looks covered in most of the macros... [EDIT] - Looks like many issues are with multiple returns being flagged now, the missing case, and some other stuff. |
7758cbe
to
7357c1c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great. Can we just add two extra tests here:
- Replacing
package test:feature-gates@0.2.1
in the package withpackage test:feature-gates@0.2.0
, and verifying thatb
andc
are not output, even withfeatures: ['gated']
set (which I think requires the change I've commented on in the code). - Running with an explicit feature enabling
features: ['fancier-foo']
and verifying it turns ond
(currently justfeatures: ['all']
is tested)
It seems to me like these should be relatively straightforward to add, but would be good to verify!
Thanks for review @guybedford ! I did #2, but if I'm right about #459 (comment) I don't think I can actually do #1 (or at least it would be a different kind of test) |
Also strictly speaking, according to the interpretation provided for since gates, we surely don't need any semver matching at all if all since gates will always be of versions less than the version we are checking? That is, if for a package version |
Okay this is making sense now, and I've resolved the outstanding questions. So the only capability provided by this PR is the ability to disable features in the bindgen. Last question then - if a component was generated assuming that a feature is enabled, is it actually valid to bindgen with that same feature disabled? That is, shouldn't the features that the component was built with be something we extract from the component itself as opposed to being an input to just the bindgen? |
Sorry super late but forgot to properly respond to this:
This is... definitely true. The And then
Yeah, basically support ensuring things marked
Hmnnn that's an interesting question -- I'm defaulting to the user needing to supply the feature(s) on every related tool, but that's obviously not a great answer. Would you mind laying out a scenario? This is probably also worth discussing (kind of like the packaging implications too...) |
Say a component was built with an imported feature enabled, then that package will be written and authored assuming it can access that feature function or interface import. To just not then bindgen that import, would result in a Wasm core error that the import is not defined by the bindgen. This makes me think, perhaps the right interpretation here is that imports should always be based on whatever the component itself uses? Rather than having to explicitly select features through an option? Because it feels like it will be a bad UX for imports if you have to guess what the component author intended, rather than just going with that to start. Then maybe the feature filtering per this PR is only an exports filtering? |
Of course for |
Ah yes, you're right -- if we can't control/don't know what the original package was built under, we have to be as permissive with the imports as possible...
Yeah this would definitely be the simplest way to deal with it for now. I'll expand the tests to use an import to make sure it's not hidden.
Ah good point -- will try to make sure this works properly as well. I might add a new test or two in |
@guybedford so I think this might not be a worry - I am almost done adding a bunch of a bunch of functionality to gate whether we enforce stability on imports or not, and realized that it just might not make sense:
After digging through the code I found this in WIT.md:
So I guess this kind of solves the problem? So actually, we cannot know when we've received a WIT with feature gates if we're using a component-derived WIT. In the case where we have the actual WIT path (i.e. the raw WIT), that's the case we do want to actually do the filtering (i.e. |
3d4c926
to
8b53c80
Compare
@vados-cosmonic agreed, it seems like if any of these gates ever fail it's effectively an invalid component. And that this validation might belong further up the stack. There might be a use case for when a dummy component is generated to provide features for that dummy component. Although perhaps that is something that belongs in wasm-tools again. Overall I'm also tending towards saying this should just be a features integration for |
8b53c80
to
2ebf5e0
Compare
Signed-off-by: Victor Adossi <vadossi@cosmonic.com>
2ebf5e0
to
65a8f7c
Compare
Definitely all for making this a Thanks again for the patience and the reviews! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we also add the --features
flag option to the jco types
command, should be relatively straightforward I think?
Then otherwise just a couple of last questions on the error reporting.
Signed-off-by: Victor Adossi <vadossi@cosmonic.com>
This commit adds two things to improve debuggability - item_name is now passed into stability checking for printing - ts_bindgen now returns a Result<()> Signed-off-by: Victor Adossi <vadossi@cosmonic.com>
110aa35
to
803dae6
Compare
Signed-off-by: Victor Adossi <vadossi@cosmonic.com>
803dae6
to
d0fa404
Compare
Hey @guybedford thanks again for the careful review -- I made the changes and added some tests around Finally got all the tests passing 😅 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, thank you for carrying this one over the line!
This PR updates
jco
to support the@since
,@after
and@unstable
annotations as implemented by the upstream Rust tooling.Currently there are a few issues left to address:
We likely need an upstream release & alignment of the new code inwit-parser
that supports the annotations:bytecodealliance/wasm-tools@01bec9cbytecodealliance/wasm-tools@10d2e21