You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by cl8n April 8, 2022
in my app I use a custom algorithm to generate message IDs. I've used babel-plugin-formatjs's overrideIdFn and formatjs extract's --format option to do this.
I discovered today that, since I'm also using the --flatten option on formatjs extract, the provided defaultMessages which I'm using to generate IDs are the flattened ones. the defaultMessage input to overrideIdFn is not flattened, so the ID ends up different for some messages.
my current workaround is to flatten defaultMessage as it comes into overrideIdFn:
but this is now referring to internals of formatjs, and I don't think it should be required to read the source to get this behavior. debugging why some IDs weren't matching up took me a while 😅 so what I suggest is to add another option for babel-plugin-formatjs that would control whether the defaultMessage input to overrideIdFn is flattened.
maybe this isn't common enough of a use case though, I'm not sure. thanks!
The text was updated successfully, but these errors were encountered:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Discussed in #3525
Originally posted by cl8n April 8, 2022
in my app I use a custom algorithm to generate message IDs. I've used
babel-plugin-formatjs
'soverrideIdFn
andformatjs extract
's--format
option to do this.I discovered today that, since I'm also using the
--flatten
option onformatjs extract
, the provideddefaultMessage
s which I'm using to generate IDs are the flattened ones. thedefaultMessage
input tooverrideIdFn
is not flattened, so the ID ends up different for some messages.my current workaround is to flatten
defaultMessage
as it comes intooverrideIdFn
:but this is now referring to internals of formatjs, and I don't think it should be required to read the source to get this behavior. debugging why some IDs weren't matching up took me a while 😅 so what I suggest is to add another option for
babel-plugin-formatjs
that would control whether thedefaultMessage
input tooverrideIdFn
is flattened.maybe this isn't common enough of a use case though, I'm not sure. thanks!
The text was updated successfully, but these errors were encountered: