3

I would like to fork Facebook's Create React Repo and use it as a dependency instead of their own react-scripts. All tutorials on the subject publish the forked repo to NPM to install via the normal way. However, my client would prefer to not do that as both the forked Create React App and my React App repositories are hosted in the same Azure workspace.

I know CRA is a monorepo and uses Lerna. Does that make it possible?

sidonaldson
  • 24,431
  • 10
  • 56
  • 61
  • I see a vote to close this question citing more detail. Please comment if you need more detail and I will provide it – sidonaldson Jan 23 '20 at 17:14

2 Answers2

0

You could upload the package to a online git repository like GitHub. It can even be private if you want. The command to install it would then be: npm install --save-dev github:username/repo-name

If you're gonna make the repo private then you need to have SSH keys setup on GitHub and on all machines on which you will be installing the dependency on.

You could also install the dependency as a path if it's on the same file system but I have bad experiences with that so I don't recommend it.

Kamil Kulach
  • 499
  • 4
  • 9
0

I've personally done that at a previous organisation. We copied any package that we forked, when heavy changes were necessary, inside our monorepo. Lerna (or yarn, or what ever) takes care of the rest.

If you have a lerna monorepo, you'd take the content of https://github.com/facebook/create-react-app/tree/master/packages/react-scripts into your monorepo, in say: packages/custom-react-scripts and change the name of the copied package in the package.json

If you'd like to rename react-scripts binary into custom-react-scripts you could do that as well via the "bin" configuration inside the copied package.json

All the renaming steps are of course optional, but it helps to know that you're not using the official tool.

Marouane Fazouane
  • 1,279
  • 14
  • 20