简体   繁体   English

如何使用 TurboRepo 重建依赖于已更改 package(本地)的应用程序

[英]How to use TurboRepo to rebuild apps that rely on a changed package (local)

I'm currently setting up TurboRepo alongside yarn workspaces and I'm having trouble getting it to rebuild our main app whenever one of the local packages it relies on changes.我目前正在将TurboRepo与纱线工作区一起设置,并且每当它依赖的本地包之一发生更改时,我都无法让它重建我们的主应用程序。

Here is an example of my file structure:这是我的文件结构的示例:

├── apps                   
│   └── web
├── packages              
│   ├── assets                 
│   ├── config                 
│   ├── design-system          
│   ├── hooks                  
│   └── utils                  

Here is my turbo.json:这是我的 turbo.json:

{
  "$schema": "https://turborepo.org/schema.json",
  "baseBranch": "origin/main",
  "pipeline": {
    "build": {
      "dependsOn": ["^build"],
      "outputs": [".sst/**", ".build/**", ".expo/**"]
    }
  }
}

I would like to only rebuild packages/apps whenever they have changed in git, so I am using the --filter=[origin/main] .我只想在 git 中发生更改时重建包/应用程序,所以我使用--filter=[origin/main] I made a small change to the hooks package and expected it to need to rebuild hooks , hooks dependencies, and web (because web has hooks as a dependency in its package.json). I made a small change to the hooks package and expected it to need to rebuild hooks , hooks dependencies, and web (because web has hooks as a dependency in its package.json). However, it only tries to rebuild hooks and hooks dependencies.但是,它只尝试重建hooks和钩子依赖项。

To test, I am experimenting with the following command: yarn turbo run build --filter=[origin/main] --dry-run为了测试,我正在试验以下命令: yarn turbo run build --filter=[origin/main] --dry-run

This prints out the following output:这将打印出以下 output:

@hlp/config#build
  Task          = build
  Package       = @hlp/config
  Hash          = 118d81f38208c721
  Directory     = packages\config
  Command       = <NONEXISTENT>
  Outputs       = .sst/**, .build/**, .expo/**
  Log File      = packages\config\.turbo\turbo-build.log
  Dependencies  =
  Dependendents = @hlp/hooks#build, @hlp/utils#build
@hlp/utils#build
  Task          = build
  Package       = @hlp/utils
  Hash          = 0c879c46fe4a9144
  Directory     = packages\utils
  Command       = <NONEXISTENT>
  Outputs       = .sst/**, .build/**, .expo/**
  Log File      = packages\utils\.turbo\turbo-build.log
  Dependencies  = @hlp/config#build
  Dependendents = @hlp/hooks#build
@hlp/hooks#build
  Task          = build
  Package       = @hlp/hooks
  Hash          = 4be940dedd5cc599
  Directory     = packages\hooks
  Command       = <NONEXISTENT>
  Outputs       = .sst/**, .build/**, .expo/**
  Log File      = packages\hooks\.turbo\turbo-build.log
  Dependencies  = @hlp/utils#build, @hlp/config#build
  Dependendents =

As you can see, it does not try to rebuild web .如您所见,它不会尝试重建web Is there any way to trigger web to rebuild since its dependency changed?有什么方法可以触发web重建,因为它的依赖关系发生了变化?

As stated in docs ( https://turborepo.org/docs/core-concepts/filtering ), you should be able to include dependents of matched packages by using ... prefix before query (eg --filter=...[origin/main] )如文档( https://turborepo.org/docs/core-concepts/filtering )中所述,您应该能够通过在查询前使用...前缀来包含匹配包的依赖项(例如--filter=...[origin/main]

# Build everything that depends on changes in branch 'my-feature'
turbo run build --filter=...[origin/my-feature]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 turborepo 中同时使用 root 和 app 级别的 env 文件 - How to use both root and app level env files with turborepo 如何在电子中重建 epoll 包? - How to rebuild epoll package in electron? Google Apps 脚本:如何使用带有本地字符串的 copyTo function - Google Apps Script : How to use the copyTo function with a local string 更改按值跟踪时如何重建ng-repeat? - How to rebuild ng-repeat when track by value is changed? 如何将带有 turborepo 的 monorepo 部署到数字海洋? - how to deploy a monorepo with turborepo to digital ocean? 如何防止$ state刷新任何不依赖于$ state.var的Component? - How to prevent $state from refreshing any Component that does not rely on the $state.var being changed? 如何将turborepo驱动的monorepo部署到Vercel? - How to deploy monorepo powered by turborepo to Vercel? 如何使用本地npm包中的React组件 - How to use React components from local npm package 是否可以在本地 package 导入中使用 package 名称? - Is it possible to use the package name in a local package import? 在不同的本地 npm 包中使用本地 npm 包 - Use local npm package within a different local npm package
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM