Skip to content

mvnpm/esbuild-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

esbuild-java

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

This is a small wrapper around the esbuild executable, so that you can invoke it from java.

// create the command line parameters 
final EsBuildConfig esBuildConfig = new EsBuildConfigBuilder().bundle().entryPoint("main.js").outDir("dist").build();

// 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
new Execute(esBuildExec.toFile(), esBuildConfig);

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 BundleOptionsBuilder().withDependencies(dependencies)
        .withEntry(entry).build();
final Path path = 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.