# Monorepo support

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.

<details>

<summary>npm/Yarn</summary>

Omlet will look for the workspace configuration in **`package.json`**, under **`workspaces`** or **`workspace.packages`** fields.

{% code title="package.json" %}

```json
{
  ...
  "workspaces": {
    "packages": [
      "packages/ds",
      "packages/app"
    ],
  },
  ...
}
```

{% endcode %}

{% code title="package.json" %}

```json
{
  ...
  "workspaces": [
    "packages/ds",
    "packages/app"
  ],
  ...
}
```

{% endcode %}

{% code title="package.json" %}

```json
{
  ...
  "workspaces": [
    "packages/*",
  ],
  ...
}
```

{% endcode %}

</details>

<details>

<summary>pnpm</summary>

Omlet will look for the workspace configuration in **`pnpm-workspace.yaml`**, under **`packages`** filed.

{% code title="pnpm-workspace.yaml" %}

```yaml
packages:
  - 'packages/*'
```

{% endcode %}

{% code title="pnpm-workspace.yaml" %}

```yaml
packages:
  - 'packages/**'
  - 'apps/**'
```

{% endcode %}

</details>

<details>

<summary>Lerna</summary>

Omlet will look for the workspace configuration in **`lerna.json`**, under the **`packages`** filed.

{% code title="lerna.json" %}

```json
{
  "packages": [
    "packages/*"
  ]
}
```

{% endcode %}

</details>

<details>

<summary>Bolt</summary>

Omlet will look for the workspace configuration in **`package.json`**, under **`bolt`** field.

{% code title="package.json" %}

```json
{
  ...
  "bolt": {
    "workspaces": [
      "packages/*",
    ],
  },
  ...
}
```

{% endcode %}

</details>

<details>

<summary>Nx</summary>

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`**.

{% code title="package.json (root)" %}

```json
{
  ...
  "name": "@nx-monorepo",
  ...
}
```

{% endcode %}

{% code title="tsconfig.base.json" %}

```json
{
  ...
  "compilerOptions": {
    "paths": {
      "@nx-monorepo/ds": ["path/to/ds/src/index.ts"],
    }
  }
  ...
}
```

{% endcode %}

{% code title="path/to/ds/package.json" %}

```json
{
  ...
  "name": "@nx-monorepo/ds",
  ...
}
```

{% endcode %}

{% code title="path/to/ds/project.json" %}

```json
{
  ...
  "name": "design-system",
  ...
}
```

{% endcode %}

{% code title="path/to/ds/tsconfig.json" %}

```json
{
  ...
  "extends": "../../../tsconfig.base.json"
  ...
}
```

{% endcode %}

{% code title="path/to/app/project.json" %}

```json
{
  ...
  "name": "app",
  ...
}
```

{% endcode %}

{% code title="path/to/app/tsconfig.json" %}

```json
{
  ...
  "extends": "../../../tsconfig.base.json"
  ...
}
```

{% endcode %}

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.omlet.dev/help/faqs/monorepo-support.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
