Package com.vaadin.flow.internal
Class BundleUtils
java.lang.Object
com.vaadin.flow.internal.BundleUtils
Utility class for bundle operations.
For internal use only. May be renamed or removed in a future release.
- Since:
- 25.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe key of the stats.json entry that lists the identifiers of the functions the bundle registers for JavaScript definitions, event data and event filters. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckJsFunctionsBundled(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@JsModuleof a component is reported.static StringgetChunkHash(List<String> chunkLines) Calculates a hash for bundle JavaScript chunk containing given string lines.static StringgetChunkId(Class<? extends Component> componentClass) Gets the id for a chunk defined by the given class.static StringgetChunkId(String className) Gets the id for a chunk defined by the given class.static booleanReturns whether the application uses pre-compiled production bundle or a custom bundle.Loads stats.json from the classpath (from the production bundle) and returns the "bundleImports" part of it.
-
Field Details
-
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
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
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
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
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:
truein case of pre-compiled bundle,falseotherwise
-
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@JsModuleof 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
@JsStringFallbackinterface 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@Useswould not help.- Parameters:
declaringType- the JavaScript definition or event type that declares the functions, notnullfunctionIds- the identifiers of the functions that the class declares, asked for only when the class is checked, notnull
-