Skip to content

Rust extractor #2436

@timofei-iatsenko

Description

@timofei-iatsenko

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

The recent changes 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. In the end, this would just be a prebuilt binary with one job: extract messages.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions