Monorepo support
Learn more about the monorepo support and which configurations are supported.
Omlet is designed to support monorepos and automatically detects each package as a separate project. Here are the details of how Omlet detects projects based on your package manager/build system.
npm/Yarn
Omlet will look for the workspace configuration in package.json
, under workspaces
or workspace.packages
fields.
{
...
"workspaces": {
"packages": [
"packages/ds",
"packages/app"
],
},
...
}
{
...
"workspaces": [
"packages/ds",
"packages/app"
],
...
}
{
...
"workspaces": [
"packages/*",
],
...
}
pnpm
Omlet will look for the workspace configuration in pnpm-workspace.yaml
, under packages
filed.
packages:
- 'packages/*'
packages:
- 'packages/**'
- 'apps/**'
Lerna
Omlet will look for the workspace configuration in lerna.json
, under the packages
filed.
{
"packages": [
"packages/*"
]
}
Bolt
Omlet will look for the workspace configuration in package.json
, under bolt
field.
{
...
"bolt": {
"workspaces": [
"packages/*",
],
},
...
}
Nx
Nx can be installed on top of other monorepo libraries. Omlet detects workspaces that are defined using another monorepo library configuration and ignores Nx. That said, a repository having nx.json
doesn't mean that it's treated as an Nx monorepo. Other monorepo configurations take precedence.
If Nx is used as the main monorepo library, each workspace folder contains a project.json
file and, optionally, a package.json
file if the workspace is publishable. In this case, Omlet searches for both project.json
and package.json
files in the repository to figure out workspace folders. If package.json
file exists, the name field in package.json
is used as the workspace name. Otherwise, the name field in project.json
(or the folder name if the name field doesn't exist) is combined with the name of the root package.json
to generate the name of the workspace.
Lastly, package dependency resolution is handled by utilizing tsconfig.json
files under each workspace. Each tsconfig.json
file under a workspace, extends tsconfig.base.json
file on the root folder, which contains the paths
configuration needed for dependency resolution.
For instance, with the given configurations below, Omlet will detect the workspaces as @nx-monorepo/ds
and @nx-monorepo/app
.
{
...
"name": "@nx-monorepo",
...
}
{
...
"compilerOptions": {
"paths": {
"@nx-monorepo/ds": ["path/to/ds/src/index.ts"],
}
}
...
}
{
...
"name": "@nx-monorepo/ds",
...
}
{
...
"name": "design-system",
...
}
{
...
"extends": "../../../tsconfig.base.json"
...
}
{
...
"name": "app",
...
}
{
...
"extends": "../../../tsconfig.base.json"
...
}
Last updated