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
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!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
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!
Beta Was this translation helpful? Give feedback.
All reactions