1

I'm setting up the framework for building a suite of apps in reactjs. They will all communicate with a suite of APIs for the backend. I wanted to build a common JavaScript library "project" where I can put code that could be used by all apps. For instance:

lib 
   |--api (JS service classes to communicate with API backend)
   |--ui
       |--components (common shared react components)

..etc..

I would like to be able to start a new app and include parts of the lib - /lib/api/ for example.

I'll be doing a similar setup with the backend code, which is not JavaScript.

What is the best way to structure this so the lib can easily be included in other projects? We're using git for source control but don't know it well. Should these be git submodules? Or should I look at some kind of private npm repository?

user210757
  • 6,996
  • 17
  • 66
  • 115

1 Answers1

1

You can:

In general, many companies tend to use packages scoped with a @companyname/ namespace. That's what I'd recommend. Whether it's public or private is up to you.

In my opinion git submodules is not what you're looking for. It's more cumbersome to manage than normal npm/yarn dependencies.

zeh
  • 10,130
  • 3
  • 38
  • 56
  • I think this is the answer, thanks. Due to requirements, I can't host in npm cloud so I'll have to find a way to host my own sort of npm – user210757 Jan 09 '19 at 15:50
  • Cool, in that case you can also set [your own npm registry](https://docs.npmjs.com/misc/registry). Or the git dependency works fine if you just want something quick and cheap, with no need for third-party registries. – zeh Jan 09 '19 at 18:49