From 76814771dcebe80628b4462f5e1d30064ae226d5 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Tue, 13 Feb 2024 15:22:21 +0300 Subject: [PATCH] fix: avoid using eval in client (#5045) --- client-src/modules/logger/SyncBailHookFake.js | 10 --------- client-src/modules/logger/tapable.js | 11 ++++++++++ client-src/webpack.config.js | 22 ++++++++----------- 3 files changed, 20 insertions(+), 23 deletions(-) delete mode 100644 client-src/modules/logger/SyncBailHookFake.js create mode 100644 client-src/modules/logger/tapable.js diff --git a/client-src/modules/logger/SyncBailHookFake.js b/client-src/modules/logger/SyncBailHookFake.js deleted file mode 100644 index ae6e5321de..0000000000 --- a/client-src/modules/logger/SyncBailHookFake.js +++ /dev/null @@ -1,10 +0,0 @@ -"use strict"; - -/** - * Client stub for tapable SyncBailHook - */ -module.exports = function clientTapableSyncBailHook() { - return { - call() {}, - }; -}; diff --git a/client-src/modules/logger/tapable.js b/client-src/modules/logger/tapable.js new file mode 100644 index 0000000000..2ee5f3accf --- /dev/null +++ b/client-src/modules/logger/tapable.js @@ -0,0 +1,11 @@ +function SyncBailHook() { + return { + call() {}, + }; +} + +/** + * Client stub for tapable SyncBailHook + */ +// eslint-disable-next-line import/prefer-default-export +export { SyncBailHook }; diff --git a/client-src/webpack.config.js b/client-src/webpack.config.js index 94a123b286..3e44675239 100644 --- a/client-src/webpack.config.js +++ b/client-src/webpack.config.js @@ -4,15 +4,12 @@ const path = require("path"); const webpack = require("webpack"); const { merge } = require("webpack-merge"); -// @ts-ignore -const library = webpack.webpack - ? { - library: { - // type: "module", - type: "commonjs", - }, - } - : { libraryTarget: "umd" }; +const library = { + library: { + // type: "module", + type: "commonjs", + }, +}; const baseForModules = { devtool: false, @@ -28,8 +25,7 @@ const baseForModules = { optimization: { minimize: false, }, - // @ts-ignore - target: webpack.webpack ? ["web", "es5"] : "web", + target: ["web", "es5"], module: { rules: [ { @@ -73,8 +69,8 @@ module.exports = [ '(typeof Symbol !== "undefined" ? Symbol : function (i) { return i; })', }), new webpack.NormalModuleReplacementPlugin( - /^tapable\/lib\/SyncBailHook/, - path.join(__dirname, "modules/logger/SyncBailHookFake.js"), + /^tapable$/, + path.join(__dirname, "modules/logger/tapable.js"), ), ], }),