create-react-app should allow TypeScript imports outside `src`
Created by: bluenote10
Is your proposal related to a problem?
Code reuse is a good thing. It is not uncommon that a backend and a frontend can use the same code, and live in the same repository. The need for sharing code is particularly strong with TypeScript type definitions, because developers on the backend and the frontend want to make sure that they are building against a common types.
Describe the solution you'd like
I don't know the CRA internals, but maybe one of the following:
- Allow
baseUrl
to point outside.
to enable absolute imports like `import * as foo from 'common/foo``. - Enable relative imports outside
src
likeimport * as foo from '../../common/foo'
.
Describe alternatives you've considered
There are work-arounds using a combination of third-party cra-patching libraries. They are tedious to setup though (I worked 3 evenings on coming up with a solution), potentially fragile, and the use case seems so fundamental that I'm very surprised that it is not to supported out-of-the-box.