Is there a way to get the `result` of `esbuild` when using the `build`api?
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 275
- PR merge metrics
- No merged PRs in 30d
Description
```ts
function build(_options: Options): Promise
```
I've read the `tsup` documentation carefully, but still haven't found a way to read the `result` of `esbuild`. The closest method so far is to obtain the `code` string through the `renderChunk` method of `plugin`.
```ts
type RenderChunk = (this: PluginContext, code: string, chunkInfo: ChunkInfo) => MaybePromise<{
code: string;
map?: object | string | SourceMap$1 | null;
} | undefined | null | void>;
type Plugin = {
name: string;
esbuildOptions?: ModifyEsbuildOptions;
buildStart?: BuildStart;
renderChunk?: RenderChunk;
buildEnd?: BuildEnd;
};
```
It's also possible that I missed some important documentation by mistake. If there is already a way to do this please feel free to correct me. Thanks. 🌹
Get whether the `build` method can be supported to return the `result` of `esbuild`, like this:
```ts
import { type BuildResult } from "esbuild";
function build(_options: Options): Promise;
```
If possible I would like to submit a `PR` to support this feature. Of course there may be a better way, please feel free to let me know. Thanks.
Contributor guide
Research direction
Start by tracing tsup's build API and how it invokes esbuild, then check the public TypeScript types for build and BuildResult. Done means the build API exposes the esbuild result as requested, with its return type and behavior documented or covered by the existing test structure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100