From a26f636c9b422f866b0dbe42566cd90c256483d1 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Fri, 11 Nov 2022 12:37:37 +0100 Subject: ci: Automated plugin test with puppeteer --- src/plugins/settings.tsx | 2 -- src/webpack/patchWebpack.ts | 14 +++++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/plugins/settings.tsx b/src/plugins/settings.tsx index d80b0ff..b3b49b6 100644 --- a/src/plugins/settings.tsx +++ b/src/plugins/settings.tsx @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -import React from "react"; - import gitHash from "~git-hash"; import { Devs } from "../utils/constants"; diff --git a/src/webpack/patchWebpack.ts b/src/webpack/patchWebpack.ts index 679d481..f14ab0b 100644 --- a/src/webpack/patchWebpack.ts +++ b/src/webpack/patchWebpack.ts @@ -65,7 +65,7 @@ function patchPush() { const originalMod = mod; const patchedBy = new Set(); - modules[id] = function (module, exports, require) { + const factory = modules[id] = function (module, exports, require) { try { mod(module, exports, require); } catch (err) { @@ -118,10 +118,14 @@ function patchPush() { logger.error("Error while firing callback for webpack chunk", err); } } - }; + } as any as { toString: () => string, original: any, (...args: any[]): void; }; - modules[id].toString = () => mod.toString(); - modules[id].original = originalMod; + // for some reason throws some error on which calling .toString() leads to infinite recursion + // when you force load all chunks??? + try { + factory.toString = () => mod.toString(); + factory.original = originalMod; + } catch { } for (let i = 0; i < patches.length; i++) { const patch = patches[i]; @@ -147,7 +151,7 @@ function patchPush() { mod = (0, eval)(`// Webpack Module ${id} - Patched by ${[...patchedBy].join(", ")}\n${newCode}\n//# sourceURL=WebpackModule${id}`); } } catch (err) { - logger.error(`Failed to apply patch ${replacement.match} of ${patch.plugin} to ${id}:\n`, err); + logger.error(`Patch by ${patch.plugin} errored (Module id is ${id}): ${replacement.match}\n`, err); if (IS_DEV) { const changeSize = code.length - lastCode.length; -- cgit