软件包类型

在 Turborepo 中,我们讨论两种类型的包:

¥In Turborepo, we talk about two types of packages:

应用包

¥Application Packages

应用包是你工作区中的一个包,它将从你的工作区部署。应用包的示例包括 Next.js、Svelte、Vite 或 CLI 应用,这些应用通常位于 ./apps 目录中。

¥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.

最佳做法是,你的应用包是 软件包图表 的 "end",而不会安装到存储库的其他包中。你的 CI/CD 流水线通常会在包图和任务图的这些节点处完成。

¥It's best practice that your Application Packages are the "end" of your 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.

将应用包安装到另一个包中

¥Installing an application package into another package

在极少数情况下,你可能需要将应用包安装到另一个包中。这应该是例外。如果你发现经常这样做,你可能需要重新考虑你的包结构。

¥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.

此规则的一个例外示例是将你的应用包安装到处理端到端测试的包中。安装后,你可以在端到端测试包中依赖应用包,以便它能够感知应用的重新部署。

¥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.

库软件包

¥Library Packages

库包包含你打算在工作区内共享的代码。它们不能独立部署。相反,它们支持应用包,以便从你的代码库创建最终的可部署文件。你也可以将这些包称为 内部软件包,它们有自己的子类型。

¥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, which have their own sub-types.