Support building a dependency tree of packages
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 275
- PR merge metrics
- No merged PRs in 30d
Description
This is really just a suggestion based on a use case that I realized. I don't believe it's been asked before, but a system for supporting dependencies of packages in a workspace/monorepo being built with `tsup` would be useful.
Currently, I have `packageA` which uses `packageB` and `packageC`, these are all in a monorepo, and they are all built using `tsup --watch`. Because `packageA` will not rebuild/rerun its onSuccess hook when `packageB` or `packageC` have changes and recompile, we ended up writing a tool in that workspace which wraps the `build()` function and uses TCP to tell other instances of the tool to rebuild and rerun the onSuccess hook.
TCP isn't a great option, but maybe adding direct support for a "dependencies" array that take the directories of other projects, or their paths to `tsup.config.ts/js/whatever`. Maybe something like this (rough idea):
```ts
import { defineConfig } from 'tsup'
export default defineConfig({
entry: ['./src/index.ts'],
format: 'esm'
platform: 'node',
onSuccess: 'node --enable-source-maps --inspect=0.0.0.0 ./dist/index.js',
dependencies: [{
path: '/Users/tale/monorepo/projectB',
configPath: '/Users/tale/monorepo/projectB/tsup.ts' // Optional but equivalent to --config
}]
})
```
I haven't completely panned this out in my head, but I wanted to start the discussion to see if this is something that can be considered in-scope with the project, and if so, I'd be willing to contribute and implement this.
Contributor guide
Assessment
This issue has not been assessed yet.