Support isolating upstream groups in dependsOn
#2006
Replies: 2 comments
-
There is some prior art in this space, but it's unclear to me how correct that can be. For example, a build-time dependency that does code injection or rewrites, or a in-repo runtime dependency that has a build step prior to being able to be consumed—neither of those can be classified singly so we can't simply introspect into In general it should be a safe assumption that if a user updated their Focusing on "how do I tell my task graph about how this change affects the build?" is, eventually, an entire programming language. Trying to accomplish that in a purely declarative manner is going to be constraining and have rapidly diminishing returns. We believe that the ideal behavior in this space is to build a task graph granular enough that the penalty for needing to process portions of the graph is negligible. That your task graph is human-understandable for manual configuration at a point early in a project is an aberration. There is a fantastic chart that demonstrates this which I can't find talking about Broccoli.js (an old JS build tool) which is basically two pictures:
We don't disagree that this is an interesting space to investigate, but the solution for approaching this problem in a way that meets our exacting API standards and scales to ambitious projects has a very different shape. |
Beta Was this translation helpful? Give feedback.
-
@nathanhammond thanks for sharing your thoughts on this. I totally agree that finding a solution that allows (or comes closer to) 100% granularity can manifest as a whole new language. However, I feel like there is a middle ground between 100% granularity and the current state. My proposal only suggests a bit more granularity (the distinction between dependencies and devDependencies), not 100% granularity - It isn't a perfect solution, but I believe it provides some value, and I imagine it also isn't much more complex to maintain. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
First brought up in this question: #2005
Context
It is a common practice for library developers to create a distinction between runtime dependencies, and build dependencies by using
dependencies
(for runtime dependencies) anddevDependencies
(for build dependencies).Problem
At the time, there isn't a way to express that distinction in the
turbo.json
file'sdependsOn
config.The cost is that caches are unnecessarily purged in cases where a package's dependency changes, even though the dependency is not referenced during the build, and is only referenced during the runtime of the package.
Example
package-1 > input
package-1 > output
package-1/package.json
package-2/package.json
some-internal-build-tool/package.json
turbo.json
Then
If I make a change in
package-2
, I don't need to recompilepackage-1
because this is a runtime dependency. However, if I make a change tosome-internal-build-tool
then I should need to recompilepackage-1
andpackage-2
.Proposal (Idea)
Allow developers to isolate
dependencies
anddevDependencies
in the upstream reference. This will allow us to continue maintaining a distinction between runtime and build dependencies (Usingdependencies
, anddevDependencies
as proxies, respectively), while optimizing cache hits.Syntax
I don't know what the preference would be, but seems like it may make sense to just build on top of the convention to use an arbitrary symbol as a prefix (for upstream) and suffix (for downstream) [as
^dep
ordep^
is used currently], but the symbol should be unique.Additionally, it may make sense to suggest a more verbose but clear syntax to denote the dependency group reference
Final thoughts
I think allowing this distinction is a reasonable step forward in allowing developers more expressive freedom to optimize cache hits.
However, I recognize that this is still limited and leads to unnecessary cache misses since there isn't a way to provide granular dependencies for a script. This a product of the
turbo.json
's global nature, and the fact thatturbo
assumes that all dependencies (includingdevDependencies
) can affect the output of a given command.A solution could be to allow providing granular dependencies per project/script (Like Bazel does with
BUILD
files).For example, lets say 2 dependencies affect the result of
build
, and 2 other dependencies affect the result oftest
So my proposal is likely not the best solution, but a maybe reasonable step forward?
Beta Was this translation helpful? Give feedback.
All reactions