user210757
user210757

Reputation: 7386

Sharing comon library in JavaScript front end apps

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?

Upvotes: 1

Views: 50

Answers (1)

zeh
zeh

Reputation: 10669

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.

Upvotes: 1

Related Questions