Closed hjylewis closed 4 years ago
Have you tried babel-plugin-react-intl
?
I'm aware of babel-plugin-react-intl
. How would I use it in this context? I would have to run it using babel which would require the user's babel config which is what @formatjs/cli
is already doing under the hood, right?
This should be in @formatjs/cli@1.4.1
Awesome, thank you!
Let me know if this functionality already exists. I haven't been able to find an easy way of doing it.
Which package? @formatjs/cli
Is your feature request related to a problem? Please describe. I'm developing a library to inject message translations on a per-file basis so that messages will be dynamically added to a bundle. Given a file, this library needs to be able to detect what IDs are used in that file.
Describe the solution you'd like I would like an API to extract the messages from a file programmatically without outputting them to a file. This would look like a function that given a filename, returns the array of messages. @formatjs/cli already does this internally, I am asking for that function to be exported for external use.
Without this, libraries will have to reproduce the logic in @formatjs/cli which is prone to breaking as the library updates. libraries like https://github.com/akameco/extract-react-intl-messages already do this.
Describe alternatives you've considered It might be possible to run the cli in a child process and read the standard output?