This is a wrapper around the esbuild executable, so that you can invoke it from java.
// create the command line parameters
final EsBuildConfig esBuildConfig = EsBuildConfig.builder().bundle().entryPoint(new String[]{"main.js"}).outDir("dist").build();
String workingDirectory = System.getProperty("user.dir");
// use the resolver to get the esbuild executable
final Path esBuildExec = new ExecutableResolver().resolve("0.17.1");
// it will use a bundled version of es build or download the right version
//execute
final ExecuteResult executeResult = new Execute(Paths.get(workingDirectory), esBuildExec.toFile()).executeAndWait();
System.out.println(executeResult.output());
Another option is to use java -jar
e.g.
java -jar target/esbuild-java-*-jar-with-dependencies.jar --help
Additionally, it has a utility to bundle a javascript file with webjar or mvnpm dependencies:
final BundleOptions bundleOptions = new BundleOptions.builder().withDependencies(dependencies)
.withEntry(entry).build();
final BundleResult result = Bundler.bundle(bundleOptions, true);
Dependencies are a list of either webjar or mvnpm jars. Returned is the folder that contains the result of the transformation.