Community Work on an SWC Plugin #938
Replies: 19 comments
-
|
There's no plan for SWC plugin from Meta |
Beta Was this translation helpful? Give feedback.
-
|
Well, that's a bummer. I'm sure lots of people agree. I don't know the first thing it takes to integrate with SWC but anyone out there who does would be greatly appreciated if they undertook it. |
Beta Was this translation helpful? Give feedback.
-
|
Will the Next.js or SWC team plan to work on this, or will they leave it to the community to implement? |
Beta Was this translation helpful? Give feedback.
-
|
Going to close this as "answered" and for the SWC community to support. Thanks |
Beta Was this translation helpful? Give feedback.
-
|
Just wanted to mention that it's not allowed to use |
Beta Was this translation helpful? Give feedback.
-
|
@denexapp We're aware. But we don't use SWC at Meta so we can't justify migrating to it. And maintaining two codebases is out of the question. As StyleX grows in popularity, NextJS will eventually find a way to make it work. |
Beta Was this translation helpful? Give feedback.
-
|
I'm not so familiar with webpack compiler api, so my plugin had better to be improved, but I wrote plugin for next swc compiler work around modifying original next plugin. It can transpile by both swc and babel. Original plugin has problem that passes babelOption including function, causes glitch in next swc compiler. When avoiding this and set babelrc option false, swc compiler works without babel config files. |
Beta Was this translation helpful? Give feedback.
-
|
@tkow Will take a look at your work. We're looking to improve the integration with Next without needing a full blown SWC plugin. Since Next added support for Babel plugins alongside SWC to enable React Compiler, it should be more possible going forward. |
Beta Was this translation helpful? Give feedback.
-
|
@nmn
My team's really moved by stylex's awesome design system and wanted to use it our product soon, so published it our own way but I would like you to improve your original plugin about the points I described if possible. |
Beta Was this translation helpful? Give feedback.
-
|
@tkow We are looking at biggest improvements for next.js right now. Will have a better solution soon. |
Beta Was this translation helpful? Give feedback.
-
|
I have been working on This plugin is ready for usage, as it passes almost 100% of original babel plugin tests. This might be especially useful for Next.js projects as it allows to use Vercel’s SWC-based Next.js Compiler (which is disabled if a Babel config is present in the project). I have a question about naming the package. I am not sure if the current name can confuse people into thinking this is an official plugin (and how ok are you with it)? In documentation, I have tried to make it as clear as possible that this is an unofficial plugin, but would love your feedback on this. I haven’t followed the discussions as much lately and not sure if there is a place / platform which gathers unofficial StyleX-related plugins and extensions. If there is such a place, I would love to reach out to the maintainers and ask them to add this plugin there. And, of course, thank you for your work! StyleX is a great library. P.S. |
Beta Was this translation helpful? Give feedback.
-
|
@Dwlad90 This plugin was brought to my attention already! I have been very busy for a while, but I plan to dig into your implementation soon. For now it makes the most sense for us to support the independent development of the SWC plugin. Eventually, I would love to share more code or even make it a part of the official implementation. The name is OK with us as all official StyleX packages are under the Thank you!! |
Beta Was this translation helpful? Give feedback.
-
Thank you, For now, Is this possible to add this plugin to the Ecosystem page on the documentation website? If so I can open a PR with this. |
Beta Was this translation helpful? Give feedback.
-
|
The SWC plugin does have limitations: it lacks first-party metadata output (requiring comment and regex extraction) and it's bound to SWC (necessitating the use of I propose an alternative approach. Instead of building an SWC plugin, we could leverage SWC's existing infrastructure (parser, transformer, etc.) to create a dedicated Rust-based Stylex transformer using napi-rs. It would work as follows: import { transform } from 'stylex-compiler-rs';
const { stylexRules, code, map } = transform(input, options);This method offers better integration with webpack/vite/rollup and doesn't suffer from the metadata limitations. I've discussed this with one of the SWC team members, @Austaras, who has expressed interest in assisting when he has available time. What are your thoughts on this? |
Beta Was this translation helpful? Give feedback.
-
Hi @SukkaW, thanks for the great recommendation, i hadn't heard of napi-rs before. This is an interesting approach and I would be interested to get to learn this technology and participate in the implementation of the StyleX napi transformer |
Beta Was this translation helpful? Give feedback.
-
|
swc creator here. I can also help if you want to go in that direction. |
Beta Was this translation helpful? Give feedback.
-
Link to RFC with |
Beta Was this translation helpful? Give feedback.
-
|
This is all very exciting! I'll be trying to contribute more in the coming months to this effort. Also, reopening this issue and updating the description for ongoing conversations about this work. |
Beta Was this translation helpful? Give feedback.
-
|
Moving this to a discussion |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
It would be nice to have a SWC plugin.
Is there a plan to integrate StyleX with Rust-based SWC as an alternative to Babel? Or, is there any team or individual currently working on this?
Beta Was this translation helpful? Give feedback.
All reactions