Skip to content

Commit

Permalink
Bump core frontend to a09d712 nad simplify build scripts (#671)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus authored Jun 30, 2023
1 parent 9813214 commit 0ef92e2
Show file tree
Hide file tree
Showing 10 changed files with 142 additions and 442 deletions.
2 changes: 1 addition & 1 deletion homeassistant-frontend
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
"@types/sortablejs": "1.15.1",
"@types/tar": "6.1.5",
"@types/webspeechapi": "0.0.29",
"@typescript-eslint/eslint-plugin": "5.59.11",
"@typescript-eslint/parser": "5.59.11",
"@typescript-eslint/eslint-plugin": "5.60.0",
"@typescript-eslint/parser": "5.60.0",
"@web/dev-server": "0.1.38",
"@web/dev-server-rollup": "0.4.1",
"babel-loader": "9.1.2",
Expand All @@ -69,7 +69,7 @@
"esprima": "4.0.1",
"fancy-log": "2.0.0",
"fs-extra": "11.1.1",
"glob": "10.2.7",
"glob": "10.3.0",
"gulp": "4.0.2",
"gulp-flatmap": "1.0.2",
"gulp-json-transform": "0.4.8",
Expand All @@ -96,7 +96,7 @@
"rollup-plugin-terser": "7.0.2",
"rollup-plugin-visualizer": "5.9.2",
"serve-handler": "6.1.5",
"sinon": "15.1.2",
"sinon": "15.2.0",
"source-map-url": "0.4.1",
"systemjs": "6.14.1",
"tar": "6.1.15",
Expand All @@ -105,7 +105,7 @@
"typescript": "5.1.3",
"vinyl-buffer": "1.0.1",
"vinyl-source-stream": "2.0.0",
"webpack": "5.87.0",
"webpack": "5.88.0",
"webpack-cli": "5.1.4",
"webpack-dev-server": "4.15.1",
"webpack-manifest-plugin": "5.0.0",
Expand All @@ -115,13 +115,13 @@
"dependencies": {
"@babel/runtime": "7.22.5",
"@braintree/sanitize-url": "6.0.2",
"@codemirror/autocomplete": "6.8.0",
"@codemirror/autocomplete": "6.8.1",
"@codemirror/commands": "6.2.4",
"@codemirror/language": "6.8.0",
"@codemirror/legacy-modes": "6.3.2",
"@codemirror/search": "6.5.0",
"@codemirror/state": "6.2.1",
"@codemirror/view": "6.13.2",
"@codemirror/view": "6.14.0",
"@egjs/hammerjs": "2.0.17",
"@formatjs/intl-datetimeformat": "6.10.0",
"@formatjs/intl-displaynames": "6.5.0",
Expand All @@ -140,7 +140,7 @@
"@lit-labs/context": "0.3.3",
"@lit-labs/motion": "1.0.3",
"@lit-labs/virtualizer": "2.0.3",
"@lrnwebcomponents/simple-tooltip": "7.0.2",
"@lrnwebcomponents/simple-tooltip": "7.0.5",
"@material/chips": "=14.0.0-canary.53b3cad2f.0",
"@material/data-table": "=14.0.0-canary.53b3cad2f.0",
"@material/mwc-button": "0.27.0",
Expand All @@ -166,7 +166,7 @@
"@material/mwc-top-app-bar": "0.27.0",
"@material/mwc-top-app-bar-fixed": "0.27.0",
"@material/top-app-bar": "=14.0.0-canary.53b3cad2f.0",
"@material/web": "=1.0.0-pre.10",
"@material/web": "=1.0.0-pre.11",
"@mdi/js": "7.2.96",
"@mdi/svg": "7.2.96",
"@polymer/app-layout": "3.1.0",
Expand Down Expand Up @@ -201,7 +201,7 @@
"fuse.js": "6.6.2",
"google-timezones-json": "1.1.0",
"hls.js": "1.4.6",
"home-assistant-js-websocket": "8.0.1",
"home-assistant-js-websocket": "8.1.0",
"idb-keyval": "6.2.1",
"intl-messageformat": "10.5.0",
"js-yaml": "4.1.0",
Expand Down
4 changes: 2 additions & 2 deletions script/gulp/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import "./clean.js";
import "../../homeassistant-frontend/build-scripts/gulp/compress.js";
import "./entry-html.js";
import "./gather-static.js";
import "./gen-icons-json.js";
import "./locale-data.js";
import "../../homeassistant-frontend/build-scripts/gulp/gen-icons-json.js";
import "../../homeassistant-frontend/build-scripts/gulp/locale-data.js";
import "./paths.cjs";
import "./webpack.cjs";

Expand Down
88 changes: 4 additions & 84 deletions script/gulp/bundle.cjs
Original file line number Diff line number Diff line change
@@ -1,90 +1,6 @@
const path = require("path");
const paths = require("./paths.cjs");

const haBundle = require("../../homeassistant-frontend/build-scripts/bundle.cjs");

module.exports.ignorePackages = ({ latestBuild }) => haBundle.ignorePackages({ latestBuild });
module.exports.htmlMinifierOptions = haBundle.htmlMinifierOptions;
module.exports.terserOptions = ({ latestBuild, isTestBuild }) =>
haBundle.terserOptions({ latestBuild, isTestBuild });

// Files from NPM packages that we should replace with empty file
module.exports.emptyPackages = ({ latestBuild }) =>
[
// Contains all color definitions for all material color sets.
// We don't use it
require.resolve("@polymer/paper-styles/color.js"),
require.resolve("@polymer/paper-styles/default-theme.js"),
// Loads stuff from a CDN
require.resolve("@polymer/font-roboto/roboto.js"),
require.resolve("@vaadin/vaadin-material-styles/typography.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.home_assistant_frontend_root, "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.
require.resolve(path.resolve(paths.home_assistant_frontend_root, "src/components/ha-icon.ts")),
require.resolve(
path.resolve(paths.home_assistant_frontend_root, "src/components/ha-icon-picker.ts")
),
].filter(Boolean);

module.exports.definedVars = ({ isProdBuild, latestBuild }) => ({
...haBundle.definedVars({ isProdBuild, latestBuild }),
// While this is not the supervisor, it functions in the same maner and we use this to signal components to behave differently.
__SUPERVISOR__: true,
__STATIC_PATH__: `"${paths.app_publicPath}/static/"`,
});

module.exports.babelOptions = ({ latestBuild, isProdBuild, isTestBuild }) => ({
...haBundle.babelOptions({ latestBuild, isProdBuild, isTestBuild }),
plugins: [
[
path.resolve(
paths.home_assistant_frontend_root,
"build-scripts/babel-plugins/inline-constants-plugin.cjs"
),
{
modules: ["@mdi/js"],
ignoreModuleNotFound: true,
},
],
// Minify template literals for production
isProdBuild && [
"template-html-minifier",
{
modules: {
lit: [
"html",
{ name: "svg", encapsulation: "svg" },
{ name: "css", encapsulation: "style" },
],
"@polymer/polymer/lib/utils/html-tag": ["html"],
},
strictCSS: true,
htmlMinifier: module.exports.htmlMinifierOptions,
failOnError: true, // we can turn this off in case of false positives
},
],
// Import helpers and regenerator from runtime package
[
"@babel/plugin-transform-runtime",
{
version: require(path.resolve(paths.root_dir, "package.json")).dependencies[
"@babel/runtime"
],
},
],
// Support some proposals still in TC39 process
["@babel/plugin-proposal-decorators", { decoratorsBeforeExport: true }],
].filter(Boolean),
});

const nameSuffix = (latestBuild) => (latestBuild ? "-latest" : "-es5");

const outputPath = (outputRoot, latestBuild) =>
Expand All @@ -106,6 +22,10 @@ module.exports.config = {
latestBuild,
isStatsBuild,
isTestBuild,
defineOverlay: {
__SUPERVISOR__: true,
__STATIC_PATH__: `"${paths.app_publicPath}/static/"`,
},
};
},
};
5 changes: 4 additions & 1 deletion script/gulp/entry-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import gulp from "gulp";
import { minify } from "html-minifier-terser";
import template from "lodash.template";
import path from "path";
import { htmlMinifierOptions, terserOptions } from "./bundle.cjs";
import {
htmlMinifierOptions,
terserOptions,
} from "../../homeassistant-frontend/build-scripts/bundle.cjs";
import env from "./env.cjs";
import paths from "./paths.cjs";

Expand Down
4 changes: 4 additions & 0 deletions script/gulp/gather-static.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import gulp from "gulp";
import path from "path";
import paths from "./paths.cjs";

const haBuildPath = (...parts) =>
path.resolve(paths.home_assistant_frontend_root, "build", ...parts);
const npmPath = (...parts) => path.resolve(paths.root_dir, "node_modules", ...parts);
const rootPath = (...parts) => path.resolve(paths.root_dir, ...parts);
const buildPath = (...parts) => path.resolve(paths.root_dir, "build", ...parts);
Expand All @@ -28,6 +30,8 @@ function copyFonts(staticDir) {
gulp.task("copy-static-app", async () => {
const staticDir = paths.app_output_static;
fs.copySync(rootPath("public"), paths.app_output_root);
fs.copySync(rootPath("public"), paths.app_output_root);
fs.copySync(buildPath("mdi"), haBuildPath("mdi"));

copyFonts(staticDir);
copyLocaleData(staticDir);
Expand Down
19 changes: 0 additions & 19 deletions script/gulp/gen-icons-json.js

This file was deleted.

60 changes: 0 additions & 60 deletions script/gulp/locale-data.js

This file was deleted.

Loading

0 comments on commit 0ef92e2

Please sign in to comment.