egoist / tsup

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

parallel: false (or formatsInParallell: false) #912

Open ComLock opened 1 year ago

ComLock commented 1 year ago

One of Esbuild's Design principles is to Maximize parallelism https://github.com/evanw/esbuild/blob/main/docs/architecture.md#design-principles

Which is great, and typically carries over into how people are writing esbuild plugins.

However when you use tsup and with build for multiple formats ['cjs', 'esm']: tsbuild runs the same esbuild-plugin, twice in parrallell.

I suspect esbuild-plugin developers don't image that happening, since they are developing for esbuild and not tsup.

I've run into a problem, because two copies of the same esbuild-plugin are writing to the same file, leading to a corrupt file: https://github.com/jfortunato/esbuild-plugin-manifest/pull/14

Perhaps there should be a generic solution in tsup to prevent this from happening?

Upvote & Fund

Fund with Polar

ComLock commented 1 year ago

esbuild has now documented how to build for multiple formats: https://github.com/jfortunato/esbuild-plugin-manifest#multiple-formats

Notice the awaits, aka no parallell...