FormatJS SWC plugin, maintained by SWC team.
The default message descriptors for the app's default language will be processed from: defineMessages(), defineMessage(), intl.formatMessage and <FormattedMessage>; all of which are named exports of the React Intl package.
import { NextConfig } from 'next';
const nextConfig: NextConfig = {
experimental: {
swcPlugins: [
[
require.resolve('@swc/plugin-formatjs'),
{
idInterpolationPattern: '[md5:contenthash:hex:10]',
additionalComponentNames: ['F'],
ast: true,
},
],
],
}
}import react from '@vitejs/plugin-react-swc'
import { defineConfig } from 'vite'
export default defineConfig((env) => ({
plugins: [
react({
tsDecorators: true,
plugins: [
[
'@swc/plugin-formatjs',
{
idInterpolationPattern: '[md5:contenthash:hex:10]',
additionalComponentNames: ['F'],
ast: true,
},
],
],
}),
]
}))A template string that allows you to override the ID both in the extracted javascript and messages. It's used only if the message ID is empty.
Remove defaultMessage field in generated js after extraction.
Whether the metadata about the location of the message in the source file should be extracted. If true, then file, start, and end fields will exist for each extracted message descriptors. Defaults to false.
Additional component names to extract messages from, e.g: ['FormattedFooBarMessage']. NOTE: By default we check for the fact that FormattedMessage are imported from moduleSourceName to make sure variable alias works. This option does not do that so it's less safe.
Additional function names to extract messages from, e.g: ['']. Use this if you prefer to alias formatMessage to something shorter like ``.
Pre-parse defaultMessage into AST for faster runtime perf. This flag doesn't do anything when removeDefaultMessage is true.
Whether to preserve whitespace and newlines.
A string that allows you to extract metadata from comments in your source files. When set, the plugin will look for comments containing the pragma string and parse key:value pairs that follow it.
For example, with pragma: "@formatjs", a comment like:
// @formatjs project:web locale:en region:usWill extract the metadata: {project: "web", locale: "en", region: "us"} that gets included with the extracted messages. This is useful for adding contextual information to your message extractions.
- 1cbeb5a: build: Update swc_core to v58.0.1
- 2113ddb: build: Update swc_core to v57
- 870774a: build: Update swc_core to v56
- 15f32da: fix(formatjs): Variable evaluate concatenation
- 66f5258: build: Update swc_core to v55.x.x
- 9c163ec: Update swc_core to v53, really
- 3799fa4: Update swc_core to v53.0.0
- 0a1d66f: Update swc_core to v52.0.0
- a73246f: build: Update swc_core to v49.0.0
- 6c46f86: feat: Enable backward-compatibility feature
- ad79e09: Update swc_core to v48.0.4
- 7a0fbdb: Update swc_core to v48
- 593f438: Update swc_core to v47
- 25e0c2c: Update swc_core to v46.0.0
- c324a59: Update swc_core to v45
- 8bad98d: Update swc_core to v44
- 47be132: Update swc_core to v42
- 0c9d7a1: build: Update swc_core to v39.0.0
- a872100: build: Update swc_core to v38
- 9b08ff7: Update swc_core to v35
- 08db5e1: docs(formatjs): add Usage to readme
- beabfa1: Add proper README
- 27cae40: Disallow typescript types to shrink size
- df280ad: Update swc_core to v34.0.0
- 562e755: Update swc_core to v33
- 9a27285: fix(formatjs): Fix description extract for the template literal string
- 85719ca: Update swc_core to v32
- 467573b: fix(formatjs): Fix ast transform in jsx
- 45d1ac7: Update swc_core to v31
- 899d803: Add support for md5 hash_type in idInterpolationPattern
- f7c8ad4: swc_core v29
- 8d5ce5c: Update swc_core to v28.0.0
- cf2636b: Update swc_core to v27
- e3e743d: Update swc_core to v27
- f226c4b: Generate the same ID after React Compiler
- 5ddbaeb: Update swc_core to v23
- 1abaa28: fix(formatjs): Sort description objects before serialization
- 648faf7: add support for hex and base64url digest encodings in idInterpolationPattern placeholders
- d51d525: Update swc_core to v22.0.0
- cb94b92: Update swc_core to v21.0.1
- af2e35d: Add support for sha1 hash_type in idInterpolationPattern
- 31e3254: build: Update
swc_coretov19.0.0
- f0fee1d: Update swc_core to v15.0.1
- 72385e1: add support for idInterpolationPattern placeholders
- 04465bc: Update swc_core to v14.0.0, really
- bfa0a51: Update swc_core to v13
- b8c4e6c: Update swc_core to v12
- 4c8b0e2: Update swc_core
- e8973e8: Update swc_core to v10.2.3
- f436a09: Update swc_core to v10.
- 2ae5319: Fix parsing of unicode
- bb13cc8: Fix missing quotes of plural keys
- f155bce: Update swc_core to v9
- c9e75ce: Bump crate versions
- 4574a70: Update swc_core to v8.0.1
- f3cea5f: Bump versions
- a73664c: Update swc_core to v6.0.2
- 4ff3b22: Move formatjs plugin to official plugin repository