Class EsbuildService
A client for a long-lived esbuild --service process. This is the same channel esbuild's
own JS API uses, so one process serves every transform and build for the life of the app.
The process is (re)started lazily, so a crash only costs the requests that were in flight.
public sealed class EsbuildService : IAsyncDisposable
- Inheritance
-
EsbuildService
- Implements
- Inherited Members
Constructors
EsbuildService(string, ILogger<EsbuildService>?)
public EsbuildService(string binaryPath, ILogger<EsbuildService>? logger = null)
Parameters
binaryPathstringloggerILogger<EsbuildService>
Methods
BuildAsync(EsbuildBuildOptions, CancellationToken)
Runs a one-shot build, like esbuild.build.
public Task<EsbuildBuildResult> BuildAsync(EsbuildBuildOptions options, CancellationToken cancellationToken = default)
Parameters
optionsEsbuildBuildOptionscancellationTokenCancellationToken
Returns
DisposeAsync()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
public ValueTask DisposeAsync()
Returns
- ValueTask
A task that represents the asynchronous dispose operation.
TransformAsync(string, IEnumerable<string>, CancellationToken)
Transforms a single file's contents, like esbuild.transform.
public Task<EsbuildTransformResult> TransformAsync(string input, IEnumerable<string> flags, CancellationToken cancellationToken = default)
Parameters
inputstringflagsIEnumerable<string>cancellationTokenCancellationToken