lingui / lingui/js-lingui

Rust extractor

Open
#2,436 28 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
5.9k
Forks
457
Avg merge
1d 23h
Merged PRs (30d)
16

Description

I’m pretty close to building a Rust version of the extractor using SWC.

The [recent changes](https://github.com/lingui/swc-plugin/pull/193) finally closed the gap between the Babel macro and SWC, so they’re now at feature parity. That was the hardest part, since most of the heavy lifting actually happens inside the macro itself.

When I say “extractor”, I don’t mean a full CLI rewrite. I’m talking only about the part that analyzes source files and extracts messages — the bit that’s currently done by Babel.

The idea is to ship the Rust extractor as a separate package at first, alongside the existing Babel one. After some real-world testing, it could become the default, while keeping the Babel extractor around for Vue and other JS-based setups.

To get there, we’d need to port `@lingui/babel-plugin-extract-messages` to Rust. The plugin is pretty small (~400 LOC), and I think an LLM could handle most of that work without much trouble.

After that, we can build a small Rust program on top of SWC, bake in all the required transforms, compile it into a single binary, and expose it to Node.js using [napi-rs](https://napi.rs/). In the end, this would just be a prebuilt binary with one job: extract messages.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the existing @lingui/babel-plugin-extract-messages package and the SWC plugin changes in PR #193. Compare the extractor behavior with the Babel macro, then investigate how a Rust program could package the required transforms and expose them through napi-rs. Done means a separate Rust extractor package or binary can extract the same messages while preserving the existing Babel extractor.

Written by the indexing model from the issue text.

Assessment

Tech stack
babel, javascript, rust
Domain
build-system, internationalization, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.