A monorepo
that demonstrates workspaces
integration with a package-based design
.
.
├── LICENSE
├── README.md
├── node_modules (will be visible on yarn install in root directory)
│ └── @calci
│ ├── adder -> ../../packages/adder (symlinks)
│ └── subtractor -> ../../packages/subtractor (symlinks)
├── package.json
├── packages
│ ├── adder
│ │ ├── index.js
│ │ └── package.json
│ └── subtractor
│ ├── index.js
│ └── package.json
├── test
│ ├── adder
│ │ ├── adder.js
│ │ └── package.json
│ └── subtractor
│ ├── package.json
│ └── subtractor.js
└── yarn.lock
You can find more about yarn workspaces here.
To install all the packages in the monorepo, run:
yarn install
yarn workspace adder test -- <num1> <num2>
yarn workspace subtractor test -- <num1> <num2>
yarn run test
The monorepo
design along with workspaces
makes it possible to use the packages within the repository efficiently. This design pattern also allows developers to publish packages independently to the npm registry.
To publish the @calci/adder
package to the npm registry, follow these steps:
cd packages/adder # Assuming you are at the root
yarn login
yarn publish --access public
You can find more on package publishing using yarn here.