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
1716const defaults = require ( 'lodash.defaults' ) ;
1817const assign = require ( 'lodash.assign' ) ;
19- const get = require ( 'lodash.get' ) ;
2018const each = require ( 'lodash.foreach' ) ;
2119const fromPairs = require ( 'lodash.frompairs' ) ;
2220const 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
0 commit comments