@swc/plugin-formatjs 3.1.2 → 3.2.1

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.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 1abaa28: fix(formatjs): Sort description objects before serialization
8
+
9
+ ## 3.2.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 648faf7: add support for hex and base64url digest encodings in idInterpolationPattern placeholders
14
+
3
15
  ## 3.1.2
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -4,6 +4,12 @@ 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
+
7
13
  ## 3.1.2
8
14
 
9
15
  ### Patch Changes
@@ -204,4 +204,83 @@ 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 generate same id even if order of keys is different in two description objects with same keys", async () => {
229
+ const input = `
230
+ import { FormattedMessage } from 'react-intl';
231
+
232
+ export function Greeting() {
233
+ return (
234
+ <FormattedMessage
235
+ defaultMessage="Hello!"
236
+ description={{ text: "Greeting message", image: "https://example.com/image.png" }}
237
+ />
238
+ );
239
+ }
240
+ `;
241
+
242
+ const input2 = `
243
+ import { FormattedMessage } from 'react-intl';
244
+
245
+ export function Greeting() {
246
+ return (
247
+ <FormattedMessage
248
+ defaultMessage="Hello!"
249
+ description={{ image: "https://example.com/image.png", text: "Greeting message" }}
250
+ />
251
+ );
252
+ }
253
+ `;
254
+
255
+ const output = await transformCode(input);
256
+ const output2 = await transformCode(input2);
257
+
258
+ expect(output).toMatch(output2);
259
+ });
260
+
261
+ it("should be able to use different encodings in interpolation", async () => {
262
+ const input = `
263
+ import { FormattedMessage } from 'react-intl';
264
+
265
+ export function Greeting() {
266
+ return (
267
+ <FormattedMessage
268
+ defaultMessage="Hello, World!"
269
+ description="Greeting message"
270
+ />
271
+ );
272
+ }
273
+ `;
274
+
275
+ const hexOutput = await transformCode(input, {
276
+ idInterpolationPattern: "[sha512:contenthash:hex:9]",
277
+ });
278
+
279
+ const base64UrlOutput = await transformCode(input, {
280
+ idInterpolationPattern: "[sha512:contenthash:base64url:12]",
281
+ });
282
+
283
+ expect(hexOutput).toMatch(/id: "[0-9a-f]{9}"/);
284
+ expect(base64UrlOutput).toMatch(/id: "[a-zA-Z0-9-_]{12}"/);
285
+ });
207
286
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swc/plugin-formatjs",
3
- "version": "3.1.2",
3
+ "version": "3.2.1",
4
4
  "description": "FormatJS SWC plugin",
5
5
  "main": "swc_plugin_formatjs.wasm",
6
6
  "homepage": "https://swc.rs",
Binary file