Move compatibility to static polyfill handling (#24775)
* Move compatibility to static polyfill handling * Move compatibility to static polyfill handling * Prettierpull/24758/head
parent
e27b97abc0
commit
386b8ba747
|
@ -18,7 +18,7 @@ module.exports.sourceMapURL = () => {
|
||||||
module.exports.ignorePackages = () => [];
|
module.exports.ignorePackages = () => [];
|
||||||
|
|
||||||
// Files from NPM packages that we should replace with empty file
|
// Files from NPM packages that we should replace with empty file
|
||||||
module.exports.emptyPackages = ({ latestBuild, isHassioBuild }) =>
|
module.exports.emptyPackages = ({ isHassioBuild }) =>
|
||||||
[
|
[
|
||||||
// Contains all color definitions for all material color sets.
|
// Contains all color definitions for all material color sets.
|
||||||
// We don't use it
|
// We don't use it
|
||||||
|
@ -28,12 +28,6 @@ module.exports.emptyPackages = ({ latestBuild, isHassioBuild }) =>
|
||||||
require.resolve("@polymer/font-roboto/roboto.js"),
|
require.resolve("@polymer/font-roboto/roboto.js"),
|
||||||
require.resolve("@vaadin/vaadin-material-styles/typography.js"),
|
require.resolve("@vaadin/vaadin-material-styles/typography.js"),
|
||||||
require.resolve("@vaadin/vaadin-material-styles/font-icons.js"),
|
require.resolve("@vaadin/vaadin-material-styles/font-icons.js"),
|
||||||
// Compatibility not needed for latest builds
|
|
||||||
latestBuild &&
|
|
||||||
// wrapped in require.resolve so it blows up if file no longer exists
|
|
||||||
require.resolve(
|
|
||||||
path.resolve(paths.polymer_dir, "src/resources/compatibility.ts")
|
|
||||||
),
|
|
||||||
// Icons in supervisor conflict with icons in HA so we don't load.
|
// Icons in supervisor conflict with icons in HA so we don't load.
|
||||||
isHassioBuild &&
|
isHassioBuild &&
|
||||||
require.resolve(
|
require.resolve(
|
||||||
|
|
|
@ -59,6 +59,11 @@ function copyPolyfills(staticDir) {
|
||||||
npmPath("@webcomponents/webcomponentsjs/webcomponents-bundle.js.map"),
|
npmPath("@webcomponents/webcomponentsjs/webcomponents-bundle.js.map"),
|
||||||
staticPath("polyfills/")
|
staticPath("polyfills/")
|
||||||
);
|
);
|
||||||
|
// Lit polyfill support
|
||||||
|
fs.copySync(
|
||||||
|
npmPath("lit/polyfill-support.js"),
|
||||||
|
path.join(staticPath("polyfills/"), "lit-polyfill-support.js")
|
||||||
|
);
|
||||||
|
|
||||||
// dialog-polyfill css
|
// dialog-polyfill css
|
||||||
copyFileDir(
|
copyFileDir(
|
||||||
|
|
|
@ -155,9 +155,7 @@ const createRspackConfig = ({
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
new rspack.NormalModuleReplacementPlugin(
|
new rspack.NormalModuleReplacementPlugin(
|
||||||
new RegExp(
|
new RegExp(bundle.emptyPackages({ isHassioBuild }).join("|")),
|
||||||
bundle.emptyPackages({ latestBuild, isHassioBuild }).join("|")
|
|
||||||
),
|
|
||||||
path.resolve(paths.polymer_dir, "src/util/empty.js")
|
path.resolve(paths.polymer_dir, "src/util/empty.js")
|
||||||
),
|
),
|
||||||
!isProdBuild && new LogStartCompilePlugin(),
|
!isProdBuild && new LogStartCompilePlugin(),
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
// Compat needs to be first import
|
|
||||||
import "../../src/resources/compatibility";
|
|
||||||
import { customElement } from "lit/decorators";
|
import { customElement } from "lit/decorators";
|
||||||
import { isNavigationClick } from "../../src/common/dom/is-navigation-click";
|
import { isNavigationClick } from "../../src/common/dom/is-navigation-click";
|
||||||
import { navigate } from "../../src/common/navigate";
|
import { navigate } from "../../src/common/navigate";
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
// Compat needs to be first import
|
|
||||||
import "../../src/resources/compatibility";
|
|
||||||
import "./hassio-main";
|
import "./hassio-main";
|
||||||
|
|
||||||
import("../../src/resources/ha-style");
|
import("../../src/resources/ha-style");
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
export const webComponentsSupported =
|
export const webComponentsSupported = "attachShadow" in Element.prototype;
|
||||||
"customElements" in window && "content" in document.createElement("template");
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
// Compat needs to be first import
|
|
||||||
import "../resources/compatibility";
|
|
||||||
import "@webcomponents/scoped-custom-element-registry/scoped-custom-element-registry.min";
|
import "@webcomponents/scoped-custom-element-registry/scoped-custom-element-registry.min";
|
||||||
import "../layouts/home-assistant";
|
import "../layouts/home-assistant";
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
// Compat needs to be first import
|
|
||||||
import "../resources/compatibility";
|
|
||||||
import "../auth/ha-authorize";
|
import "../auth/ha-authorize";
|
||||||
|
|
||||||
import("../resources/ha-style");
|
import("../resources/ha-style");
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
// Compat needs to be first import
|
|
||||||
import "../resources/compatibility";
|
|
||||||
|
|
||||||
import type { CSSResult } from "lit";
|
import type { CSSResult } from "lit";
|
||||||
import { fireEvent } from "../common/dom/fire_event";
|
import { fireEvent } from "../common/dom/fire_event";
|
||||||
import { isNavigationClick } from "../common/dom/is-navigation-click";
|
import { isNavigationClick } from "../common/dom/is-navigation-click";
|
||||||
|
@ -67,9 +64,10 @@ function initialize(
|
||||||
let start: Promise<unknown> = Promise.resolve();
|
let start: Promise<unknown> = Promise.resolve();
|
||||||
|
|
||||||
if (!webComponentsSupported) {
|
if (!webComponentsSupported) {
|
||||||
start = start.then(() =>
|
start = start.then(() => {
|
||||||
loadJS(`${__STATIC_PATH__}polyfills/webcomponents-bundle.js`)
|
loadJS(`${__STATIC_PATH__}polyfills/webcomponents-bundle.js`);
|
||||||
);
|
loadJS(`${__STATIC_PATH__}polyfills/lit-polyfill-support.js`);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (__BUILD__ === "legacy") {
|
if (__BUILD__ === "legacy") {
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
// Compat needs to be first import
|
|
||||||
import "../resources/compatibility";
|
|
||||||
import "../onboarding/ha-onboarding";
|
import "../onboarding/ha-onboarding";
|
||||||
|
|
||||||
import("../resources/ha-style");
|
import("../resources/ha-style");
|
||||||
|
|
|
@ -8,13 +8,9 @@
|
||||||
return document.head.appendChild(script);
|
return document.head.appendChild(script);
|
||||||
}
|
}
|
||||||
window.polymerSkipLoadingFontRoboto = true;
|
window.polymerSkipLoadingFontRoboto = true;
|
||||||
if (
|
if (!("attachShadow" in Element.prototype)) {
|
||||||
!(
|
|
||||||
"customElements" in window &&
|
|
||||||
"content" in document.createElement("template")
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
_ls("/static/polyfills/webcomponents-bundle.js", true);
|
_ls("/static/polyfills/webcomponents-bundle.js", true);
|
||||||
|
_ls("/static/polyfills/lit-polyfill-support.js", true);
|
||||||
}
|
}
|
||||||
// Modern browsers are detected primarily using the user agent string.
|
// Modern browsers are detected primarily using the user agent string.
|
||||||
// A feature detection which roughly lines up with the modern targets is used
|
// A feature detection which roughly lines up with the modern targets is used
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
// Caution before editing - For latest builds, this module is replaced with emptiness and thus not imported (see build-scripts/bundle.js)
|
|
||||||
import "lit/polyfill-support";
|
|
Loading…
Reference in New Issue