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

Automatically bundle private packages from workspace [feature request] #1251

Open
DesselBane opened this issue Nov 20, 2024 · 2 comments
Open

Comments

@DesselBane
Copy link

DesselBane commented Nov 20, 2024

Context

I work in a mono repo which has a similar setup to this:

  • @repo/root
    • @my-company/my-awesome-package (public)
      • dependency: @repo/my-helper-package
    • @repo/my-helper-package (private)

I want to bundle and publish @my-company/my-awesome-package.

How it currently works

If I bundle with tsup it will not bundle @repo/my-helper-package in my output and if that output then is pushed to a registry the package is broken.

Currently I have the following line in my tsup.config.ts => noExternal: [/^@repo.*/], which will include all packages which start with @repo into the bundle.

What I would like to do

It would be cool if tsup has a config setting called something like bundlePrivatePackages: boolean. If its false it works like it does now. If its true though tsup would go and inspect the package.json file of imported packages and check if the package has "private": true set, if so it would include it in the output bundle if not leave the import statement.

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
@methompson
Copy link

I recently ran into this issue on one of my projects.

I fixed the issue by including my private package as a file-based dependency in package.json. For example, if my private package is located (from the root of the project) in ./packages/my_fun_package, I can add it as a dependency in package.json: "my_fun_package": "file:./packages/my_fun_package".

By doing that, the package is added in node_modules and comes along for the ride when I install using npm i or npm ci.

I also add the path to my tsconfig.json in compilerOptions:

{
  "compilerOptions": {
    "paths": {
      "my_fun_package": [
        "./packages/my_fun_package/*"
      ]
    }
  }
}

This makes sure that when I import in my package (e.g. import { fun } from 'my_fun_package) I don't get any red squiggles. Not sure how well it will work with noExternal, but this functions correctly with my private packages attached to another project.

@g-mero
Copy link

g-mero commented Dec 27, 2024

same issue here

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

3 participants