Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support building a dependency tree of packages #999

Open
tale opened this issue Sep 17, 2023 · 5 comments
Open

Support building a dependency tree of packages #999

tale opened this issue Sep 17, 2023 · 5 comments

Comments

@tale
Copy link

tale commented Sep 17, 2023

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):

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.

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@tkodev
Copy link

tkodev commented Oct 1, 2023

I think simply allowing us to monitor file changes in node_modules might be sufficient to trigger the build. Right now watch ignores the node_modules folder. Is there a way to ignore it?

@tale
Copy link
Author

tale commented Oct 2, 2023

I don't think node_modules would suffice because in something like a PNPM repo, workspaces are linked directly from their source. Internally our tool is watching for something like this:

If projectA depends on projectB, I have chokidar watching /packages/projectB/dist to detect rebuilds of projectB and then it'll rerun (without rebuilding).

@yairopro
Copy link

yairopro commented Dec 19, 2023

Something like a notIgnoreWatching option should do the work.

Like

{
  "notIgnoreWatching": [
    "@myMonorepo/myPackage"
  ]
}

@egoist
Copy link
Owner

egoist commented Jan 27, 2024

I don't think node_modules would suffice because in something like a PNPM repo, workspaces are linked directly from their source. Internally our tool is watching for something like this:

If projectA depends on projectB, I have chokidar watching /packages/projectB/dist to detect rebuilds of projectB and then it'll rerun (without rebuilding).

@tale I did some test and watching package-b/dist actually will trigger the rebuild of the package using it.

# in package a
tsup --watch . --watch "../package-b/dist/**"

so I think for now it could be a workaround until we automatically do that

@ilijaNL
Copy link

ilijaNL commented Mar 23, 2024

It would be nice to override the default ignore (node_modules)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants