Expand description
Rust/SWC port of babel-plugin-formatjs@10.5.41.
Build targets:
- WASI plugin (
--features plugin --no-default-features --target wasm32-wasip1) for @swc/core’s wasm plugin host. Entry point:process_transform. - Native rlib (
--features native, default) for embedders that link directly into a native @swc/core build. Entry point:formatjs.
§Hard-error policy
Per consumer requirement, this plugin MUST hard-error on any construct we can’t statically resolve, rather than silently skip extraction.
Babel’s plugin falls back on path.evaluate() for constant folding
(string concatenation, const references, ternaries with literal arms).
This Rust port does not implement scope-aware constant folding —
supporting it properly would mean re-implementing a chunk of @babel.
Until that lands, we fail loudly via [fail] so the build breaks
instead of silently producing divergent output in a 90 GB monorepo.
See CLAUDE.md for the parity bar.
Structs§
- Config
- Mirrors the option surface of
babel-plugin-formatjs@10.5.41’sOptionsthat upstream actually uses. - Format
JsTransform
Constants§
Functions§
- formatjs
- formatjs_
pass - Convenience wrapper that returns the transform as
impl Pass, ready to drop intoswc::Compiler::process_js_with_custom_passwithout the caller having to importswc_core::ecma::visit::visit_mut_passthemselves.