egoist / tsup

The simplest and fastest way to bundle your TypeScript libraries.
https://tsup.egoist.dev
MIT License
9.11k stars 218 forks source link

feat: Support share config #756

Open rxliuli opened 1 year ago

rxliuli commented 1 year ago

motivation

In a monorepo, multiple projects need to share the configuration, instead of each project writing its own command line parameters or configuration file, which is actually annoying, it would be nice if there was a way to specify the configuration via a simple option

Existing program

The eslint approach is through the extends option, ref: https://eslint.org/docs/latest/user-guide/configuring/configuration-files#adding-shared-settings prettier can directly point to a package, ref: https://prettier.io/docs/en/configuration.html#sharing-configurations

If you'd like to include this functionality, I'm willing to implement it

Upvote & Fund

Fund with Polar

await-ovo commented 1 year ago

Just curious why not use --config to specify a custom shared config file in a monorepo.

By the way, I like the prettier style too, if the configuration of multiple projects has no difference.

rxliuli commented 1 year ago

The main problem is hierarchy and sharing across monorepo

The problem with the first level is that you need to use a path of the form ../libs/configs/tsup.config.ts, and if you want to have a hint that you must install tsup dependencies at the top level, in multiple different projects, The monorepo directory may be organized differently, which results in a different path to config The second problem is that I do have multiple monorepo, which deal with different issues, but they all contain some libs, such as projects like joplin-utils/liuli-tools/mami , all need to be built with tsup

caoimhebyrne commented 1 year ago

I agree with this feature. It would be very nice instead of having to pass relative --config arguments, it would be nice if we could follow the typescript style for it though: my-package/tsup.config.json:

{
  "entry": ["./src/index.ts"],
  "format": ["cjs, esm"]
}

app/tsup.config.json

{
  "extends": "my-package/tsup.config.json",
  "dts": true
}

And something similar for typescript: my-package-using-ts/tsup.config.ts

import { defineConfig } from "tsup";

export default defineConfig({
  entry: ["./src/index.ts"],
  format: ["cjs", "esm"],
  dts: true,
});

app-using-ts/tsup.config.ts

import { inheritConfig } from "tsup"; // Maybe we could use defineConfig with a different pattern?
import baseConfig from "my-package-using-ts/tsup.config.ts"; // NOTE: Right now, we can't do imports like this (from my testing) 

export default inheritConfig(baseConfig, {...});