Record Class DependencyOptions

java.lang.Object
java.lang.Record
com.google.javascript.jscomp.DependencyOptions
Record Components:
mode - Returns the dependency management mode.
entryPoints - Returns the list of explicit entry points.
All Implemented Interfaces:
Serializable

@Immutable public record DependencyOptions(DependencyOptions.DependencyMode mode, com.google.common.collect.ImmutableList<ModuleIdentifier> entryPoints) extends Record implements Serializable
Options for how to manage dependencies between input files.

Dependency information is pulled out from the JS code by looking for import and export primitives (like ES import and export statements, Closure Library's goog.module, goog.provide and goog.require calls, or CommonJS require calls). The compiler can optionally use this information to sort input files in dependency order and/or prune unnecessary input files.

Also see CodingConvention.extractClassNameIfProvide(Node, Node) and CodingConvention.extractClassNameIfRequire(Node, Node), which affect what the compiler considers to be goog.provide and goog.require statements.

See Also:
  • Constructor Details

    • DependencyOptions

      public DependencyOptions(DependencyOptions.DependencyMode mode, com.google.common.collect.ImmutableList<ModuleIdentifier> entryPoints)
      Creates an instance of a DependencyOptions record class.
      Parameters:
      mode - the value for the mode record component
      entryPoints - the value for the entryPoints record component
  • Method Details

    • getMode

      @InlineMe(replacement="this.mode()") public DependencyOptions.DependencyMode getMode()
    • getEntryPoints

      @InlineMe(replacement="this.entryPoints()") public com.google.common.collect.ImmutableList<ModuleIdentifier> getEntryPoints()
    • needsManagement

      public boolean needsManagement()
      Returns whether dependency management is enabled.
    • shouldSort

      public boolean shouldSort()
      Returns whether files should be sorted.

      If true, the input files should be sorted in dependency order. Otherwise, input files should not be reordered.

    • shouldPrune

      public boolean shouldPrune()
      Returns whether files should be pruned.

      If true, an input file should be excluded from the compilation if it is not a transitive dependency of an entry point. Otherwise, all input files should be included.

    • shouldDropMoochers

      public boolean shouldDropMoochers()
      Returns whether moochers should be dropped.

      A moocher is a strong file that does not goog.provide a namespace and is not a goog.module, ES module or CommonJS module. Weak files are never considered moochers.

      If true, moochers should not be considered implicit entry points.

    • none

      public static DependencyOptions none()
    • sortOnly

      public static DependencyOptions sortOnly()
    • pruneLegacyForEntryPoints

      @InlineMe(replacement="new DependencyOptions(DependencyMode.PRUNE_LEGACY, ImmutableList.copyOf(entryPoints))", imports={"com.google.common.collect.ImmutableList","com.google.javascript.jscomp.DependencyOptions","com.google.javascript.jscomp.DependencyOptions.DependencyMode"}) @Deprecated public static DependencyOptions pruneLegacyForEntryPoints(Iterable<ModuleIdentifier> entryPoints)
      Deprecated.
      Prefer pruneForEntryPoints(Iterable) with a complete list of entry points.
      Returns a DependencyOptions using the DependencyOptions.DependencyMode.PRUNE_LEGACY mode with the given entry points.
    • pruneAllowNoEntryPoints

      public static DependencyOptions pruneAllowNoEntryPoints(Iterable<ModuleIdentifier> entryPoints)
      Returns a DependencyOptions using the DependencyOptions.DependencyMode.PRUNE mode with the given entry points.
    • pruneForEntryPoints

      public static DependencyOptions pruneForEntryPoints(Iterable<ModuleIdentifier> entryPoints)
      Returns a DependencyOptions using the DependencyOptions.DependencyMode.PRUNE mode with the given entry points.
    • fromFlags

      public static @Nullable DependencyOptions fromFlags(@Nullable DependencyOptions.DependencyMode dependencyModeFlag, List<String> entryPointFlag, List<String> closureEntryPointFlag, String commonJsEntryModuleFlag, boolean manageClosureDependenciesFlag, boolean onlyClosureDependenciesFlag)
      A helper function for validating dependency management flags and converting them into a DependencyOptions object.

      Returns null when no dependency management flags have been specified.

      TODO(tjgq): Simplify this once we deprecate and remove all legacy flags and standardize on --dependency_mode and --entry_point.

    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • mode

      Returns the value of the mode record component.
      Returns:
      the value of the mode record component
    • entryPoints

      public com.google.common.collect.ImmutableList<ModuleIdentifier> entryPoints()
      Returns the value of the entryPoints record component.
      Returns:
      the value of the entryPoints record component