Skip to content

New workspace

This documentation will explain how to setup a new workspace inside the monorepository.

  • Init a new project at the root. (or inside relevant folders).

  • Extend the tsconfig.json with the one at the root. In your tsconfig.json copy/paste this line:

"extends": "../../../../tsconfig.json",

It gives us access to aliases for using DTOs and libs:

"paths": {
      "core/shared/dtos/*": ["core/shared/communication/dtos/*"],
      "@wiotm-libs/*": ["core/shared/*"]
    }
  • Delete this line (still in your tsconfig.json):
   "baseUrl": "./"

⚠️ As you extend another configuration and we work as a monorepo way, if you don't delete this line it will override the root configuration.

  • Add the new project as a workspace of the monorepository. In the package.json at the root (iotmanager/) add the path to your new workspace as in following examples:
 "workspaces": [
    "./core/apps/*",
    "./core/apps/client/*",
  ],
  • In your new app delete the node_modules directory and at the root of the monorepo do anpm i. Now all packages will be shared across the monorepo through the node_modules directory at the root.

  • Delete the package-lock.json in your app is safer. Whenever you want to update a dependency in your package.json, logically you would do a npm i in this directory to update your change. If you do that: as the workspace itself have no notions of the monorepository it is going to install all the nodes_modules in this directory and that's not the goal of monorepo. So instead, you go to the root and do that npm i to upgrade the package. But, if you don't have deleted the package-lock.json of your new app before, it will only take in account this one and will not upgrade anything. Only package-lock.json of monorepo root is useful.

  • Finally, get rids of duplicates configurations that you can find on your tsconfig.json. As we extends the one at the root it is not necessary to have it both times.