From 36285699ac2450789a38d77ce7909cd3031808c2 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 4 Oct 2024 14:12:08 +0100 Subject: [PATCH] Remove more bits surrounding hmr Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- package.json | 2 -- src/vector/devcss.ts | 38 -------------------------------------- src/vector/index.ts | 8 -------- yarn.lock | 13 ------------- 4 files changed, 61 deletions(-) delete mode 100644 src/vector/devcss.ts diff --git a/package.json b/package.json index f0265a8068..67451cd31f 100644 --- a/package.json +++ b/package.json @@ -198,8 +198,6 @@ "raw-loader": "^4.0.2", "rimraf": "^6.0.0", "semver": "^7.5.2", - "string-replace-loader": "3", - "style-loader": "4", "stylelint": "^16.1.0", "stylelint-config-standard": "^36.0.0", "stylelint-scss": "^6.0.0", diff --git a/src/vector/devcss.ts b/src/vector/devcss.ts deleted file mode 100644 index 38cca75ba3..0000000000 --- a/src/vector/devcss.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* -Copyright 2024 New Vector Ltd. -Copyright 2021 The Matrix.org Foundation C.I.C. - -SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only -Please see LICENSE files in the repository root for full details. -*/ - -/** - * This code is removed on production builds. - * - * Webpack's `string-replace-loader` searches for the `use theming` string - * in this specific file, and replaces it with CSS requires statements that - * are specific to the themes we have enabled. - * - * Without this workaround, webpack would import the CSS of all themes, which - * would defeat the purpose of hot-reloading since all themes would be compiled, - * which would result in compilation times on the order of 30s, even on a - * powerful machine. - * - * For more details, see webpack.config.js:184 (string-replace-loader) - */ -if (process.env.NODE_ENV === "development") { - ("use theming"); - /** - * Clean up old hot-module script injections as they hog up memory - * and anything other than the newest one is really not needed at all. - * We don't need to do it more frequently than every half a minute or so, - * but it's done to delay full page reload due to app slowness. - */ - setInterval(() => { - const elements = Array.from(document.querySelectorAll("script[src*=hot-update]")); - if (elements.length > 1) { - const oldInjects = elements.slice(0, elements.length - 1); - oldInjects.forEach((e) => e.remove()); - } - }, 1000); -} diff --git a/src/vector/index.ts b/src/vector/index.ts index 1b9a59d099..04143ba36e 100644 --- a/src/vector/index.ts +++ b/src/vector/index.ts @@ -22,14 +22,6 @@ import "./modernizr"; // in webpack.config.js require("katex/dist/katex.css"); -/** - * This require is necessary only for purposes of CSS hot-reload, as otherwise - * webpack has some incredible problems figuring out which CSS files should be - * hot-reloaded, even with proper hints for the loader. - * - * On production build it's going to be an empty module, so don't worry about that. - */ -require("./devcss"); require("./localstorage-fix"); async function settled(...promises: Array>): Promise { diff --git a/yarn.lock b/yarn.lock index 55f63f6cc1..662cfd8719 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10810,14 +10810,6 @@ string-length@^4.0.1: char-regex "^1.0.2" strip-ansi "^6.0.0" -string-replace-loader@3: - version "3.1.0" - resolved "https://registry.yarnpkg.com/string-replace-loader/-/string-replace-loader-3.1.0.tgz#11ac6ee76bab80316a86af358ab773193dd57a4f" - integrity sha512-5AOMUZeX5HE/ylKDnEa/KKBqvlnFmRZudSOjVJHxhoJg9QYTwl1rECx7SLR8BBH7tfxb4Rp7EM2XVfQFxIhsbQ== - dependencies: - loader-utils "^2.0.0" - schema-utils "^3.0.0" - "string-width-cjs@npm:string-width@^4.2.0": version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" @@ -10975,11 +10967,6 @@ strip-json-comments@^3.1.1: resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== -style-loader@4: - version "4.0.0" - resolved "https://registry.yarnpkg.com/style-loader/-/style-loader-4.0.0.tgz#0ea96e468f43c69600011e0589cb05c44f3b17a5" - integrity sha512-1V4WqhhZZgjVAVJyt7TdDPZoPBPNHbekX4fWnCJL1yQukhCeZhJySUL+gL9y6sNdN95uEOS83Y55SqHcP7MzLA== - stylehacks@^7.0.2: version "7.0.2" resolved "https://registry.yarnpkg.com/stylehacks/-/stylehacks-7.0.2.tgz#cc0ec317e9d5b30fdbdfe7ed6b8d3b1a8c57fa06"