From 9ee2cfc3934fbd44c3d4afad60c6684de0f86cff Mon Sep 17 00:00:00 2001 From: Daniel Tschinder <231804+danez@users.noreply.github.com> Date: Tue, 3 Sep 2024 19:25:37 +0200 Subject: [PATCH] feat: replace lodash with webpack-merge --- package.json | 2 +- pnpm-lock.yaml | 45 +++++++++++++++++++++++++++++++++++++++--- src/options/default.js | 21 +++++--------------- 3 files changed, 48 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index 21a32cb..ae3f106 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ }, "dependencies": { "deep-for-each": "^3.0.0", - "lodash": "^4.17.21" + "webpack-merge": "^6.0.1" }, "jest": { "collectCoverageFrom": [ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index baeaa9b..69c1021 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,9 +11,9 @@ importers: deep-for-each: specifier: ^3.0.0 version: 3.0.0 - lodash: - specifier: ^4.17.21 - version: 4.17.21 + webpack-merge: + specifier: ^6.0.1 + version: 6.0.1 devDependencies: '@babel/core': specifier: ^7.22.10 @@ -1308,6 +1308,10 @@ packages: resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==} engines: {node: '>=12'} + clone-deep@4.0.1: + resolution: {integrity: sha512-neHB9xuzh/wk0dIHweyAXv2aPGZIVk3pLMe+/RNzINf17fe0OG96QroktYAUm7SM1PBnzTabaLboqqxDyMU+SQ==} + engines: {node: '>=6'} + co@4.6.0: resolution: {integrity: sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==} engines: {iojs: '>= 1.0.0', node: '>= 0.12.0'} @@ -1788,6 +1792,10 @@ packages: resolution: {integrity: sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==} engines: {node: ^10.12.0 || >=12.0.0} + flat@5.0.2: + resolution: {integrity: sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==} + hasBin: true + flatted@3.2.7: resolution: {integrity: sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==} @@ -3055,6 +3063,10 @@ packages: setprototypeof@1.2.0: resolution: {integrity: sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==} + shallow-clone@3.0.1: + resolution: {integrity: sha512-/6KqX+GVUdqPuPPd2LxDDxzX6CAbjJehAAOKlNpqqUpAqPM6HeL8f+o3a+JsyGjn2lv0WY8UsTgUJjU9Ok55NA==} + engines: {node: '>=8'} + shebang-command@2.0.0: resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} engines: {node: '>=8'} @@ -3406,6 +3418,10 @@ packages: webpack-cli: optional: true + webpack-merge@6.0.1: + resolution: {integrity: sha512-hXXvrjtx2PLYx4qruKl+kyRSLc52V+cCvMxRjmKwoA+CBbbF5GfIBtR6kCvl0fYGqTUPKB+1ktVmTHqMOzgCBg==} + engines: {node: '>=18.0.0'} + webpack-sources@3.2.3: resolution: {integrity: sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==} engines: {node: '>=10.13.0'} @@ -3444,6 +3460,9 @@ packages: engines: {node: '>= 8'} hasBin: true + wildcard@2.0.1: + resolution: {integrity: sha512-CC1bOL87PIWSBhDcTrdeLo6eGT7mCFtrg0uIJtqJUFyK+eJnzl8A1niH56uu7KMa5XFrtiV+AQuHO3n7DsHnLQ==} + wrap-ansi@7.0.0: resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==} engines: {node: '>=10'} @@ -5092,6 +5111,12 @@ snapshots: strip-ansi: 6.0.1 wrap-ansi: 7.0.0 + clone-deep@4.0.1: + dependencies: + is-plain-object: 2.0.4 + kind-of: 6.0.3 + shallow-clone: 3.0.1 + co@4.6.0: {} collect-v8-coverage@1.0.2: {} @@ -5651,6 +5676,8 @@ snapshots: flatted: 3.2.7 rimraf: 3.0.2 + flat@5.0.2: {} + flatted@3.2.7: {} follow-redirects@1.15.6: {} @@ -7098,6 +7125,10 @@ snapshots: setprototypeof@1.2.0: {} + shallow-clone@3.0.1: + dependencies: + kind-of: 6.0.3 + shebang-command@2.0.0: dependencies: shebang-regex: 3.0.0 @@ -7473,6 +7504,12 @@ snapshots: - supports-color - utf-8-validate + webpack-merge@6.0.1: + dependencies: + clone-deep: 4.0.1 + flat: 5.0.2 + wildcard: 2.0.1 + webpack-sources@3.2.3: {} webpack@5.94.0: @@ -7537,6 +7574,8 @@ snapshots: dependencies: isexe: 2.0.0 + wildcard@2.0.1: {} + wrap-ansi@7.0.0: dependencies: ansi-styles: 4.3.0 diff --git a/src/options/default.js b/src/options/default.js index 735342c..50e3483 100644 --- a/src/options/default.js +++ b/src/options/default.js @@ -1,6 +1,6 @@ "use strict"; -const mergeWith = require("lodash/mergeWith"); +const { merge } = require("webpack-merge"); const gruntOptions = { failOnError: (options) => { @@ -39,13 +39,6 @@ const webpackDevServerOptions = { }, }; -// eslint-disable-next-line consistent-return -function mergeCustomize(a, b) { - if (Array.isArray(a) && Array.isArray(b)) { - return a.concat(b); - } -} - function mergeOptions(defaultOptions, options, targetOptions) { if (Array.isArray(targetOptions) && Array.isArray(options)) { if (targetOptions.length !== options.length) { @@ -55,21 +48,17 @@ function mergeOptions(defaultOptions, options, targetOptions) { ); } return targetOptions.map((opt, index) => - mergeWith({}, defaultOptions, options[index], opt, mergeCustomize), + merge(defaultOptions, options[index], opt), ); } if (Array.isArray(targetOptions)) { - return targetOptions.map((opt) => - mergeWith({}, defaultOptions, options, opt, mergeCustomize), - ); + return targetOptions.map((opt) => merge(defaultOptions, options, opt)); } else if (Array.isArray(options)) { - return options.map((opt) => - mergeWith({}, defaultOptions, opt, targetOptions, mergeCustomize), - ); + return options.map((opt) => merge(defaultOptions, opt, targetOptions)); } - return mergeWith({}, defaultOptions, options, targetOptions, mergeCustomize); + return merge(defaultOptions, options, targetOptions); } exports.gruntOptions = gruntOptions;