Created by: CarlRibbegaardh
Added support for alternative tsconfig through TSCONFIG_BUILD env variable. It's intended for using a custom tsconfig in a monorepo setting.
TSCONFIG_BUILD=tsconfig.build.json
React-scripts doesn't play with path aliases. But in monorepos a lot of people go a long way to have them.
The end goal is to have a tsconfig.json that inherits a base tsconfig with all internal package folders defined in order to facilitate easy navigation from the outermost projects into components inside library projects. But by doing that it causes the build process to navigate through the source files instead of the build/dist folders of the library project builds. This is usually solved by updating the tsconfig on the fly before react-scripts build or copying between build and edit mode configs. This PR gives the possibility for react-scripts to use a dedicated tsconfig.build.json instead of the tsconfig.json used by the editor.
This is version 2 of this PR (which is incorrectly marked as merged and almost the same diff is available here)
Here's a super simple sample to show how it works. It's the turborepo "with-create-react-app" that originally suffers from not being able to navigate to the components through CTRL-Click in VSCode. You can try out that behavior in /apps/doc/App.tsx and navigate to Link and compare with /apps/web/App.tsx. The difference is that the latter has a specific build tsconfig that is working as create-react-app expects.
Changes: https://github.com/vercel/turborepo/compare/main...CarlRibbegaardh:turborepo:tsconfig-build-sample
Things to try: 1 build whole project: yarn build 2 cd ./apps/web 3 yarn build 4 rename ./apps/web/tsconfig.json to something invalid and yarn build inside that folder again 5 go to Link.tsx and make the file content invalid, then yarn build from apps\web (should still work since dist/index.js is used) (building from top would rebuild ui first 6 building from top will of course trigger build errors as usual
To compare with how similar situations are solved by ejecting or craco, google search for: yarn workspaces create react app create react app path alias