SWC plugin
See original GitHub issueIs your feature request related to a problem? Please describe. I want to switch our projects from Babel to SWC, a Rust-based JS transpiler. SWC is used by Next.js unless you opt-out from it because you rely on Babel.
Describe proposed solution SWC has a brand new plugin system, which should be able to handle the transformations needed by Lingui’s macros.
This is not yet stable / well documented, but some plugins are available here: https://github.com/swc-project/plugins (for Styled Components for example).
Those plugins are compiled to WASM, so they can be written in several languages (including AssemblyScript, a Typescript derivative compiling to WASM)
A first step would probably be to continue using Babel for extracting and use this plugin only to transform macros, but in the long term being able to use SWC for extracting could bring a much faster extract
and heavily reduce dependencies needed for extraction (swc
+ swc-lingui
and thats pretty much all).
Describe alternatives you’ve considered
- Porting Babel macros to a SWC plugin: not sure this can easily be done, this has been discussed a bit in https://github.com/kentcdodds/babel-plugin-macros/issues/144 but this would probably be a new project. Also
babel-macros
is frozen as the author no longer uses it - Using another transpiling tool, like
esbuild
: there is no support foresbuild
+ Lingui either (andesbuild
does not have a plugin support) - Switching away from Lingui: I really like Lingui, I would prefer not 😃
- Keep using Babel:
swc
(and other modern compilers) are much faster, it would really be better to be able to switch away!
Additional context Add any other context or screenshots about the feature request here.
Issue Analytics
- State:
- Created a year ago
- Reactions:77
- Comments:22 (11 by maintainers)
Top GitHub Comments
Yes I’m already moving pieces together thanks to a similar project that implemented Macros on SWC, I’m already working on something suitable for Lingui… I’ll open-source it soon.
Latest updates. I’ve implemented jsx transformations with interpolations and imports replacement, so now this test passes:
It was the hardest part, so rest is should be much simpler.