How to deal with peer dependencies that must be build first?

For Uppy we recently introduced turbo. However we ran into race conditions with builds. Turbo is smart enough to first build dependencies of a package before building the package itself, however almost all of our packages depend on the peer dependency @uppy/core.

I could not find a way to guarantee @uppy/core is always build first so I added a turbo.json to every package just to add:

{
  "extends": ["//"],
  "tasks": {
    "build": {
      "dependsOn": ["@uppy/core#build"]
    }
  }
}

Now it seems that once dependsOn is added that becomes the single source of truth and turbo no longer builds the dependencies first, or so it seems because we have other race conditions now. Below are logs that kind of prove this as we only set @uppy/core in dependsOn while @uppy/rovider-views is in "dependencies".

@uppy/dropbox:build
cache miss, executing b433e035fd3e1293
Error: src/Dropbox.tsx(1[6](https://github.com/transloadit/uppy/actions/runs/16252201232/job/45883390176#step:11:7),31): error TS2306: File '/home/runner/work/uppy/uppy/packages/@uppy/provider-views/lib/index.d.ts' is not a module.
Error:  command finished with error: command (/home/runner/work/uppy/uppy/packages/@uppy/dropbox) /tmp/xfs-ba39c088/yarn run build exited (2)

What is the best way to solve this?

Order of preference:

  1. Remove all redundant turbo.json’s and have a way to make sure @uppy/core is build first while keeping turbo’s caching features.
  2. Adding dependsOn should not ignore dependencies
  3. Manually add all dependencies to every turbo.json
  4. Something else?

I use something like this in my root turbo.json to build paraglide before running tsc as paraglidejs generates files used by the other packages:

"pre-compile": {
      "inputs": ["messages/*.json", "package.json"],
      "outputs": ["src/paraglide"],
      "cache": true
 },
"tsc": {
   "dependsOn": ["@repo/i18n#pre-compile"],
   ...
},

Note I only have a single turbo.json in this monorepo. Sorry I cannot share the repository

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.