[RN72][skip-ci] Update Babel config for monorepo setup
Summary:
In the next diff, we update ESLint, which necessitates replacing the deprecated babel-eslint with the new @babel/eslint-parser.
The new @babel/eslint-parser appears to break yarn eslint:fix from the repo root, since it can't find a Babel config file.
To address this, I had to update our Babel config to work from the root. Some relevant docs I had to read:
- https://babeljs.io/docs/config-files#project-wide-configuration
- https://babeljs.io/docs/config-files#file-relative-configuration
- https://babeljs.io/docs/config-files#monorepos
- https://babeljs.io/docs/options#babelrcroots
In short, Babel's docs recommend that for a monorepo setup, you use a single babel.config.cjs file in the root, and then specify .babelrc.cjs files for individual workspaces. However, this didn't work with Jest, which was ignoring the .babelrc.cjs files. This is documented in issues on the Jest repo, but there are no official solutions. To get around this, I ended up also specifying babel.config.cjs files for the individual workspaces, that simply reference the .babelrc.cjs files.
Depends on D10536
Test Plan: In combination with the next diff, run yarn eslint:fix from the repo root
Reviewers: atul
Reviewed By: atul
Subscribers: tomek
Differential Revision: https://phab.comm.dev/D10537