From 44787a868495b68c3b9a5116281317ab479f4a15 Mon Sep 17 00:00:00 2001 From: Boyuan Gao Date: Mon, 9 Oct 2023 17:01:34 +0800 Subject: [PATCH] fix: remove eval usage so that chrome extension MV3 can run properly --- 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; + } } /*