swc-plugin icon indicating copy to clipboard operation
swc-plugin copied to clipboard

Hashing doesn't match output of `@lingui/cli`

Open maisano-patreon opened this issue 5 months ago • 6 comments

I have a rather large application that uses Lingui. We've recently paved the way the be able to adopt swc (including the use of this plugin), and in the process learned that the hashing of strings is not identical across the JS extraction (and babel macro) and this plugin. For one reason or another we have a handful of strings defined with defineMessage that have trailing whitespace. It seems the normalization of whitespace is part of this plugin, but not similarly handled via the babel-based tooling.

There are a few escape hatches on our end that we can rely on to unblock the adoption of swc:

  • Providing explicit ids to match our existing strings
  • Updating said strings to remove leading/trailing whitespace characters

However, I wanted to flag this as an issue as it's a divergence between the JS and Rust based tooling for Lingui and feels like an oversight. Arguably no string for translation needs to contain leading or trailing whitespace, but I would expect the babel and swc plugins to behave deterministically.

maisano-patreon avatar Sep 26 '24 13:09 maisano-patreon