Webpack packing error Cannot read property 'emit' of undefined

< H2 > webpack reported an error when using the compression-webpack-plugin plug-in < / H2 >

related codes

const CompressionPlugin = require ("compression-webpack-plugin")

webpackConfig.plugins.push (

)
new CompressionPlugin({
  // asset: "[path].gz[query]",
  algorithm: "gzip",
  test: new RegExp(
    "\\.(js)$" 
    // "\\.(" +
    // configItem.productionGzipExtensions.join("|") +
    // ")$"
  ),
  threshold: 10240,
  minRatio: 0.8
})

errors are as follows

compiler.hooks.emit.tapAsync ({name: "CompressionPlugin"}, emit);

)
               ^

TypeError: Cannot read property "emit" of undefined

at CompressionPlugin.apply (C:\MyWayProject\2018\vue\ehrAdmin\node_modules\compression-webpack-plugin\dist\index.js:175:20)
Jul.06,2021

if I lower the compression-webpack-plugin to 1.1.12, I won't make a mistake


I also don't know if it's an es6 grammar problem


how to maintain the project later?

Menu