You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our monorepo follows the standard pattern of being split into deployed /apps and bundled /packages. All of the /packages have a build script that produces a /dist output, which are being cached during CI. When those packages are built we mark all dependencies in that package's package.json as externals so they are not bundled in the final output. This way the /dist output for each package is small - essentially just the bundled source - and the /apps have the ultimate responsibility of combining everything, including dependencies, into the final JS bundle.
The problem is when packages depend on each other the dependencies are part of calculation for determining what is cached, even if the output from the task doesn't change. For example, we might have a dependency chain where package A depends on package B, and B depends on package C. If we make a change to the /src of package C we want the a new version of the output to be cached. However, even though C is marked as an external for B (and B as external for A), both A and B end up rebuilding, even though the final output contents remain unchanged.
Is there a way to tell the build script to only depend on changes to the immediate package's /src and nothing else?
Additional information
I've tried setting the build task in the root turbo.json as:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Summary
Our monorepo follows the standard pattern of being split into deployed
/apps
and bundled/packages
. All of the/packages
have abuild
script that produces a/dist
output, which are being cached during CI. When those packages are built we mark all dependencies in that package'spackage.json
as externals so they are not bundled in the final output. This way the/dist
output for each package is small - essentially just the bundled source - and the/apps
have the ultimate responsibility of combining everything, including dependencies, into the final JS bundle.The problem is when packages depend on each other the dependencies are part of calculation for determining what is cached, even if the output from the task doesn't change. For example, we might have a dependency chain where package
A
depends on packageB
, andB
depends on packageC
. If we make a change to the/src
of packageC
we want the a new version of the output to be cached. However, even thoughC
is marked as an external forB
(andB
as external forA
), bothA
andB
end up rebuilding, even though the final output contents remain unchanged.Is there a way to tell the
build
script to only depend on changes to the immediate package's/src
and nothing else?Additional information
I've tried setting the
build
task in the rootturbo.json
as:However, if I make a change to a dependency down the line it will still rebuild all of the packages up the dependency stream.
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions