Search in sources :

Example 11 with FallbackChunk

use of com.vaadin.flow.server.frontend.FallbackChunk in project flow by vaadin.

the class UIInternals method addFallbackDependencies.

private void addFallbackDependencies(DependencyInfo dependency) {
    if (isFallbackChunkLoaded) {
        return;
    }
    VaadinContext context = ui.getSession().getService().getContext();
    FallbackChunk chunk = context.getAttribute(FallbackChunk.class);
    if (chunk == null) {
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Fallback chunk is not available, skipping fallback dependencies load");
        }
        return;
    }
    Set<String> modules = chunk.getModules();
    Set<CssImportData> cssImportsData = chunk.getCssImports();
    if (modules.isEmpty() && cssImportsData.isEmpty()) {
        getLogger().debug("Fallback chunk is empty, skipping fallback dependencies load");
        return;
    }
    List<CssImport> cssImports = dependency.getCssImports();
    List<JavaScript> javaScripts = dependency.getJavaScripts();
    List<JsModule> jsModules = dependency.getJsModules();
    if (jsModules.stream().map(JsModule::value).anyMatch(modules::contains)) {
        loadFallbackChunk();
        return;
    }
    if (javaScripts.stream().map(JavaScript::value).anyMatch(modules::contains)) {
        loadFallbackChunk();
        return;
    }
    if (cssImports.stream().map(this::buildData).anyMatch(cssImportsData::contains)) {
        loadFallbackChunk();
        return;
    }
}
Also used : JsModule(com.vaadin.flow.component.dependency.JsModule) CssImport(com.vaadin.flow.component.dependency.CssImport) VaadinContext(com.vaadin.flow.server.VaadinContext) FallbackChunk(com.vaadin.flow.server.frontend.FallbackChunk) JavaScript(com.vaadin.flow.component.dependency.JavaScript) CssImportData(com.vaadin.flow.server.frontend.FallbackChunk.CssImportData)

Aggregations

FallbackChunk (com.vaadin.flow.server.frontend.FallbackChunk)11 Map (java.util.Map)3 Properties (java.util.Properties)3 Test (org.junit.Test)3 VaadinContext (com.vaadin.flow.server.VaadinContext)2 CssImportData (com.vaadin.flow.server.frontend.FallbackChunk.CssImportData)2 File (java.io.File)2 ServletContext (javax.servlet.ServletContext)2 CssImport (com.vaadin.flow.component.dependency.CssImport)1 JavaScript (com.vaadin.flow.component.dependency.JavaScript)1 JsModule (com.vaadin.flow.component.dependency.JsModule)1 Lookup (com.vaadin.flow.di.Lookup)1 ResourceProvider (com.vaadin.flow.di.ResourceProvider)1 DeploymentConfiguration (com.vaadin.flow.function.DeploymentConfiguration)1 ExecutionFailedException (com.vaadin.flow.server.ExecutionFailedException)1 VaadinService (com.vaadin.flow.server.VaadinService)1 VaadinServletRequest (com.vaadin.flow.server.VaadinServletRequest)1 ApplicationConfiguration (com.vaadin.flow.server.startup.ApplicationConfiguration)1 DefaultApplicationConfigurationFactory (com.vaadin.flow.server.startup.DefaultApplicationConfigurationFactory)1 SpringInstantiatorTest (com.vaadin.flow.spring.instantiator.SpringInstantiatorTest)1