-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
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'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:
defaultMessage = printAST(hoistSelectors(parse(defaultMessage)));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!