Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Merge requests
  • !10157

feat(monorepo): adds ability to run cra-template-typescript locally

  • Review changes

  • Download
  • Email patches
  • Plain diff
Open Administrator requested to merge github/fork/bmuenzenmeyer/master into main Nov 26, 2020
  • Overview 1
  • Commits 1
  • Pipelines 1
  • Changes 4

Created by: bmuenzenmeyer

I had some extra 🦃 day time and wanted to submit this small customization we introduced into our fork for consideration upstream.

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

image

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). 🤔 though on some level it's interesting to think that CRA could have more opinion here about what a default tsconfig looks like (with added maintenance then...)

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 👶

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/bmuenzenmeyer/master