use of com.vaadin.flow.component.WebComponents in project flow by vaadin.
the class BootstrapHandler method appendWebComponentsPolyfills.
private static void appendWebComponentsPolyfills(Element head, BootstrapContext context) {
Optional<WebComponents> webComponents = AnnotationReader.getAnnotationFor(context.getUI().getClass(), WebComponents.class);
DeploymentConfiguration config = context.getSession().getConfiguration();
String webComponentsPolyfillBase = config.getWebComponentsPolyfillBase().orElse(null);
if (webComponentsPolyfillBase == null) {
return;
}
assert webComponentsPolyfillBase.endsWith("/");
boolean loadEs5Adapter = config.getBooleanProperty(Constants.LOAD_ES5_ADAPTERS, webComponents.map(WebComponents::loadEs5Adapter).orElse(true));
if (loadEs5Adapter && !context.getSession().getBrowser().isEs6Supported()) {
// This adapter is required since lots of our current customers use
// polymer-cli to transpile sources,
// this tool adds babel-helpers dependency into each file, see:
// https://github.com/Polymer/polymer-cli/blob/master/src/build/build.ts#L64
// and
// https://github.com/Polymer/polymer-cli/blob/master/src/build/optimize-streams.ts#L119
head.appendChild(createInlineJavaScriptElement(BABEL_HELPERS_JS));
}
head.appendChild(createJavaScriptElement(context.getUriResolver().resolveVaadinUri(webComponentsPolyfillBase + "webcomponents-loader.js"), false));
}
Aggregations