turbo 2.11.4 → 2.11.5-canary.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/docs/README.md +39 -0
  2. package/docs/acknowledgments.mdx +48 -0
  3. package/docs/community.mdx +63 -0
  4. package/docs/core-concepts/index.mdx +41 -0
  5. package/docs/core-concepts/internal-packages.mdx +177 -0
  6. package/docs/core-concepts/meta.json +8 -0
  7. package/docs/core-concepts/package-and-task-graph.mdx +127 -0
  8. package/docs/core-concepts/package-types.mdx +32 -0
  9. package/docs/core-concepts/remote-caching.mdx +241 -0
  10. package/docs/crafting-your-repository/caching.mdx +320 -0
  11. package/docs/crafting-your-repository/configuring-tasks.mdx +388 -0
  12. package/docs/crafting-your-repository/constructing-ci.mdx +208 -0
  13. package/docs/crafting-your-repository/creating-an-internal-package.mdx +457 -0
  14. package/docs/crafting-your-repository/developing-applications.mdx +185 -0
  15. package/docs/crafting-your-repository/index.mdx +96 -0
  16. package/docs/crafting-your-repository/managing-dependencies.mdx +306 -0
  17. package/docs/crafting-your-repository/meta.json +15 -0
  18. package/docs/crafting-your-repository/running-tasks.mdx +228 -0
  19. package/docs/crafting-your-repository/structuring-a-repository.mdx +562 -0
  20. package/docs/crafting-your-repository/understanding-your-repository.mdx +158 -0
  21. package/docs/crafting-your-repository/upgrading.mdx +215 -0
  22. package/docs/crafting-your-repository/using-environment-variables.mdx +332 -0
  23. package/docs/getting-started/add-to-existing-repository.mdx +488 -0
  24. package/docs/getting-started/editor-integration.mdx +74 -0
  25. package/docs/getting-started/examples.mdx +108 -0
  26. package/docs/getting-started/index.mdx +72 -0
  27. package/docs/getting-started/installation.mdx +201 -0
  28. package/docs/getting-started/meta.json +10 -0
  29. package/docs/guides/ai.mdx +119 -0
  30. package/docs/guides/ci-vendors/buildkite.mdx +219 -0
  31. package/docs/guides/ci-vendors/circleci.mdx +274 -0
  32. package/docs/guides/ci-vendors/github-actions.mdx +415 -0
  33. package/docs/guides/ci-vendors/gitlab-ci.mdx +207 -0
  34. package/docs/guides/ci-vendors/index.mdx +48 -0
  35. package/docs/guides/ci-vendors/meta.json +1 -0
  36. package/docs/guides/ci-vendors/travis-ci.mdx +197 -0
  37. package/docs/guides/ci-vendors/vercel.mdx +79 -0
  38. package/docs/guides/coordinating-runtime-dependencies.mdx +145 -0
  39. package/docs/guides/frameworks/framework-bindings.mdx +90 -0
  40. package/docs/guides/frameworks/index.mdx +28 -0
  41. package/docs/guides/frameworks/meta.json +10 -0
  42. package/docs/guides/frameworks/nextjs.mdx +231 -0
  43. package/docs/guides/frameworks/nuxt.mdx +229 -0
  44. package/docs/guides/frameworks/rsbuild.mdx +309 -0
  45. package/docs/guides/frameworks/sveltekit.mdx +229 -0
  46. package/docs/guides/frameworks/vite.mdx +307 -0
  47. package/docs/guides/generating-code.mdx +448 -0
  48. package/docs/guides/handling-platforms.mdx +85 -0
  49. package/docs/guides/index.mdx +82 -0
  50. package/docs/guides/meta.json +17 -0
  51. package/docs/guides/microfrontends.mdx +500 -0
  52. package/docs/guides/migrating-from-nx.mdx +688 -0
  53. package/docs/guides/multi-language.mdx +191 -0
  54. package/docs/guides/publishing-libraries.mdx +201 -0
  55. package/docs/guides/single-package-workspaces.mdx +184 -0
  56. package/docs/guides/skipping-tasks.mdx +107 -0
  57. package/docs/guides/tools/biome.mdx +68 -0
  58. package/docs/guides/tools/create-turbo-callout.tsx +10 -0
  59. package/docs/guides/tools/docker.mdx +220 -0
  60. package/docs/guides/tools/eslint.mdx +353 -0
  61. package/docs/guides/tools/go.mdx +195 -0
  62. package/docs/guides/tools/index.mdx +29 -0
  63. package/docs/guides/tools/jest.mdx +231 -0
  64. package/docs/guides/tools/meta.json +16 -0
  65. package/docs/guides/tools/oxc.mdx +270 -0
  66. package/docs/guides/tools/playwright.mdx +176 -0
  67. package/docs/guides/tools/prisma.mdx +30 -0
  68. package/docs/guides/tools/python.mdx +167 -0
  69. package/docs/guides/tools/rust.mdx +170 -0
  70. package/docs/guides/tools/shadcn-ui.mdx +126 -0
  71. package/docs/guides/tools/storybook.mdx +530 -0
  72. package/docs/guides/tools/tailwind.mdx +405 -0
  73. package/docs/guides/tools/typescript.mdx +427 -0
  74. package/docs/guides/tools/vitest.mdx +478 -0
  75. package/docs/index.mdx +45 -0
  76. package/docs/messages/invalid-env-prefix.mdx +36 -0
  77. package/docs/messages/meta.json +3 -0
  78. package/docs/messages/missing-root-task-in-turbo-json.mdx +55 -0
  79. package/docs/messages/package-task-in-single-package-workspace.mdx +40 -0
  80. package/docs/messages/recursive-turbo-invocations.mdx +46 -0
  81. package/docs/messages/unnecessary-package-task-syntax.mdx +46 -0
  82. package/docs/meta.json +14 -0
  83. package/docs/reference/bin.mdx +17 -0
  84. package/docs/reference/boundaries.mdx +106 -0
  85. package/docs/reference/configuration.mdx +1574 -0
  86. package/docs/reference/create-turbo.mdx +194 -0
  87. package/docs/reference/devtools.mdx +33 -0
  88. package/docs/reference/docs.mdx +53 -0
  89. package/docs/reference/eslint-config-turbo.mdx +126 -0
  90. package/docs/reference/eslint-plugin-turbo.mdx +153 -0
  91. package/docs/reference/generate.mdx +94 -0
  92. package/docs/reference/globs.mdx +38 -0
  93. package/docs/reference/index.mdx +190 -0
  94. package/docs/reference/info.mdx +37 -0
  95. package/docs/reference/link.mdx +45 -0
  96. package/docs/reference/login.mdx +48 -0
  97. package/docs/reference/logout.mdx +28 -0
  98. package/docs/reference/ls.mdx +68 -0
  99. package/docs/reference/meta.json +36 -0
  100. package/docs/reference/options-overview.mdx +128 -0
  101. package/docs/reference/package-configurations.mdx +467 -0
  102. package/docs/reference/prune.mdx +253 -0
  103. package/docs/reference/query.mdx +406 -0
  104. package/docs/reference/run.mdx +723 -0
  105. package/docs/reference/scan.mdx +27 -0
  106. package/docs/reference/system-environment-variables.mdx +378 -0
  107. package/docs/reference/telemetry.mdx +45 -0
  108. package/docs/reference/turbo-codemod.mdx +427 -0
  109. package/docs/reference/turbo-gen.mdx +59 -0
  110. package/docs/reference/turbo-ignore.mdx +37 -0
  111. package/docs/reference/unlink.mdx +16 -0
  112. package/docs/reference/watch.mdx +60 -0
  113. package/docs/support-policy.mdx +133 -0
  114. package/docs/telemetry.mdx +67 -0
  115. package/package.json +8 -7
package/docs/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Turborepo documentation
2
+
3
+ These docs match the installed `turbo` package version. Start here, choose the smallest relevant page, and read it before changing Turborepo configuration or commands.
4
+
5
+ The files are the same MDX sources used by turborepo.dev. Site-absolute links such as `/docs/reference/run` map to paths in this directory, such as `reference/run.mdx`.
6
+
7
+ ## Find the page for your task
8
+
9
+ | To do this | Read this |
10
+ | ------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
11
+ | Add Turborepo to a repository | [Add to an existing repository](./getting-started/add-to-existing-repository.mdx) |
12
+ | Understand packages and task relationships | [Package and task graph](./core-concepts/package-and-task-graph.mdx) |
13
+ | Configure tasks, dependencies, inputs, or outputs | [Configuring tasks](./crafting-your-repository/configuring-tasks.mdx) |
14
+ | Look up `turbo.json` fields | [Configuration reference](./reference/configuration.mdx) |
15
+ | Run or filter tasks | [Running tasks](./crafting-your-repository/running-tasks.mdx) and [`turbo run` reference](./reference/run.mdx) |
16
+ | Configure caching or debug cache misses | [Caching](./crafting-your-repository/caching.mdx) |
17
+ | Set up Remote Cache | [Remote Caching](./core-concepts/remote-caching.mdx) |
18
+ | Configure environment variables | [Using environment variables](./crafting-your-repository/using-environment-variables.mdx) |
19
+ | Structure a repository | [Structuring a repository](./crafting-your-repository/structuring-a-repository.mdx) |
20
+ | Create an internal package | [Creating an internal package](./crafting-your-repository/creating-an-internal-package.mdx) |
21
+ | Manage workspace dependencies | [Managing dependencies](./crafting-your-repository/managing-dependencies.mdx) |
22
+ | Configure package-specific tasks | [Package Configurations](./reference/package-configurations.mdx) |
23
+ | Set up CI | [Constructing CI](./crafting-your-repository/constructing-ci.mdx) and [CI vendor guides](./guides/ci-vendors/index.mdx) |
24
+ | Configure watch mode | [`turbo watch` reference](./reference/watch.mdx) |
25
+ | Enforce package boundaries | [Boundaries](./reference/boundaries.mdx) |
26
+ | Look up a command or option | [Reference](./reference/index.mdx) and [options overview](./reference/options-overview.mdx) |
27
+ | Upgrade Turborepo | [Upgrading](./crafting-your-repository/upgrading.mdx) |
28
+
29
+ ## Broader reading order
30
+
31
+ For a broader introduction, read:
32
+
33
+ 1. [Introduction](./index.mdx)
34
+ 2. [Core concepts](./core-concepts/index.mdx)
35
+ 3. [Crafting your repository](./crafting-your-repository/index.mdx)
36
+ 4. [Guides](./guides/index.mdx)
37
+ 5. [Reference](./reference/index.mdx)
38
+
39
+ Prefer these installed docs over the live website when behavior may vary by version.
@@ -0,0 +1,48 @@
1
+ ---
2
+ title: Acknowledgements
3
+ description: Thank you to all these developers, build systems, and monorepo tools for their support and assistance.
4
+ product: turborepo
5
+ type: overview
6
+ summary: Credits and thanks to the developers, build systems, and monorepo tools that inspired Turborepo.
7
+ related:
8
+ - /docs/community
9
+ ---
10
+
11
+ Turborepo was originally created by [Jared Palmer](https://x.com/jaredpalmer) as a closed-source enterprise software offering. In late 2021, [Vercel acquired Turborepo](https://vercel.com/blog/vercel-acquires-turborepo) and open sourced the codebase.
12
+
13
+ Today, Turborepo has a dedicated full-time team working on it as well as a growing list of [open source contributors](https://github.com/vercel/turborepo/graphs/contributors).
14
+
15
+ ## Inspiration and Prior Art
16
+
17
+ At [Vercel](https://vercel.com/), we believe deeply in the open source movement and in the power of open collaboration. To that end, it's important to provide meaningful attribution to the projects and people that inspire(d) us and our work.
18
+
19
+ We'd like to make a special shoutout to other build systems, monorepo tools, and prior art:
20
+
21
+ - Bazel - https://bazel.build
22
+ - Buck - https://buck.build
23
+ - Please - https://please.build
24
+ - Pants - https://www.pantsbuild.org
25
+ - Scoot - https://github.com/twitter/scoot
26
+ - TSDX - https://tsdx.io
27
+ - Lerna - https://lerna.js.org
28
+ - Lage - https://microsoft.github.io/lage
29
+ - Backfill - https://github.com/microsoft/backfill
30
+ - Bolt - https://github.com/boltpkg/bolt
31
+ - Rush - https://rushjs.io
32
+ - Preconstruct - https://preconstruct.tools
33
+ - Nx - https://nx.dev
34
+ - Yarn - https://yarnpkg.com
35
+ - npm - https://www.npmjs.com
36
+ - pnpm - https://pnpm.js.org
37
+
38
+ Throughout the documentation, wherever applicable, we also provide inline callouts and links to the projects and people that have inspired us.
39
+
40
+ ## Additional Thanks
41
+
42
+ Additionally, we're grateful to:
43
+
44
+ - [Rick Button](https://x.com/rickbutton) for donating the `turbo` package name on npm
45
+ - [Iheanyi Ekechukwu](https://x.com/kwuchu) for helping Jared pick up Golang during the Pandemic!
46
+ - [Kenneth Chau](https://x.com/kenneth_chau) for Lage's Scope and Pipeline API and docs
47
+ - [Miguel Oller](https://x.com/ollermi) and [MakeSwift.com](https://www.makeswift.com/) for piloting Turborepo
48
+ - [Eric Koslow](https://x.com/ekosz1), [Jack Hanford](https://x.com/jackhanford), and [Lattice.com](https://lattice.com/) for piloting Turborepo
@@ -0,0 +1,63 @@
1
+ ---
2
+ title: Community
3
+ description: Learn about the Turborepo community.
4
+ product: turborepo
5
+ type: overview
6
+ summary: Find ways to contribute, ask questions, and connect with other Turborepo developers.
7
+ related:
8
+ - /docs/acknowledgments
9
+ ---
10
+
11
+ Turborepo has a large and active community of developers across the world. Here's how you can get involved.
12
+
13
+ ## Contributing
14
+
15
+ - [Documentation](https://github.com/vercel/turborepo/tree/main/docs): Suggest improvements or even write new sections to help build understanding of how to use Turborepo.
16
+ - [Examples](https://github.com/vercel/turborepo/tree/main/examples): Help developers integrate Turborepo with other tools and services by improving an example.
17
+ - [Code](https://github.com/vercel/turborepo/blob/main/CONTRIBUTING.md): Learn more about the underlying architecture, contribute bug fixes, and suggest new features.
18
+
19
+ ## Discussions
20
+
21
+ If you have a question about Turborepo or want to help others, join the conversation:
22
+
23
+ - [GitHub Discussions](https://github.com/vercel/turborepo/discussions)
24
+ - [Vercel Community](https://community.vercel.com/tag/turborepo)
25
+
26
+ ## Acknowledgements
27
+
28
+ Turborepo was originally created by [Jared Palmer](https://x.com/jaredpalmer) as a closed-source enterprise software offering. In late 2021, [Vercel acquired Turborepo](https://vercel.com/blog/vercel-acquires-turborepo) and open sourced the codebase.
29
+
30
+ Today, Turborepo has dedicated full-time team working on it as well as a growing list of [open source contributors](https://github.com/vercel/turborepo/graphs/contributors).
31
+
32
+ ### Inspiration / Prior Art
33
+
34
+ At [Vercel](https://vercel.com/), we believe deeply in the open source movement and in the power of open collaboration. To that end, it's important to provide meaningful attribution to the projects and people that inspire(d) us and our work.
35
+
36
+ We'd like to make a special shoutout to other build systems, monorepo tools, and prior art:
37
+
38
+ - Bazel - https://bazel.build
39
+ - Buck - https://buck.build
40
+ - Please - https://please.build
41
+ - Pants - https://www.pantsbuild.org
42
+ - Scoot - https://github.com/twitter/scoot
43
+ - TSDX - https://tsdx.io
44
+ - Lerna - https://lerna.js.org
45
+ - Lage - https://microsoft.github.io/lage
46
+ - Backfill - https://github.com/microsoft/backfill
47
+ - Bolt - https://github.com/boltpkg/bolt
48
+ - Rush - https://rushjs.io
49
+ - Preconstruct - https://preconstruct.tools
50
+ - Nx - https://nx.dev
51
+ - Yarn - https://yarnpkg.com
52
+ - npm - https://www.npmjs.com
53
+ - pnpm - https://pnpm.js.org
54
+
55
+ ### Additional Thanks
56
+
57
+ Additionally, we're grateful to:
58
+
59
+ - [Rick Button](https://x.com/rickbutton) for donating the `turbo` package name on npm
60
+ - [Iheanyi Ekechukwu](https://x.com/kwuchu) for helping Jared pick up Golang during the Pandemic!
61
+ - [Kenneth Chau](https://x.com/kenneth_chau) for Lage's Scope and Pipeline API and docs
62
+ - [Miguel Oller](https://mobile.x.com/ollermi) and [MakeSwift.com](https://www.makeswift.com/) for piloting Turborepo
63
+ - [Eric Koslow](https://x.com/ekosz1), [Jack Hanford](https://x.com/jackhanford), and [Lattice.com](https://lattice.com/) for piloting Turborepo
@@ -0,0 +1,41 @@
1
+ ---
2
+ title: Core concepts
3
+ description: Learn about the core concepts behind Turborepo.
4
+ product: turborepo
5
+ type: overview
6
+ summary: Explore the foundational concepts that power Turborepo's monorepo tooling.
7
+ related:
8
+ - /docs/core-concepts/remote-caching
9
+ - /docs/core-concepts/package-types
10
+ - /docs/core-concepts/internal-packages
11
+ - /docs/core-concepts/package-and-task-graph
12
+ ---
13
+
14
+ Learn more about the core concepts of Turborepo:
15
+
16
+ <Cards>
17
+ <Card
18
+ title="Remote Caching"
19
+ href="/docs/core-concepts/remote-caching"
20
+ description="Save time by never doing the same work twice"
21
+ />
22
+
23
+ <Card
24
+ title="Package types"
25
+ href="/docs/core-concepts/package-types"
26
+ description="Application and Library Packages"
27
+ />
28
+
29
+ <Card
30
+ title="Internal Packages"
31
+ href="/docs/core-concepts/internal-packages"
32
+ description="Easily share code inside your repository"
33
+ />
34
+
35
+ <Card
36
+ title="Package and Task Graphs"
37
+ href="/docs/core-concepts/package-and-task-graph"
38
+ description="How Turborepo relates your tasks to each other"
39
+ />
40
+
41
+ </Cards>
@@ -0,0 +1,177 @@
1
+ ---
2
+ title: Internal Packages
3
+ description: Learn how to build Internal Packages in your monorepo.
4
+ product: turborepo
5
+ type: conceptual
6
+ summary: Understand how internal packages work and their compilation strategies for sharing code across your monorepo.
7
+ prerequisites:
8
+ - /docs/core-concepts/package-types
9
+ related:
10
+ - /docs/crafting-your-repository/creating-an-internal-package
11
+ - /docs/core-concepts/package-and-task-graph
12
+ - /docs/guides/publishing-libraries
13
+ ---
14
+
15
+ Internal Packages are libraries whose source code is inside your Workspace. You can quickly make Internal Packages to share code within your monorepo and choose to [publish them to the npm registry](/docs/guides/publishing-libraries) if you need to later.
16
+
17
+ Internal Packages are used in your repository by installing them in `package.json` similar to an external package coming from the npm registry. However, instead of marking a version to install, you can reference the package using your package manager's workspace installation syntax:
18
+
19
+ <PackageManagerTabs>
20
+
21
+ <Tab value="pnpm">
22
+ ```json title="./apps/web/package.json"
23
+ {
24
+ "dependencies": {
25
+ "@repo/ui": "workspace:*" // [!code highlight]
26
+ }
27
+ }
28
+ ```
29
+ </Tab>
30
+
31
+ <Tab value="yarn">
32
+ ```json title="./apps/web/package.json"
33
+ {
34
+ "dependencies": {
35
+ "@repo/ui": "*" // [!code highlight]
36
+ }
37
+ }
38
+ ```
39
+ </Tab>
40
+
41
+ <Tab value="npm">
42
+ ```json title="./apps/web/package.json"
43
+ {
44
+ "dependencies": {
45
+ "@repo/ui": "*" // [!code highlight]
46
+ }
47
+ }
48
+ ```
49
+ </Tab>
50
+
51
+ <Tab value="bun">
52
+ ```json title="./apps/web/package.json"
53
+ {
54
+ "dependencies": {
55
+ "@repo/ui": "workspace:*" // [!code highlight]
56
+ }
57
+ }
58
+ ```
59
+ </Tab>
60
+
61
+ <Tab value="nub">
62
+ ```json title="./apps/web/package.json"
63
+ {
64
+ "dependencies": {
65
+ "@repo/ui": "workspace:*" // [!code highlight]
66
+ }
67
+ }
68
+ ```
69
+ </Tab>
70
+
71
+ <Tab value="aube">
72
+ ```json title="./apps/web/package.json"
73
+ {
74
+ "dependencies": {
75
+ "@repo/ui": "workspace:*" // [!code highlight]
76
+ }
77
+ }
78
+ ```
79
+ </Tab>
80
+
81
+ </PackageManagerTabs>
82
+
83
+ In the [Creating an Internal Package guide](/docs/crafting-your-repository/creating-an-internal-package), you can build an Internal Package from the beginning using [the Compiled Package strategy](#compiled-packages). On this page, we'll describe other strategies for creating Internal Packages and their tradeoffs, including [publishing the package to the npm registry](#publishable-packages) to create an External Package.
84
+
85
+ You can then import the package into your code like you're used to doing with an external package:
86
+
87
+ ```tsx title="./apps/web/app/page.tsx"
88
+ import { Button } from "@repo/ui"; // [!code highlight]
89
+
90
+ export default function Page() {
91
+ return <Button>Submit</Button>;
92
+ }
93
+ ```
94
+
95
+ ## Compilation Strategies
96
+
97
+ Depending on what you need from your library, you can choose one of three compilation strategies:
98
+
99
+ - [**Just-in-Time Packages**](#just-in-time-packages): Create minimal configuration for your package by allowing application bundlers to compile the package as it uses it.
100
+ - [**Compiled Packages**](#compiled-packages): With a moderate amount of configuration, compile your package using a build tool like `tsc` or a bundler.
101
+ - [**Publishable Packages**](#publishable-packages): Compile and prepare a package to publish to the npm registry. This approach requires the most configuration.
102
+
103
+ ### Just-in-Time Packages
104
+
105
+ A Just-in-Time package is compiled by the application that uses it. This means you can use your TypeScript (or uncompiled JavaScript) files directly, requiring much less configuration than the other strategies on this page.
106
+
107
+ This strategy is most useful when:
108
+
109
+ - Your applications are built using a modern bundler like Turbopack, webpack, or Vite.
110
+ - You want to avoid configuration and setup steps.
111
+ - You're satisfied with your applications' build times, even when you can't hit cache for the package.
112
+
113
+ A `package.json` for a Just-in-Time package may look like this one:
114
+
115
+ ```json title="./packages/ui/package.json"
116
+ {
117
+ "name": "@repo/ui",
118
+ "exports": {
119
+ "./button": "./src/button.tsx", // [!code highlight]
120
+ "./card": "./src/card.tsx" // [!code highlight]
121
+ },
122
+ "scripts": {
123
+ "lint": "eslint . --max-warnings 0", // [!code highlight]
124
+ "check-types": "tsc --noEmit" // [!code highlight]
125
+ }
126
+ }
127
+ ```
128
+
129
+ There are a few important things to notice in this `package.json`:
130
+
131
+ - **Directly exporting TypeScript**: The `exports` field marks the entrypoints for the package and, in this case, you're **referencing TypeScript files directly**. This is possible because the bundler for the application will compile the code as it uses it in its build process.
132
+ - **No `build` script**: Because this package is exporting TypeScript, it doesn't need a build step for transpiling the package. This means you don't have to configure a build tool in this package to make it work in your Workspace.
133
+
134
+ #### Limitations and tradeoffs
135
+
136
+ - **Only applicable when consumers do transpiling**: This strategy can only be used when the package is going to be used in tooling that uses a bundler or natively understands TypeScript. The consumer's bundler is responsible for transpiling the TypeScript packages to JavaScript. If your builds or other usages of the package are not able to consume TypeScript, you will need to move to the [Compiled Packages](#compiled-packages) strategy.
137
+ - **No TypeScript `paths`**: A library that is being transpiled by its consumer cannot use the `compilerOptions.paths` configuration because TypeScript assumes that source code is being transpiled in the package where it is written. If you're using TypeScript 5.4 or later, we recommend [using Node.js subpath imports](https://devblogs.microsoft.com/typescript/announcing-typescript-5-4/#auto-import-support-for-subpath-imports). To learn how, visit [our TypeScript page](/docs/guides/tools/typescript#use-nodejs-subpath-imports-instead-of-typescript-compiler-paths).
138
+ - **Turborepo cannot cache a build for a Just-in-Time Package**: Because the package doesn't have its own `build` step, it can't be cached by Turborepo. This tradeoff may make sense for you if you want to keep configuration to a minimum and are okay with the build times for your applications.
139
+ - **Errors in internal dependencies will be reported**: When directly exporting TypeScript, type-checking in a dependent package will fail if code in an internal dependency has TypeScript errors. You may find this confusing or problematic in some situations.
140
+
141
+ ### Compiled Packages
142
+
143
+ A Compiled Package is a package that handles its own compilation using a build tool, like [`tsc` (the TypeScript compiler)](https://www.typescriptlang.org/docs/handbook/compiler-options.html#handbook-content).
144
+
145
+ ```json title="./packages/ui/package.json"
146
+ {
147
+ "name": "@repo/ui",
148
+ "exports": {
149
+ "./button": {
150
+ "types": "./src/button.tsx", // [!code highlight]
151
+ "default": "./dist/button.js" // [!code highlight]
152
+ },
153
+ "./card": {
154
+ "types": "./src/card.tsx", // [!code highlight]
155
+ "default": "./dist/card.js" // [!code highlight]
156
+ }
157
+ },
158
+ "scripts": {
159
+ "build": "tsc" // [!code highlight]
160
+ }
161
+ }
162
+ ```
163
+
164
+ Compiling your library produces compiled JavaScript outputs into a directory (`dist`, `build`, etc.) that you will use for the entrypoints for your package. The build outputs will be cached by Turborepo once they're added to the [`outputs` key of the task](/docs/reference/configuration#outputs), allowing you to have faster build times.
165
+
166
+ #### Limitations and tradeoffs
167
+
168
+ - **Using the TypeScript compiler**: The majority of Compiled Packages should use `tsc`. Since the package is highly likely to be consumed by an application that is using a bundler, the application's bundler will prepare the library package for distribution in the application's final bundles, handling polyfilling, downleveling, and other concerns. A bundler should only be used if you have a specific use case that requires it, like bundling static assets into your package's outputs.
169
+ - **More configuration**: Compiled Packages require deeper knowledge and configuration to create build outputs. There are [many configurations for the TypeScript compiler](https://www.typescriptlang.org/docs/handbook/compiler-options.html#compiler-options) that can be difficult to manage and understand, and further configuration to optimize for bundlers, like [the `sideEffects` key in `package.json`](https://webpack.js.org/guides/tree-shaking/#mark-the-file-as-side-effect-free). You can find some of our recommendations in [our dedicated TypeScript guide](/docs/guides/tools/typescript).
170
+
171
+ ### Publishable packages
172
+
173
+ Publishing a package to the npm registry comes with the most strict requirements of the packaging strategies on this page. Because you don't know anything about how your package will be used by consumers who download the package from the registry, you may find it difficult due to the numerous configurations required for a robust package.
174
+
175
+ Additionally, the process of publishing a package to the npm registry requires specialized knowledge and tooling. We recommend [`changesets`](https://github.com/changesets/changesets) for managing versioning, changelogs, and the publishing process.
176
+
177
+ For a detailed guide, visit [our Publishing packages guide](/docs/guides/publishing-libraries).
@@ -0,0 +1,8 @@
1
+ {
2
+ "pages": [
3
+ "remote-caching",
4
+ "package-types",
5
+ "internal-packages",
6
+ "package-and-task-graph"
7
+ ]
8
+ }
@@ -0,0 +1,127 @@
1
+ ---
2
+ title: Package and Task Graphs
3
+ description: Turborepo builds a Task Graph based on your configuration and repository structure.
4
+ product: turborepo
5
+ type: conceptual
6
+ summary: Learn how Turborepo uses directed acyclic graphs to model package dependencies and task relationships.
7
+ prerequisites:
8
+ - /docs/core-concepts/internal-packages
9
+ related:
10
+ - /docs/crafting-your-repository/configuring-tasks
11
+ - /docs/crafting-your-repository/running-tasks
12
+ ---
13
+
14
+ ## Package Graph
15
+
16
+ The Package Graph is the structure of your monorepo created by your package manager. When you install [Internal Packages](/docs/core-concepts/internal-packages) into each other, Turborepo will automatically identify those dependency relationships to build a foundational understanding of your Workspace.
17
+
18
+ For a deeper explanation of how to set up your Workspace, [visit our Structuring a repository page](/docs/crafting-your-repository/structuring-a-repository#anatomy-of-a-workspace). This sets the groundwork for the Task Graph, where you'll define how **tasks** relate to each other.
19
+
20
+ ## Task Graph
21
+
22
+ In `turbo.json`, you express how tasks relate to each other. You can think of these relationships as
23
+ dependencies between tasks, but we have a more formal name for them: the Task Graph.
24
+
25
+ <Callout type="info">
26
+ You can generate a visualization of the task graph for your tasks using [the
27
+ `--graph` flag](/docs/reference/run#--graph-file-type).
28
+ </Callout>
29
+
30
+ Turborepo uses a data structure called a [directed acyclic graph (DAG)](https://en.wikipedia.org/wiki/Directed_acyclic_graph) to
31
+ understand your repository and its tasks. A graph is made up of "nodes" and
32
+ "edges". In the Task Graph, the nodes are tasks and the edges are the
33
+ dependencies between tasks. A _directed_ graph indicates that the edges
34
+ connecting each node have a direction, so if Task A points to Task B, we can say
35
+ that Task A depends on Task B. The direction of the edge depends on which task
36
+ depends on which.
37
+
38
+ For example, let's say you have a monorepo with an application in `./apps/web` that
39
+ depends on two packages: `@repo/ui` and `@repo/utils`:
40
+
41
+ <Files>
42
+ <Folder name="apps" defaultOpen>
43
+ <Folder name="web" />
44
+ </Folder>
45
+ <Folder name="packages" defaultOpen>
46
+ <Folder name="ui" />
47
+ <Folder name="utils" />
48
+ </Folder>
49
+ </Files>
50
+
51
+ You also have a `build` task that depends on `^build`:
52
+
53
+ ```json title="./turbo.json"
54
+ {
55
+ "tasks": {
56
+ "build": {
57
+ "dependsOn": ["^build"]
58
+ }
59
+ }
60
+ }
61
+ ```
62
+
63
+ Turborepo will build a task graph like this:
64
+
65
+ ![Task graph visualization. The diagram has one node at the top named "apps/web" with two lines that connect to other nodes, "packages/ui" and "packages/utils" respectively.](/images/docs/simple-task-graph.png)
66
+
67
+ ### Transit Nodes
68
+
69
+ A challenge when building a Task Graph is handling nested dependencies. For
70
+ example, let's say your monorepo has a `docs` app that depends on the `ui`
71
+ package, which depends on the `core` package:
72
+
73
+ <Files>
74
+ <Folder name="apps" defaultOpen>
75
+ <Folder name="docs" />
76
+ </Folder>
77
+ <Folder name="packages" defaultOpen>
78
+ <Folder name="ui" />
79
+ <Folder name="core" />
80
+ </Folder>
81
+ </Files>
82
+
83
+ Let's assume the `docs` app and the `core` package each have a `build` task, but
84
+ the `ui` package does not. You also have a `turbo.json` that configures the
85
+ `build` task the same way as above with `"dependsOn": ["^build"]`. When you run
86
+ `turbo run build`, what would you expect to happen?
87
+
88
+ Turborepo will build this Task Graph:
89
+
90
+ ![A Task Graph visualization with a Transit Node. The diagram has one node at the top named "apps/doc" with a line that connects to a "packages/ui" node. This node does not have a "build" task. The "packages/ui" node has another line to a "packages/core" node that does have a "build" task.](/images/docs/transitive-nodes.png)
91
+
92
+ You can think of this graph in a series of steps:
93
+
94
+ - The `docs` app only depends on `ui`.
95
+ - The `ui` package does **not** have a build script.
96
+ - The `ui` package's _dependencies_ have a `build` script, so the task graph knows to include those.
97
+
98
+ Turborepo calls the `ui` package a Transit Node in this scenario, because it
99
+ doesn't have its own `build` script. Since it doesn't have a `build` script,
100
+ Turborepo won't execute anything for it, but it's still part of the graph for
101
+ the purpose of including its own dependencies.
102
+
103
+ #### Transit Nodes as entry points
104
+
105
+ What if the `docs/` package didn't implement the `build` task? What would
106
+ you expect to happen in this case? Should the `ui` and `core` packages still
107
+ execute their build tasks? Should _anything_ happen here?
108
+
109
+ Turborepo's mental model is that all nodes in the Task Graph are the same. In other words,
110
+ Transit Nodes are included in the graph regardless of where they appear in the graph.
111
+ This model can have unexpected consequences. For example, let's say you've configured
112
+ your `build` task to depend on `^test`:
113
+
114
+ ```json title="./turbo.json"
115
+ {
116
+ "tasks": {
117
+ "build": {
118
+ "dependsOn": ["^test"]
119
+ }
120
+ }
121
+ }
122
+ ```
123
+
124
+ Let's say your monorepo has many apps and many packages. All packages have
125
+ `test` tasks, but only one app has a `build` task. Turborepo's mental model
126
+ says that when you run `turbo run build`, even if an app doesn't implement `build`
127
+ the `test` task of all packages that are dependencies will show up in the graph.
@@ -0,0 +1,32 @@
1
+ ---
2
+ title: Package types
3
+ description: Learn about the different types of packages in a workspace.
4
+ product: turborepo
5
+ type: conceptual
6
+ summary: Understand the difference between Application Packages and Library Packages in a workspace.
7
+ related:
8
+ - /docs/core-concepts/internal-packages
9
+ - /docs/core-concepts/package-and-task-graph
10
+ - /docs/crafting-your-repository/structuring-a-repository
11
+ ---
12
+
13
+ In Turborepo, we talk about two types of packages:
14
+
15
+ - [Application Packages](#application-packages)
16
+ - [Library Packages](#library-packages)
17
+
18
+ ## Application Packages
19
+
20
+ An Application Package is a package in your workspace that will be deployed from your workspace. Examples of Application Packages are Next.js, Svelte, Vite, or CLI applications that are commonly found in the `./apps` directory.
21
+
22
+ It's best practice that your Application Packages are the "end" of your [Package Graph](/docs/core-concepts/package-and-task-graph#package-graph), not being installed into other packages of your repository. Your CI/CD pipelines will most often finalize at these nodes of your Package and Task Graphs.
23
+
24
+ ### Installing an application package into another package
25
+
26
+ In rare cases, you may need to install an Application Package into another package. This should be the exception. If you find you are doing this often, you may want to rethink your package structure.
27
+
28
+ An example of an exception for this rule is installing your Application Package into a package that handles end-to-end testing. Once installed, you can depend on the Application Package in your end-to-end testing package so it is aware of re-deploys of the application.
29
+
30
+ ## Library Packages
31
+
32
+ Library Packages contain code that you intend to share around your workspace. They aren't independently deployable. Instead, they support the Application Packages to create the final deployables from your repository. You might also refer to these packages as [Internal Packages](/docs/core-concepts/internal-packages), which have their own sub-types.