Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updare HA FE to 20231129.1 #115

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
compressionLevel: mixed

defaultSemverRangePrefix: ""

nodeLinker: node-modules
enableGlobalCache: false

plugins:
- path: homeassistant-frontend/.yarn/plugins/@yarnpkg/plugin-typescript.cjs
spec: "@yarnpkg/plugin-typescript"
- path: homeassistant-frontend/.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"
nodeLinker: node-modules

yarnPath: homeassistant-frontend/.yarn/releases/yarn-3.6.4.cjs
yarnPath: homeassistant-frontend/.yarn/releases/yarn-4.0.2.cjs
56 changes: 56 additions & 0 deletions build-scripts/babel-plugins/custom-polyfill-plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import defineProvider from "@babel/helper-define-polyfill-provider";

// List of polyfill keys with supported browser targets for the functionality
const PolyfillSupport = {
fetch: {
android: 42,
chrome: 42,
edge: 14,
firefox: 39,
ios: 10.3,
opera: 29,
opera_mobile: 29,
safari: 10.1,
samsung: 4.0,
},
proxy: {
android: 49,
chrome: 49,
edge: 12,
firefox: 18,
ios: 10.0,
opera: 36,
opera_mobile: 36,
safari: 10.0,
samsung: 5.0,
},
};

// Map of global variables and/or instance and static properties to the
// corresponding polyfill key and actual module to import
const polyfillMap = {
global: {
Proxy: { key: "proxy", module: "proxy-polyfill" },
fetch: { key: "fetch", module: "unfetch/polyfill" },
},
instance: {},
static: {},
};

// Create plugin using the same factory as for CoreJS
export default defineProvider(
({ createMetaResolver, debug, shouldInjectPolyfill }) => {
const resolvePolyfill = createMetaResolver(polyfillMap);
return {
name: "HA Custom",
polyfills: PolyfillSupport,
usageGlobal(meta, utils) {
const polyfill = resolvePolyfill(meta);
if (polyfill && shouldInjectPolyfill(polyfill.desc.key)) {
debug(polyfill.desc.key);
utils.injectGlobalImport(polyfill.desc.module);
}
},
};
}
);
32 changes: 22 additions & 10 deletions build-scripts/bundle.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ const env = require("./env.cjs");
const paths = require("./paths.cjs");

// Files from NPM Packages that should not be imported
module.exports.ignorePackages = ({ latestBuild }) => [
// Part of yaml.js and only used for !!js functions that we don't use
require.resolve("esprima"),
];
module.exports.ignorePackages = () => [];

// Files from NPM packages that we should replace with empty file
module.exports.emptyPackages = ({ latestBuild, isHassioBuild }) =>
Expand All @@ -26,8 +23,6 @@ module.exports.emptyPackages = ({ latestBuild, isHassioBuild }) =>
require.resolve(
path.resolve(paths.polymer_dir, "homeassistant-frontend/src/resources/compatibility.ts")
),
// This polyfill is loaded in workers to support ES5, filter it out.
latestBuild && require.resolve("proxy-polyfill/src/index.js"),
// Icons in supervisor conflict with icons in HA so we don't load.
isHassioBuild &&
require.resolve(
Expand Down Expand Up @@ -76,14 +71,12 @@ module.exports.babelOptions = ({ latestBuild }) => ({
setSpreadProperties: true,
},
browserslistEnv: latestBuild ? "modern" : "legacy",
// Must be unambiguous because some dependencies are CommonJS only
sourceType: "unambiguous",
presets: [
[
"@babel/preset-env",
{
useBuiltIns: latestBuild ? false : "entry",
corejs: latestBuild ? false : { version: "3.33", proposals: true },
useBuiltIns: latestBuild ? false : "usage",
corejs: latestBuild ? false : "3.33",
bugfixes: true,
shippedProposals: true,
},
Expand All @@ -98,6 +91,13 @@ module.exports.babelOptions = ({ latestBuild }) => ({
ignoreModuleNotFound: true,
},
],
[
path.resolve(
paths.polymer_dir,
"build-scripts/babel-plugins/custom-polyfill-plugin.js"
),
{ method: "usage-global" },
],
// Import helpers and regenerator from runtime package
[
"@babel/plugin-transform-runtime",
Expand All @@ -111,6 +111,18 @@ module.exports.babelOptions = ({ latestBuild }) => ({
/node_modules[\\/]core-js/,
/node_modules[\\/]webpack[\\/]buildin/,
],
overrides: [
{
// Use unambiguous for dependencies so that require() is correctly injected into CommonJS files
// Exclusions are needed in some cases where ES modules have no static imports or exports, such as polyfills
sourceType: "unambiguous",
include: /\/node_modules\//,
exclude: [
"element-internals-polyfill",
"@?lit(?:-labs|-element|-html)?",
].map((p) => new RegExp(`/node_modules/${p}/`)),
},
],
});

const outputPath = (outputRoot, latestBuild) =>
Expand Down
2 changes: 1 addition & 1 deletion homeassistant-frontend
Loading