io.github.cdklabs.projen.javascript.BundlingOptions Maven / Gradle / Ivy
Show all versions of projen Show documentation
package io.github.cdklabs.projen.javascript;
/**
* (experimental) Options for bundling.
*/
@javax.annotation.Generated(value = "jsii-pacmak/1.105.0 (build 0a2adcb)", date = "2024-11-15T17:03:55.275Z")
@software.amazon.jsii.Jsii(module = io.github.cdklabs.projen.$Module.class, fqn = "projen.javascript.BundlingOptions")
@software.amazon.jsii.Jsii.Proxy(BundlingOptions.Jsii$Proxy.class)
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public interface BundlingOptions extends software.amazon.jsii.JsiiSerializable {
/**
* (experimental) You can mark a file or a package as external to exclude it from your build.
*
* Instead of being bundled, the import will be preserved (using require for
* the iife and cjs formats and using import for the esm format) and will be
* evaluated at run time instead.
*
* This has several uses. First of all, it can be used to trim unnecessary
* code from your bundle for a code path that you know will never be executed.
* For example, a package may contain code that only runs in node but you will
* only be using that package in the browser. It can also be used to import
* code in node at run time from a package that cannot be bundled. For
* example, the fsevents package contains a native extension, which esbuild
* doesn't support.
*
* Default: []
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable java.util.List getExternals() {
return null;
}
/**
* (experimental) Include a source map in the bundle.
*
* Default: false
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable java.lang.Boolean getSourcemap() {
return null;
}
/**
* (experimental) In addition to the bundle:xyz
task, creates bundle:xyz:watch
task which will invoke the same esbuild command with the --watch
flag.
*
* This can be used
* to continusouly watch for changes.
*
* Default: true
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable java.lang.Boolean getWatchTask() {
return null;
}
/**
* @return a {@link Builder} of {@link BundlingOptions}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
static Builder builder() {
return new Builder();
}
/**
* A builder for {@link BundlingOptions}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public static final class Builder implements software.amazon.jsii.Builder {
java.util.List externals;
java.lang.Boolean sourcemap;
java.lang.Boolean watchTask;
/**
* Sets the value of {@link BundlingOptions#getExternals}
* @param externals You can mark a file or a package as external to exclude it from your build.
* Instead of being bundled, the import will be preserved (using require for
* the iife and cjs formats and using import for the esm format) and will be
* evaluated at run time instead.
*
* This has several uses. First of all, it can be used to trim unnecessary
* code from your bundle for a code path that you know will never be executed.
* For example, a package may contain code that only runs in node but you will
* only be using that package in the browser. It can also be used to import
* code in node at run time from a package that cannot be bundled. For
* example, the fsevents package contains a native extension, which esbuild
* doesn't support.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder externals(java.util.List externals) {
this.externals = externals;
return this;
}
/**
* Sets the value of {@link BundlingOptions#getSourcemap}
* @param sourcemap Include a source map in the bundle.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder sourcemap(java.lang.Boolean sourcemap) {
this.sourcemap = sourcemap;
return this;
}
/**
* Sets the value of {@link BundlingOptions#getWatchTask}
* @param watchTask In addition to the bundle:xyz
task, creates bundle:xyz:watch
task which will invoke the same esbuild command with the --watch
flag.
* This can be used
* to continusouly watch for changes.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder watchTask(java.lang.Boolean watchTask) {
this.watchTask = watchTask;
return this;
}
/**
* Builds the configured instance.
* @return a new instance of {@link BundlingOptions}
* @throws NullPointerException if any required attribute was not provided
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@Override
public BundlingOptions build() {
return new Jsii$Proxy(this);
}
}
/**
* An implementation for {@link BundlingOptions}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@software.amazon.jsii.Internal
final class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements BundlingOptions {
private final java.util.List externals;
private final java.lang.Boolean sourcemap;
private final java.lang.Boolean watchTask;
/**
* Constructor that initializes the object based on values retrieved from the JsiiObject.
* @param objRef Reference to the JSII managed object.
*/
protected Jsii$Proxy(final software.amazon.jsii.JsiiObjectRef objRef) {
super(objRef);
this.externals = software.amazon.jsii.Kernel.get(this, "externals", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(java.lang.String.class)));
this.sourcemap = software.amazon.jsii.Kernel.get(this, "sourcemap", software.amazon.jsii.NativeType.forClass(java.lang.Boolean.class));
this.watchTask = software.amazon.jsii.Kernel.get(this, "watchTask", software.amazon.jsii.NativeType.forClass(java.lang.Boolean.class));
}
/**
* Constructor that initializes the object based on literal property values passed by the {@link Builder}.
*/
protected Jsii$Proxy(final Builder builder) {
super(software.amazon.jsii.JsiiObject.InitializationMode.JSII);
this.externals = builder.externals;
this.sourcemap = builder.sourcemap;
this.watchTask = builder.watchTask;
}
@Override
public final java.util.List getExternals() {
return this.externals;
}
@Override
public final java.lang.Boolean getSourcemap() {
return this.sourcemap;
}
@Override
public final java.lang.Boolean getWatchTask() {
return this.watchTask;
}
@Override
@software.amazon.jsii.Internal
public com.fasterxml.jackson.databind.JsonNode $jsii$toJson() {
final com.fasterxml.jackson.databind.ObjectMapper om = software.amazon.jsii.JsiiObjectMapper.INSTANCE;
final com.fasterxml.jackson.databind.node.ObjectNode data = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
if (this.getExternals() != null) {
data.set("externals", om.valueToTree(this.getExternals()));
}
if (this.getSourcemap() != null) {
data.set("sourcemap", om.valueToTree(this.getSourcemap()));
}
if (this.getWatchTask() != null) {
data.set("watchTask", om.valueToTree(this.getWatchTask()));
}
final com.fasterxml.jackson.databind.node.ObjectNode struct = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
struct.set("fqn", om.valueToTree("projen.javascript.BundlingOptions"));
struct.set("data", data);
final com.fasterxml.jackson.databind.node.ObjectNode obj = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
obj.set("$jsii.struct", struct);
return obj;
}
@Override
public final boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
BundlingOptions.Jsii$Proxy that = (BundlingOptions.Jsii$Proxy) o;
if (this.externals != null ? !this.externals.equals(that.externals) : that.externals != null) return false;
if (this.sourcemap != null ? !this.sourcemap.equals(that.sourcemap) : that.sourcemap != null) return false;
return this.watchTask != null ? this.watchTask.equals(that.watchTask) : that.watchTask == null;
}
@Override
public final int hashCode() {
int result = this.externals != null ? this.externals.hashCode() : 0;
result = 31 * result + (this.sourcemap != null ? this.sourcemap.hashCode() : 0);
result = 31 * result + (this.watchTask != null ? this.watchTask.hashCode() : 0);
return result;
}
}
}