I want to sort a JSON file as part of my build process. Basically I have react-intl
which defines localised messages, then babel-plugin-react-intl
extracts those messages to files - the issue is that the file in question is not sorted (which creates all sorts of annoying versioning problems).
I could simply hack the actual dist of the plugin (which works), but that is not very scalable. I looked at babel-plugin-macros
but it seems most of these deal with traversing the actual AST of applications. Basically all I want is to say; "At the end of every build, run this function" which would contain:
//Open the file en.json
Object.keys(messages).reduce((accumulator, currentValue) => {
accumulator[currentValue] = testObj[currentValue];
return accumulator;
}, {})
// save it again
Isn't there any simple way to just call an extra function as part of your pipeline - without having too hook into the whole visitor/ast traversal API of babel?