[PoC] V2 API changes using cargo feature flag #5536
Closed
+127
−125
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
We can use multi-branch but I think it will really hurt rust-side users.
With multi-branch approach, we have to prevent some patches from being published to crates.io, but I think it's not acceptable for some rust-side users.
So I'm suggesting another approach. We can use a (potentially private) feature flag named
swc_v2
in js-surfacing crates likeswc
orswc_node_bundler
to 'hide' some changes to node api.This is clearly not additive, and that's why I think it should be a private feature.
As users are not expected to depend on
swc_v2
, enabling it from outside of SWC may break the whole dependency tree, but it's fine.For PoC, I fixed #5527 only for v2.
I want to hear more about opinions about this approach
Some constraints
rust users should not depends on
swc_v2
. This is not considered as a public api.All code should be accessible witthout
swc_v2
.But altering behavior is fine.
Let's say, we want to
fix
#5535 in v2 and change the order of plugins to afterresolver
but beforedecorator
ortypescript::strip
. In this case we can use#[cfg(feature = "swc_v2")]
and#[cfg(not(feature = "swc_v2")]
respectively.Related issue (if exists):