Circular dependencies in newly migrated repository #8135
-
SummaryI was tasked at work with migrating an existing NextJS web application to Turborepo to allow for code-sharing between any new applications that may be developed, as well as streamlined CI/CD and task caching. Upon migration, it seemed like things would be relatively easy, as within our Whenever I went and executed this idea, it seemed to work fine, I created packages with labels such as All seemed well, and I got through the migration without any TS errors after quite a bit of work, until I went to run the
I see that I am importing some of these packages within others, but I don't understand what needs to be done to prevent this? As it seems to prevent this from happening, we would need to remove some exports that exist in a package like Additional informationNo response ExampleNo response |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Circular dependencies happen when you have dependencies installed into each other such that an order for the package graph can't be determined to have a specific "direction". For instance, given two packages with these // ./packages/a/package.json
{
"name": "@repo/a",
"scripts": {
"build": "tsc"
},
"dependencies": {
"@repo/b": "workspace:*"
}
} // ./packages/b/package.json
{
"name": "@repo/b",
"scripts": {
"build": "tsc"
},
"dependencies": {
"@repo/a": "workspace:*"
}
} In this case, there's no way for Some strategies to avoid this:
|
Beta Was this translation helpful? Give feedback.
-
Hey @anthonyshew, I feel like there should be a way to force Turborepo to accept the circular dependency in this scenario. Take this case where
We could break the rules out into a separate package, but then we end up with For now, my workaround is to directly import the shared Vitest config by relative path, and add that package as an arbitrary dependency in |
Beta Was this translation helpful? Give feedback.
Circular dependencies happen when you have dependencies installed into each other such that an order for the package graph can't be determined to have a specific "direction".
For instance, given two packages with these
package.json
s:In this case, there's no way for
turbo
to understand which"build"
to run first. If@repo/a
needs@repo/b
to be available for it to build,@repo/b
nee…