Skip to content

Commit e0abf8f

Browse files
authored
Merge pull request #129 from jacobtylerwalls/lodash-get
Replace deprecated lodash.get package
2 parents 8261c7e + 844491a commit e0abf8f

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

lib/index.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// @ts-check
22
/** @typedef {import("lodash.defaults")} defaults */
33
/** @typedef {import("lodash.assign")} assign */
4-
/** @typedef {import("lodash.get")} get */
54
/** @typedef {import("webpack").Compiler} Compiler */
65
/** @typedef {import("webpack").Stats} Stats */
76
/** @typedef {import("webpack").compilation.Compilation} Compilation */
@@ -16,7 +15,6 @@ const crypto = require('crypto');
1615

1716
const defaults = require('lodash.defaults');
1817
const assign = require('lodash.assign');
19-
const get = require('lodash.get');
2018
const each = require('lodash.foreach');
2119
const fromPairs = require('lodash.frompairs');
2220
const toPairs = require('lodash.topairs');
@@ -73,8 +71,8 @@ class BundleTrackerPlugin {
7371
*/
7472
_setParamsFromCompiler(compiler) {
7573
this.options = defaults({}, this.options, {
76-
path: get(compiler.options, 'output.path', process.cwd()),
77-
publicPath: get(compiler.options, 'output.publicPath', ''),
74+
path: compiler.options.output?.path ?? process.cwd(),
75+
publicPath: compiler.options.output?.publicPath ?? '',
7876
filename: 'webpack-stats.json',
7977
logTime: false,
8078
relativePath: false,
@@ -93,7 +91,7 @@ class BundleTrackerPlugin {
9391
}
9492

9593
// Set output directories
96-
this.outputChunkDir = path.resolve(get(compiler.options, 'output.path', process.cwd()));
94+
this.outputChunkDir = path.resolve(compiler.options.output?.path ?? process.cwd());
9795
// @ts-ignore: TS2345 this.options.path can't be undefined here because we set a default value above
9896
// @ts-ignore: TS2345 this.options.filename can't be undefined here because we set a default value above
9997
this.outputTrackerFile = path.resolve(path.join(this.options.path, this.options.filename));
@@ -161,7 +159,7 @@ class BundleTrackerPlugin {
161159
const error = findError(stats.compilation);
162160
this._writeOutput(compiler, {
163161
status: 'error',
164-
error: get(error, 'name', 'unknown-error'),
162+
error: error.name ?? 'unknown-error',
165163
message: stripAnsi(error['message']),
166164
});
167165

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
"lodash.defaults": "^4.2.0",
4444
"lodash.foreach": "^4.5.0",
4545
"lodash.frompairs": "^4.0.1",
46-
"lodash.get": "^4.4.2",
4746
"lodash.topairs": "^4.3.0"
4847
},
4948
"devDependencies": {
@@ -53,7 +52,6 @@
5352
"@types/lodash.defaults": "^4.2.7",
5453
"@types/lodash.foreach": "^4.5.7",
5554
"@types/lodash.frompairs": "^4.0.7",
56-
"@types/lodash.get": "^4.4.7",
5755
"@types/lodash.topairs": "^4.3.7",
5856
"@types/node": "^13.13.52",
5957
"@types/webpack": "^4.41.33",

0 commit comments

Comments
 (0)