Create Another Git Repository For Common Component Development Under a Git Repository

The Article Background

Our team starts multiple projects recently. My task is to write the frame component of all projects using React. The component includes the top menu and left side menu as the submenu. These projects assigned to multiple groups. And each project has its own git repository. Well, the problem is how to share the frame component and update once the frame has a new feature in the multiple projects during development.


How do I solve the share and update?

I thought I can package the frame as a node_mudule. And the developer of every project's group can install and update by npm. I could use our team's development server as the git repository. And I can upload and update code to the repository. The developer can update the frame by npm.

npm install git+http://xxx.xx.xx.xx/userName/Frame.git#master

How do I establish an environment of development?

As you know, we can use webpack to build assets. but the redundant file will be submitted to the git repository. such as webpack.config.js, .gitignore, .bablerc and so on. It's very not good. Why not use one of the projects as the Frame component's development environment?

Great idea. We can use git and gitignore management. One is the project‘s git repository, the other is Frame's git repository. The folder structure is below.

Every developer of all projects can install and update with npm.

Summary

We can use one of project development’s environment when we develop a node_module. And do not establish the components’ development environment. This is a good skill.

Update Jan 31, 2019

Git addresses this issue using submodules.

This article is original, licensed under a Creative Commons Attribution 4.0 International license