Class BundleUtils

java.lang.Object
com.vaadin.flow.internal.BundleUtils

public final class BundleUtils extends Object
Utility class for bundle operations.

For internal use only. May be renamed or removed in a future release.

Since:
25.1
  • Field Details

    • JS_DEFINITION_FUNCTION_IDS_STATS_KEY

      public static final String JS_DEFINITION_FUNCTION_IDS_STATS_KEY
      The key of the stats.json entry that lists the identifiers of the functions the bundle registers for JavaScript definitions, event data and event filters.
      See Also:
  • Method Details

    • loadBundleImports

      public static Set<String> loadBundleImports()
      Loads stats.json from the classpath (from the production bundle) and returns the "bundleImports" part of it.
      Returns:
      the bundle imports as a set
    • getChunkId

      public static String getChunkId(Class<? extends Component> componentClass)
      Gets the id for a chunk defined by the given class.
      Parameters:
      componentClass - the class
      Returns:
      an identifier for the component class that does not reveal the name of the component class
    • getChunkId

      public static String getChunkId(String className)
      Gets the id for a chunk defined by the given class.
      Parameters:
      className - the name of the class
      Returns:
      an identifier for the component class that does not reveal the name of the component class
    • getChunkHash

      public static String getChunkHash(List<String> chunkLines)
      Calculates a hash for bundle JavaScript chunk containing given string lines.
      Parameters:
      chunkLines - content of the chunk, collection of string lines
      Returns:
      chunk's hash
    • isPreCompiledProductionBundle

      public static boolean isPreCompiledProductionBundle()
      Returns whether the application uses pre-compiled production bundle or a custom bundle.
      Returns:
      true in case of pre-compiled bundle, false otherwise
    • checkJsFunctionsBundled

      public static void checkJsFunctionsBundled(Class<?> declaringType, Supplier<Collection<String>> functionIds)
      Logs an error when the production bundle does not carry a function that the given class declares JavaScript for, the way a missing @JsModule of a component is reported. The browser can not run such a function, and in production mode it does not log why, so the server says which class is missing and how to get it into the bundle.

      Checks a class once, and only in production mode with a bundle whose stats list the functions it registers.

      Calls that a @JsStringFallback interface stands in for are not checked: the build always keeps those interfaces in the bundle, as they are found by the string an add-on sends rather than through a class reference, so naming them in @Uses would not help.

      Parameters:
      declaringType - the JavaScript definition or event type that declares the functions, not null
      functionIds - the identifiers of the functions that the class declares, asked for only when the class is checked, not null