0

I have three codebases: web, mobile, and the back-end.

Both the web and mobile codebase will use the same types from the back-end.

The back-end repository is structured as such:

domain/
-- Account.ts
-- Customer.ts
-- Notification.ts
-- Email.ts
-- TextMessage.ts
-- ... etc
...other folders

I need to find a way to get import the types that are inside these files from the mobile and web repositories.

I recently found out about git submodules. It seems to do its job, however, I'd be importing the whole backend to my web and mobile repositories.

Is there a way I can only import the domain folder, instead of the whole backend repository, which is quite heavy?

kibe
  • 90
  • 1
  • 8
  • 26

1 Answers1

1

No, git submodules only work on whole repositories.

Either externalize the interface ts files into a dedicated shared repo or put everything into one big monorepo. (Or include one in the other)

See also this answer. https://stackoverflow.com/a/5303850/1974021

DasKrümelmonster
  • 5,816
  • 1
  • 24
  • 45
  • oh... right! thanks very much. i guess externalizing the types into a private npm package sounds best. do you know if there is a way to create a npm package out of only the `domain` folder? instead of a npm package will the whole repository – kibe Aug 12 '21 at 13:54
  • No, sorry I have never published a npm package. – DasKrümelmonster Aug 13 '21 at 14:07