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

fix: change process_js_with_custom_pass api #6236

Merged
merged 1 commit into from Oct 24, 2022

Conversation

JSerFeng
Copy link
Contributor

Fix

Options missing unresolved_mark field

Breaking Change

It's a breaking change I know but the usage of current implementation is hard to use, or maybe I did it wrong.
It's very easily to encounter lifetime limitation.

compiler.process_js_with_custom_pass(..., |_, comments| { build_pass(comments) });
-----------------------------------------------^^^^^^^ compile error

I believe this is a common pattern, build_pass should hold the comments' lifetime, but borrow checker would not allow this.

So I think maybe pass comments to it should be a better idea.

If anything wrong with my point of view, please tell me

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.

Comments are cheap to clone, so you should clone it instead

@JSerFeng
Copy link
Contributor Author

Yes, but
If I have cloned one called C_A, and the one used by process_js_with_custom_pass called C_B
I made some changes in C_A, but the actual used one is C_B, and codegen will use C_B instead of C_A right?

@kdy1
Copy link
Member

kdy1 commented Oct 23, 2022

Clone of Comments does not clone data

@JSerFeng
Copy link
Contributor Author

Clone of Comments does not clone data

Oh, thanks, I will revert my changes on that, but keep change on unresolved_mark

@JSerFeng JSerFeng force-pushed the refactor/process_js_with_custom_pas branch from b1ed5ba to 1687c1b Compare October 23, 2022 05:07
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.


swc-bump:

  • swc

@kdy1 kdy1 enabled auto-merge (squash) October 23, 2022 05:19
@kdy1 kdy1 added this to the Planned milestone Oct 23, 2022
@kdy1 kdy1 self-assigned this Oct 23, 2022
@JSerFeng JSerFeng force-pushed the refactor/process_js_with_custom_pas branch from 1687c1b to c24c7e0 Compare October 23, 2022 07:54
@kdy1 kdy1 merged commit 0b267ed into swc-project:main Oct 24, 2022
@kdy1 kdy1 modified the milestones: Planned, v1.3.11 Oct 26, 2022
@swc-project swc-project locked as resolved and limited conversation to collaborators Nov 25, 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.

None yet

2 participants