From a8822d48823ecf710e09c6c6ef679ff593e5cc50 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Fri, 12 Apr 2024 07:00:46 -0400 Subject: [PATCH] fix: use `string-replace-loader` instead of `string-replace-webpack-plugin` --- package-lock.json | 137 +++++++++------------------------------ package.json | 2 +- webpack.common.config.js | 30 ++++++++- 3 files changed, 62 insertions(+), 107 deletions(-) diff --git a/package-lock.json b/package-lock.json index a687fbd7fdaa..c3a2607edf8d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -66,7 +66,6 @@ "sass": "^1.54.8", "sass-loader": "^14.1.1", "scriptjs": "2.5.9", - "string-replace-webpack-plugin": "0.1.3", "style-loader": "0.18.2", "svg-inline-loader": "0.8.2", "uglify-js": "2.7.0", @@ -109,6 +108,7 @@ "selenium-webdriver": "3.4.0", "sinon": "2.3.5", "squirejs": "0.1.0", + "string-replace-loader": "^3.1.0", "stylelint-formatter-pretty": "1.0.3", "webpack-cli": "^5.1.4" } @@ -16220,6 +16220,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", "integrity": "sha512-S2Hw0TtNkMJhIabBwIojKL9YHO5T0n5eNqWJ7Lrlel/zDbftQpxpapi8tZs3X1HWa+u+QeydGmzzNU0m09+Rcg==", + "dev": true, "optional": true, "engines": { "node": ">=0.4.2" @@ -35334,15 +35335,6 @@ "node": ">=0.10.0" } }, - "node_modules/string_decoder": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", - "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", - "extraneous": true, - "dependencies": { - "safe-buffer": "~5.2.0" - } - }, "node_modules/string-convert": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/string-convert/-/string-convert-0.2.1.tgz", @@ -35361,114 +35353,49 @@ "node": ">=10" } }, - "node_modules/string-replace-webpack-plugin": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/string-replace-webpack-plugin/-/string-replace-webpack-plugin-0.1.3.tgz", - "integrity": "sha512-uKyQi7AKVVMT7vLSA6qMAY5Pm4Ib13iBb9qAlIiCp44jxAQMlbX+4W9A050d4aLzf0siXdB8Xw1yODJNh2Z45w==", + "node_modules/string-replace-loader": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-replace-loader/-/string-replace-loader-3.1.0.tgz", + "integrity": "sha512-5AOMUZeX5HE/ylKDnEa/KKBqvlnFmRZudSOjVJHxhoJg9QYTwl1rECx7SLR8BBH7tfxb4Rp7EM2XVfQFxIhsbQ==", + "dev": true, "dependencies": { - "async": "~0.2.10", - "loader-utils": "~0.2.3" - }, - "optionalDependencies": { - "css-loader": "^0.9.1", - "file-loader": "^0.8.1", - "style-loader": "^0.8.3" + "loader-utils": "^2.0.0", + "schema-utils": "^3.0.0" }, "peerDependencies": { - "webpack": "^1.4.2 || >=2.2.0" + "webpack": "^5" } }, - "node_modules/string-replace-webpack-plugin/node_modules/async": { - "version": "0.2.10", - "resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz", - "integrity": "sha512-eAkdoKxU6/LkKDBzLpT+t6Ff5EtfSF4wx1WfJiPEEV7WNLnDaRXk0oVysiEPm262roaachGexwUv94WhSgN5TQ==" - }, - "node_modules/string-replace-webpack-plugin/node_modules/big.js": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/big.js/-/big.js-3.2.0.tgz", - "integrity": "sha512-+hN/Zh2D08Mx65pZ/4g5bsmNiZUuChDiQfTUQ7qJr4/kuopCr88xZsAXv6mBoZEsUI4OuGHlX59qE94K2mMW8Q==", - "engines": { - "node": "*" - } - }, - "node_modules/string-replace-webpack-plugin/node_modules/css-loader": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/css-loader/-/css-loader-0.9.1.tgz", - "integrity": "sha512-gRUrW6PKtgZrWaJ/w51C7N4MblnSe7LicfyX36YiN4gAK7QBNZ9VT3wxZDcyzW6zAkEpk7f/92v9258dCIKdEQ==", - "optional": true, + "node_modules/string-replace-loader/node_modules/loader-utils": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.4.tgz", + "integrity": "sha512-xXqpXoINfFhgua9xiqD8fPFHgkoq1mmmpE92WlDbm9rNRd/EbRb+Gqf908T2DMfuHjjJlksiK2RbHVOdD/MqSw==", + "dev": true, "dependencies": { - "csso": "1.3.x", - "loader-utils": "~0.2.2", - "source-map": "~0.1.38" - } - }, - "node_modules/string-replace-webpack-plugin/node_modules/csso": { - "version": "1.3.12", - "resolved": "https://registry.npmjs.org/csso/-/csso-1.3.12.tgz", - "integrity": "sha512-K5CSPbOVumvT1ceFb+maul2vow0WrTGxF3PXJpyjOuxilSGwgPqbub2M8oHTLz0hJ7lzSKBFSKTx299fpttlmQ==", - "optional": true, - "bin": { - "csso": "bin/csso" + "big.js": "^5.2.2", + "emojis-list": "^3.0.0", + "json5": "^2.1.2" }, "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/string-replace-webpack-plugin/node_modules/emojis-list": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-2.1.0.tgz", - "integrity": "sha512-knHEZMgs8BB+MInokmNTg/OyPlAddghe1YBgNwJBc5zsJi/uyIcXoSDsL/W9ymOsBoBGdPIHXYJ9+qKFwRwDng==", - "engines": { - "node": ">= 0.10" - } - }, - "node_modules/string-replace-webpack-plugin/node_modules/file-loader": { - "version": "0.8.5", - "resolved": "https://registry.npmjs.org/file-loader/-/file-loader-0.8.5.tgz", - "integrity": "sha512-yDylQzd/QOaMm249awSL+JjsLRDfFghwmm+YCALH0uLXqAazD/alHnhbIE+UyVtbI+bIVYVdgDApSJ9blouFDg==", - "optional": true, - "dependencies": { - "loader-utils": "~0.2.5" - } - }, - "node_modules/string-replace-webpack-plugin/node_modules/json5": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", - "integrity": "sha512-4xrs1aW+6N5DalkqSVA8fxh458CXvR99WU8WLKmq4v8eWAL86Xo3BVqyd3SkA9wEVjCMqyvvRRkshAdOnBp5rw==", - "bin": { - "json5": "lib/cli.js" - } - }, - "node_modules/string-replace-webpack-plugin/node_modules/loader-utils": { - "version": "0.2.17", - "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-0.2.17.tgz", - "integrity": "sha512-tiv66G0SmiOx+pLWMtGEkfSEejxvb6N6uRrQjfWJIT79W9GMpgKeCAmm9aVBKtd4WEgntciI8CsGqjpDoCWJug==", - "dependencies": { - "big.js": "^3.1.3", - "emojis-list": "^2.0.0", - "json5": "^0.5.0", - "object-assign": "^4.0.1" + "node": ">=8.9.0" } }, - "node_modules/string-replace-webpack-plugin/node_modules/source-map": { - "version": "0.1.43", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.43.tgz", - "integrity": "sha512-VtCvB9SIQhk3aF6h+N85EaqIaBFIAfZ9Cu+NJHHVvc8BbEcnvDcFw6sqQ2dQrT6SlOrZq3tIvyD9+EGq/lJryQ==", - "optional": true, + "node_modules/string-replace-loader/node_modules/schema-utils": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.3.0.tgz", + "integrity": "sha512-pN/yOAvcC+5rQ5nERGuwrjLlYvLTbCibnZ1I7B1LaiAz9BRBlE9GMgE/eqV30P7aJQUf7Ddimy/RsbYO/GrVGg==", + "dev": true, "dependencies": { - "amdefine": ">=0.0.4" + "@types/json-schema": "^7.0.8", + "ajv": "^6.12.5", + "ajv-keywords": "^3.5.2" }, "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/string-replace-webpack-plugin/node_modules/style-loader": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/style-loader/-/style-loader-0.8.3.tgz", - "integrity": "sha512-ICp1ISTuh4+aunEXH1XjCBEtPWcX6PKJ5D0f3g8/+mPHEUbcwo9ynMUUWKSH26DItIIlB/PStP5TTaQF+V7y7Q==", - "optional": true, - "dependencies": { - "loader-utils": "^0.2.5" + "node": ">= 10.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" } }, "node_modules/string-width": { diff --git a/package.json b/package.json index 3f6336ab7533..0050a5f5f9d6 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,6 @@ "sass": "^1.54.8", "sass-loader": "^14.1.1", "scriptjs": "2.5.9", - "string-replace-webpack-plugin": "0.1.3", "style-loader": "0.18.2", "svg-inline-loader": "0.8.2", "uglify-js": "2.7.0", @@ -115,6 +114,7 @@ "selenium-webdriver": "3.4.0", "sinon": "2.3.5", "squirejs": "0.1.0", + "string-replace-loader": "^3.1.0", "stylelint-formatter-pretty": "1.0.3", "webpack-cli": "^5.1.4" } diff --git a/webpack.common.config.js b/webpack.common.config.js index 2fd71bddee2e..c1b5b30378b3 100644 --- a/webpack.common.config.js +++ b/webpack.common.config.js @@ -5,7 +5,6 @@ var path = require('path'); var webpack = require('webpack'); var BundleTracker = require('webpack-bundle-tracker'); -var StringReplace = require('string-replace-webpack-plugin'); var Merge = require('webpack-merge'); var files = require('./webpack-config/file-lists.js'); @@ -168,6 +167,35 @@ module.exports = Merge.smart({ /\/sinon\.js|codemirror-compressed\.js|hls\.js|tinymce.js/ ], rules: [ + { + test: files.namespacedRequire.concat(files.textBangUnderscore, filesWithRequireJSBlocks), + loader: 'string-replace-loader', + options: { + multiple: [ + { search: defineHeader, replace: '' }, + { search: defineFooter, replace: '' }, + { + search: /(\/\* RequireJS) \*\//g, + replace(match, p1, offset, string) { + return p1; + } + }, + { + search: /\/\* Webpack/g, + replace(match, p1, offset, string) { + return match + ' */'; + } + }, + { + search: /text!(.*?\.underscore)/g, + replace(match, p1, offset, string) { + return p1; + } + }, + { search: /RequireJS.require/g, replace: 'require' } + ] + } + }, { test: /\.(js|jsx)$/, exclude: [