i am trying to find a good way to share codes between projects like Types and Redux Stores. The best 3 methods i've seen is:
How would u resolve this issue?
Instead of deploying straight to npmjs.com you can use the npm-link cli to install your package locally and then when you need to make changes during development, they will be automatically updated to your projects
This might be a case for a monorepo, with a solution like NX or Lerna
You have one repository that contains multiple apps, and the common code they share. This makes it trivial to update shared code because it's only ever in one place.
In NX, for instance, you have a directory structure like:
apps/
website/ (React app)
mobile-app/ (React native app)
backend/ (Node.js Express app)
libs/
common-utils/
fancy-types/
constants/
And if you want something from a shared lib, you just:
import { foo } from '@mymonoreponame/common-utils'
It is a big change, so if you are wanting to keep those projects in separate repositories, this solution isn't going to help you. But after struggling with similar issues, the switch to a NX monorepo really helped my workflow.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.