I'm trying to set up a npm workspace monorepo using typescript and create-react-app with the following structure, where project1 and project2 both can reference the library package. The build for project1 and project2 need to run independently, and the root package.json has no build associated with it.
- root
- library
- src
- package.json
- tsconfig.json
- project1
- src
- package.json
- tsconfig.json
- project2
- src
- package.json
- tsconfig.json
- package.json
- library
I've gotten this to work with older versions of create-react-app by using react-app-rewired but I would like to switch to newer versions of react-scripts which react-app-rewired do not support.
I've found lots of tutorials for very similar setups, but nothing quite like what I want. I think I have to use tsconfig.json's composite and reference features, but those seem to be for using one large project where packages in that project can reference each other, instead of what I want which is a number of smaller projects that can all reference a library package.
Notice that in my setup the root has no tsconfig.json, and the root package.json has no build associated with it. The root itself doesn't build anything, each individual project has its own run & build scripts which get run independently to produce their own output.
I guess I could achieve this using symlinks, just linking the library's .tsx files into the individual project's src directories, but there has to be a way to do this properly using tsconfig, right?
Thank you