Skip to content

mvnpm/esbuild-java

Repository files navigation

esbuild-java

Build Status usefulness 100% Maven Central Apache License, Version 2.0, January 2004

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.

Key Features

  • Native Java API for Esbuild
  • Supports plugins via Deno
  • Works with Quarkus or standalone
  • Maven integration available

Quick Example

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());
    }
}

Bundling with Dependencies

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);

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published