Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -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 */
Expand All @@ -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');
Expand Down Expand Up @@ -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,
Expand All @@ -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));
Expand Down Expand Up @@ -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']),
});

Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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",
Expand Down