如何将 Node.js 微服务客户端作为来自同一存储库的独立包发布?

How to have Node.js microservice's client published as an independant package from the same repo?

我目前正在开发 Web 应用程序,我决定使用客户端 <-> api <-> [微服务] 模式。

我正在通过 node.js 使用 Typescript 在 Clean Architecture 中开发我的微服务来挑战自己。

我已经在 Go 中完成了完全相同的事情,但出于某些原因,我想在这里使用 node.js。

微服务本身的开发根本不是问题,它运行良好,考虑到我根本不习惯使用 Typescript 进行开发,我对我所做的非常满意。

无论如何,我的问题是: 在 Go 中,我能够构建微服务的客户端并同时发布它,最重要的是来自与微服务本身相同的 repo。这非常方便,因为客户端随后可以封装所有自定义类型和数据模型。

在这里我想做同样的事情:我有一个主回购

> dist //where JS files will be generated of course
> src //where you can find my TS files
  > controllers
  > factories
  > models
    > objects
      - InputObject.ts
  > repositories
  > routes
  > services
  > use_cases
  - index.ts

我想将我的客户端库放在这个主仓库的子文件夹中。

我可以使用 git 子模块或 npm 目标,但问题是,假设我的树是这样的:

> dist
> client
  > src
    - index.ts
  > dist
    - package.json
> src
  //all the same as above

如何从 client/src/index.ts 开始使用 src/models/* 的类型并拥有它们 我 npm publish 时工作?这可能吗?

非常感谢您的关注与参与!

我终于找到了一个很棒的软件包,可以让我做到这一点:Lerna (https://github.com/lerna/lerna)