@formatjs/swc-plugin-experimental
v0.6.1
Published
SWC plugin for formatjs
Downloads
5,058
Readme
@formatjs/swc-plugin-experimental
@formatjs/swc-plugin-experimental
is a port of babel-plugin-formatjs
written
in Rust, for the SWC's experimental plugin system. Transform can currently
be performed via SWC's wasm-based plugin, and in the future also as a custom
pass in Rust-side transform chains.
What does compatible exactly means?
This plugin attempts to mimic most of defined behavior of original plugin's test fixture. However, due to differences of plugin interfaces, as well as known limitations there are numbers of unsupported features with differences. You may able to check the list of github issues, as well as checking test fixtures.
Notably, any dynamic configuration options (overrideFn
, onMsg
...) are not
supported, and few internal behaviors relying on static evaluation won't work.
NOTE: Package can have breaking changes without major semver bump
Given SWC's plugin interface itself is under experimental stage does not gaurantee semver-based major bump yet, this package also does not gaurantee semver compliant breaking changes yet. Please refer changelogs if you're encountering unexpected breaking behavior across versions.
Also, current implementation is largely unoptimized, and may have performance issues as initial focus was to pass existing test fixtures only.
Usage
Using SWC's wasm-based experimental plugin
First, install package via npm:
npm install --save-dev @formatjs/swc-plugin-experimental
Then add plugin into swc's configuration:
interface PluginOptions {
pragma: string
removeDefaultMessage: bool
idInterpolationPattern?: string
ast: bool
extractSorceLocation: bool
preserveWhitespace: bool
additionalFunctionNames: Array<string>
additionalComponentNames: Array<string>
}
jsc: {
// ...
experimental: {
plugins: [
[
'@formatjs/swc-plugin-experimental',
{
// PluginOptions
},
],
]
}
}