From 844491abebecf23e5a9e57536b700289846fa228 Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Sun, 18 May 2025 15:03:49 -0400 Subject: [PATCH] Replace deprecated lodash.get package --- lib/index.js | 10 ++++------ package.json | 2 -- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/index.js b/lib/index.js index 4e4c2d4..5af916a 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,7 +1,6 @@ // @ts-check /** @typedef {import("lodash.defaults")} defaults */ /** @typedef {import("lodash.assign")} assign */ -/** @typedef {import("lodash.get")} get */ /** @typedef {import("webpack").Compiler} Compiler */ /** @typedef {import("webpack").Stats} Stats */ /** @typedef {import("webpack").compilation.Compilation} Compilation */ @@ -16,7 +15,6 @@ const crypto = require('crypto'); const defaults = require('lodash.defaults'); const assign = require('lodash.assign'); -const get = require('lodash.get'); const each = require('lodash.foreach'); const fromPairs = require('lodash.frompairs'); const toPairs = require('lodash.topairs'); @@ -73,8 +71,8 @@ class BundleTrackerPlugin { */ _setParamsFromCompiler(compiler) { this.options = defaults({}, this.options, { - path: get(compiler.options, 'output.path', process.cwd()), - publicPath: get(compiler.options, 'output.publicPath', ''), + path: compiler.options.output?.path ?? process.cwd(), + publicPath: compiler.options.output?.publicPath ?? '', filename: 'webpack-stats.json', logTime: false, relativePath: false, @@ -93,7 +91,7 @@ class BundleTrackerPlugin { } // Set output directories - this.outputChunkDir = path.resolve(get(compiler.options, 'output.path', process.cwd())); + this.outputChunkDir = path.resolve(compiler.options.output?.path ?? process.cwd()); // @ts-ignore: TS2345 this.options.path can't be undefined here because we set a default value above // @ts-ignore: TS2345 this.options.filename can't be undefined here because we set a default value above this.outputTrackerFile = path.resolve(path.join(this.options.path, this.options.filename)); @@ -161,7 +159,7 @@ class BundleTrackerPlugin { const error = findError(stats.compilation); this._writeOutput(compiler, { status: 'error', - error: get(error, 'name', 'unknown-error'), + error: error.name ?? 'unknown-error', message: stripAnsi(error['message']), }); diff --git a/package.json b/package.json index 7f8118f..b5a8911 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,6 @@ "lodash.defaults": "^4.2.0", "lodash.foreach": "^4.5.0", "lodash.frompairs": "^4.0.1", - "lodash.get": "^4.4.2", "lodash.topairs": "^4.3.0" }, "devDependencies": { @@ -53,7 +52,6 @@ "@types/lodash.defaults": "^4.2.7", "@types/lodash.foreach": "^4.5.7", "@types/lodash.frompairs": "^4.0.7", - "@types/lodash.get": "^4.4.7", "@types/lodash.topairs": "^4.3.7", "@types/node": "^13.13.52", "@types/webpack": "^4.41.33",