Skip to content
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(swc/common): allow to take inner from versioned (#5060: Part 2) #5071

Merged
merged 2 commits into from
Jun 30, 2022

Conversation

kwonoj
Copy link
Member

@kwonoj kwonoj commented Jun 29, 2022

Description:

I made this PR intentionally short for the verification of idea (which means I'm not certain about this change and I may wrong 😅)

PR implements take for the VersionedSerializable to move out value after deserializaiton is done from transform. Pseudocodewise, it'll be used like below:

let versioned_program = VersionedSerializable::new(program);
let mut serialized = Serialized::serialize(&versioned_program)?;

//... run plugin transform

// deserialize, return actual inner program
return Serialized::deserialize(&serialized)
                    .map(|mut v: VersionedSerializable<Program>| v.take())

Main thing I'm unsure is implementing Default for the Program to use mem::take in here. It maybe harmless, but I'm not easily able to say default impl for the program is exactly right. Maybe 1. either default should not be implemented 2. or implement better default ?

BREAKING CHANGE:

Related issue (if exists):
#5060

@kwonoj kwonoj changed the title feat(swc/common): allow to take inner from versioned @kwonoj (#5060: Part 2) feat(swc/common): allow to take inner from versioned (#5060: Part 2) Jun 29, 2022
Copy link
Member

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!


swc-bump:

  • swc_common
  • swc_ecma_ast

@kdy1 kdy1 enabled auto-merge (squash) June 30, 2022 01:21
@kdy1 kdy1 added this to the Planned milestone Jun 30, 2022
@kdy1 kdy1 merged commit e1aa937 into swc-project:main Jun 30, 2022
@kdy1 kdy1 modified the milestones: Planned, v1.2.208 Jul 1, 2022
@kwonoj kwonoj deleted the feat-wrap-plugin-versioned branch July 6, 2022 23:33
@swc-project swc-project locked as resolved and limited conversation to collaborators Oct 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants