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

Add swcImplementation option #206

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

ArnaudBarre
Copy link
Member

Addressing: #190 (comment)

The other case it would be useful is when people have issues with breaking changes in the plugin API and want use another version of SWC. Ideally it should be done via package manager, but it very different from one case to another so I could have a generic message like:

Use your package manager overrides to install v1.X.X or add "@swc/core": "1.X.X" to your package.json and use

import swc from "@swc/core";
import react from "@vitejs/plugin-react-swc";

export default defineConfig({
  plugins: [react({ swcImplementation: swc })],
});

@ArnaudBarre ArnaudBarre self-assigned this May 20, 2024
Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

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

I'm not quite sure we need a new option for this. Like you mentioned, overrides should do the trick, but for the linked issue comment case, they could bundle the Vite plugin and specify their own SWC version? Is it common for SWC to break stuff too?

@ArnaudBarre
Copy link
Member Author

Yeah it broke multiple multiple times in last year, their rust plugin API is not as stable as their transformer.
Yeah technically re-bundling the plugin would work but I think they were looking for a simpler way to do it that allows theur shared configuration to be something easy to maintain

@bluwy
Copy link
Member

bluwy commented May 21, 2024

I'm still not sure if we need a new option since overrides should usually solve this, even if it breaks a lot. Exposing an implementation option feels odd to me. Maybe I'll see sapphi's thoughts on this then and if we're in favour of a new option, we could go with it.

@sapphi-red
Copy link
Member

If the SWC plugin (e.g. @swc/plugin-emotion) requires a specific version of SWC, the plugin should have a peerDep field that declares that. But they introduce breaking changes even in patch versions and that makes it difficult to do that. If they did breaking changes only in minors, the plugins can have peerDep field and that would show warnings when installed. Maybe worth asking the SWC team if they are open to that.

If not, I think we can have this option until the plugin API is stable. The pugin API seems to be an experimental feature and would be resolved when it becomes stable (swc-project/swc#5060). Bundling the plugin-react-swc plugin has a downside of locking version. I guess they want to lock the SWC and SWC plugins version since their versioning policy violates semver, but not to lock the plugin-react-swc plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants