From f2ccb999220ee596d68c80b36265e5ee4ec877b3 Mon Sep 17 00:00:00 2001 From: AntiMoron Date: Mon, 30 Dec 2024 14:30:38 +0800 Subject: [PATCH] fix: remove eval usage so that chrome extension MV3 can run properly (#1941) --- lib/inquire/index.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/inquire/index.js b/lib/inquire/index.js index 259011b17..5dd720bf7 100644 --- a/lib/inquire/index.js +++ b/lib/inquire/index.js @@ -8,12 +8,17 @@ module.exports = inquire; * @returns {?Object} Required module if available and not empty, otherwise `null` */ function inquire(moduleName) { - try { - var mod = eval("quire".replace(/^/,"re"))(moduleName); // eslint-disable-line no-eval - if (mod && (mod.length || Object.keys(mod).length)) - return mod; - } catch (e) {} // eslint-disable-line no-empty + try { + if (typeof require !== "function") { + return null; + } + var mod = require(moduleName); + if (mod && (mod.length || Object.keys(mod).length)) return mod; return null; + } catch (err) { + // ignore + return null; + } } /*