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.
Here is an example of my file structure:
├── apps
│ └── web
├── packages
│ ├── assets
│ ├── config
│ ├── design-system
│ ├── hooks
│ └── utils
Here is my 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]. 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.
To test, I am experimenting with the following command:
yarn turbo run build --filter=[origin/main] --dry-run
This prints out the following 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. Is there any way to trigger web to rebuild since its dependency changed?
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 (e.g. --filter=...[origin/main])
# Build everything that depends on changes in branch 'my-feature'
turbo run build --filter=...[origin/my-feature]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With