-
-
Notifications
You must be signed in to change notification settings - Fork 157
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
Feature Request: Backward compatibility (default value for fields / ignoring extra data) #373
Comments
Thanks for the context. There has been a lot of interest in this and there are a few ways to maintain backwards compatibility. Backwards compatibility can be maintained manually as demonstrated in the I'm also familiar with |
Thank you for the pointer! I think I can create a proc-macro that can be used to duplicate AST type without new fields. |
@djkoloski I thought about it more deeply, but I think it's going to be hard because I have to pay attention to the size of the binary. |
If you're only using nested structs and no enums, |
SWC uses lots of enums, so I think I can't use it.
|
Mind if I ask one q regarding how to deal copying / allocate SWC's host allocates memory in wasm plugin's memory space, then copy serialized struct into. When |
To make sure I understand correctly, you're serializing a type that includes a |
Yes.
I don't think I do special to copy part of it. Pseudocodewise, what I'm doing is basically
The exact same logic works without |
Hm, if you're copying all of the bytes into the target memory space then you should have the exact same values as before. Do you have a repro for this? I'd be happy to take a look and see if I can dig up any additional information. |
The current PR I'm working on is swc-project/swc#7382, and this https://github.com/swc-project/swc/pull/7382/files#diff-4d01e730818bcc35a17d65dd364390283fd29e3fb1dc0e35050a67034eeb474dR156 is the struct can repro if you enable The offending test case is here https://github.com/swc-project/swc/blob/a2577adffa846a9e9010be7f42378170cfec9338/crates/swc_plugin_runner/tests/fixture/swc_internal_plugin/src/lib.rs#L80-L82 which verifies plugin copied host's value - if enable |
I'm the author of the swc project.
I wonder if
rkyv
can support some sort of backward compatibility, as we pass the whole AST to the Wasm plugin after serializing it usingrkyv
.Most of AST changes are about new fields, and a default value is enough in most cases because the changes are mostly about TypeScript, which is stripped out before invoking Wasm plugins.
But we still have TypeScript data in AST, so the layout of archived value changes even if the value is always e.g.
false
.The text was updated successfully, but these errors were encountered: