[英]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.