egoist / tsup

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

Implement incremental rebuilds #615

Open egoist opened 2 years ago

egoist commented 2 years ago

esbuild is so fast that I forgot this is not yet implemented in tsup.

Upvote & Fund

Fund with Polar

vforsh commented 2 years ago

it would be nice to have for DTS builds since tsc is sloooooow

EdieLemoine commented 1 year ago

I've made an ugly but functional workaround because DTS was too slow:

// tsup.config.ts
import {spawnSync} from 'child_process';

export default {
  // your config
  dts: false,
  async onSuccess() {
    spawnSync('tsc', ['--emitDeclarationOnly', '--declaration']);
  },
}

To make this an incremental build, you should have incremental: true in the relevant tsconfig.json, or pass it in spawnSync.

X-Jagger commented 1 year ago

We want this feature, as esbuild already supports it: https://github.com/evanw/esbuild/pull/2816.

In our case, we have some interface generation processes to execute before other esbuild processes, but currently, we have to execute every file, which is very slow. Ideally, we would only handle the changed files, making it much faster.

By the way, thank you for your great job!

coopbri commented 1 year ago

I've made an ugly but functional workaround because DTS was too slow:

// tsup.config.ts
import {spawnSync} from 'child_process';

export default {
  // your config
  dts: false,
  async onSuccess() {
    spawnSync('tsc', ['--emitDeclarationOnly', '--declaration']);
  },
}

To make this an incremental build, you should have incremental: true in the relevant tsconfig.json, or pass it in spawnSync.

@EdieLemoine Proxying the declaration builds to a separate tsc process directly works great, thank you so much! Cut my build times down substantially.

Do you have any clean methods to bundle up the .d.ts files into a single .d.ts file per entry point like tsup does by default, or do you just keep them separate? I tried a few packages, such as dts-bundle-generator and rollup-plugin-ts itself without luck.