This library provides a Java binding for Esbuild, allowing you to invoke Esbuild directly from Java.
It uses Deno under the hood to run Esbuild and its plugins.
Originally created for Quarkus via quarkiverse/quarkus-web-bundler,
it can also be used standalone or through Maven with the mvnpm/esbuild-maven-plugin.
- Native Java API for Esbuild
- Supports plugins via Deno
- Works with Quarkus or standalone
- Maven integration available
public class Main {
public static void main(String[] args) throws IOException {
String entrypoint = args.length > 0 ? args[0] : "example.js";
System.out.println("Using entrypoint: " + entrypoint);
BundleOptions options = BundleOptions.builder()
.addEntryPoint(Path.of(entrypoint))
.build();
BundleResult result = Bundler.bundle(options, true);
System.out.println(result.logs());
System.out.println("Bundling output: " + result.dist());
}
}You can also bundle JavaScript files that depend on WebJars or mvnpm packages:
BundleOptions options = BundleOptions.builder()
.withDependencies(dependencies) // List of WebJar or mvnpm JARs
.addEntryPoint(Path.of(entrypoint))
.build();
BundleResult result = Bundler.bundle(options, true);