@swc/plugin-formatjs 3.1.2 → 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 +6 -0
- package/README.md +6 -0
- package/__tests__/wasm.test.ts +46 -0
- package/package.json +1 -1
- package/swc_plugin_formatjs.wasm +0 -0
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
package/__tests__/wasm.test.ts
CHANGED
|
@@ -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
package/swc_plugin_formatjs.wasm
CHANGED
|
Binary file
|