@swc/plugin-formatjs 3.1.1 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @swc/plugin-formatjs
2
2
 
3
+ ## 3.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 648faf7: add support for hex and base64url digest encodings in idInterpolationPattern placeholders
8
+
9
+ ## 3.1.2
10
+
11
+ ### Patch Changes
12
+
13
+ - d51d525: Update swc_core to v22.0.0
14
+
3
15
  ## 3.1.1
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -4,6 +4,18 @@ FormatJS SWC plugin, maintained by SWC team.
4
4
 
5
5
  # @swc/plugin-formatjs
6
6
 
7
+ ## 3.2.0
8
+
9
+ ### Minor Changes
10
+
11
+ - 648faf7: add support for hex and base64url digest encodings in idInterpolationPattern placeholders
12
+
13
+ ## 3.1.2
14
+
15
+ ### Patch Changes
16
+
17
+ - d51d525: Update swc_core to v22.0.0
18
+
7
19
  ## 3.1.1
8
20
 
9
21
  ### Patch Changes
@@ -204,4 +204,50 @@ describe("formatjs swc plugin", () => {
204
204
  expect(sha512output).toMatch(/id: "[a-zA-Z0-9]{6}"/);
205
205
  expect(sha1output).not.toMatch(sha512output);
206
206
  });
207
+
208
+ it("should be able to use object description", async () => {
209
+ const input = `
210
+ import { FormattedMessage } from 'react-intl';
211
+
212
+ export function Greeting() {
213
+ return (
214
+ <FormattedMessage
215
+ defaultMessage="Hello!"
216
+ description={{ text: "Greeting message" }}
217
+ />
218
+ );
219
+ }
220
+ `;
221
+
222
+ console.log(input);
223
+ const output = await transformCode(input);
224
+
225
+ expect(output).toMatch(/id: "zL\/jyT\"/);
226
+ });
227
+
228
+ it("should be able to use different encodings in interpolation", async () => {
229
+ const input = `
230
+ import { FormattedMessage } from 'react-intl';
231
+
232
+ export function Greeting() {
233
+ return (
234
+ <FormattedMessage
235
+ defaultMessage="Hello, World!"
236
+ description="Greeting message"
237
+ />
238
+ );
239
+ }
240
+ `;
241
+
242
+ const hexOutput = await transformCode(input, {
243
+ idInterpolationPattern: "[sha512:contenthash:hex:9]",
244
+ });
245
+
246
+ const base64UrlOutput = await transformCode(input, {
247
+ idInterpolationPattern: "[sha512:contenthash:base64url:12]",
248
+ });
249
+
250
+ expect(hexOutput).toMatch(/id: "[0-9a-f]{9}"/);
251
+ expect(base64UrlOutput).toMatch(/id: "[a-zA-Z0-9-_]{12}"/);
252
+ });
207
253
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swc/plugin-formatjs",
3
- "version": "3.1.1",
3
+ "version": "3.2.0",
4
4
  "description": "FormatJS SWC plugin",
5
5
  "main": "swc_plugin_formatjs.wasm",
6
6
  "homepage": "https://swc.rs",
Binary file