Created by: bmuenzenmeyer
I had some extra
This PR adds the ability to run the cra-template-typescript
source locally, which is nice when verifying the template contents and TS ecosystem.
To run:
CRA_TEMPLATE_TS_LOCAL=true yarn start
CRA_TEMPLATE_TS_LOCAL=true yarn build
CRA_TEMPLATE_TS_LOCAL=true yarn test
This relies on a process.env
check within paths.js
that alters the hardcoded path to cra-template
.
I know webpack 5 is doing away with Node polyfilling, but CRA currently still supports process.env
so I am hoping this is alright.
Running this for the first time is interesting too, in that TypeScript generates two files that have historically never been present, tsconfig.json
and the react-app-env.d.ts
file. I've currently gitignored these files, as there is value in the tsconfig.json
being generated by TS from version to version (I know the definition is added during init).
EDIT: the only thing I'd consider a bit unclean about this new functionality is that the @types/
modules need to be installed at the root in order for resolution to succeed. Of course, an end user would get these via template.json
but that's not really an option during local runs. Is this too much of a future maintenance burden to keep them aligned? CRA already does the same with the RTL libraries AFAIK. Tooling can help here, or targeting versions via dist tag like "@types/react": "ts4.1",
.... but that's a separate issue.
EDIT 2: also thinking about where this could be documented - perhaps within https://create-react-app.dev/docs/advanced-configuration/
I am being slightly lazy here and letting the GH CI handle the complete suite. Forgive me, but kiddos call
👶