image-minimizer-webpack-plugin: squooshGenerate error: " TypeError: Cannot read properties of undefined (reading 'get')"

with squooshMinify

module: {
  rules: [
    {
      test: /\.(gif|png|jpe?g|svg|ico)$/,
...
optimization: {
  minimize,
  minimizer: [
    new ImageMinimizerPlugin({
      minimizer: {
        implementation: ImageMinimizerPlugin.squooshMinify,
        options: {
          encodeOptions: {
            oxipng: {
              level: 6,
            },
          },
        },
      },

png minification works.

switch, instead, to squooshGenerate, for png->webp generation,

module: {
  rules: [
    {
      test: /\.(gif|png|jpe?g|svg|ico)$/,
...
  optimization: {
    minimize,
    minimizer: [
      new ImageMinimizerPlugin({
        generator: [
          {
            implementation: ImageMinimizerPlugin.squooshGenerate,
            options: {
              encodeOptions: {
                webp: {
                  quality: 90,
                },
              },
            },
          },
        ],

on build, fails

webpack --mode=production  --progress --profile
  [webpack-cli] HookWebpackError: Cannot read properties of undefined (reading 'get')
      at makeWebpackError (/work/test01/.yarn/__virtual__/webpack-virtual-7a36ac1fb4/0/cache/webpack-npm-5.68.0-f34609ad11-ac6efd861a.zip/node_modules/webpack/lib/HookWebpackError.js:48:9)
      at /work/test01/.yarn/__virtual__/webpack-virtual-7a36ac1fb4/0/cache/webpack-npm-5.68.0-f34609ad11-ac6efd861a.zip/node_modules/webpack/lib/Compilation.js:3057:12
      at eval (eval at create (/work/test01/.yarn/cache/tapable-npm-2.2.1-8cf5ff3039-3b7a1b4d86.zip/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:17:1)
      at fn (/work/test01/.yarn/__virtual__/webpack-virtual-7a36ac1fb4/0/cache/webpack-npm-5.68.0-f34609ad11-ac6efd861a.zip/node_modules/webpack/lib/Compilation.js:478:17)
      at _next7 (eval at create (/work/test01/.yarn/cache/tapable-npm-2.2.1-8cf5ff3039-3b7a1b4d86.zip/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:14:1)
      at eval (eval at create (/work/test01/.yarn/cache/tapable-npm-2.2.1-8cf5ff3039-3b7a1b4d86.zip/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:34:1)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
  -- inner error --
  TypeError: Cannot read properties of undefined (reading 'get')
      at WebpackAssetsManifest.handleProcessAssetsAnalyse (/work/test01/.yarn/__virtual__/webpack-assets-manifest-virtual-f2c3bb0a34/0/cache/webpack-assets-manifest-npm-5.1.0-fad26f5290-30b0929f6a.zip/node_modules/webpack-assets-manifest/src/WebpackAssetsManifest.js:467:37)
      at fn (/work/test01/.yarn/__virtual__/webpack-virtual-7a36ac1fb4/0/cache/webpack-npm-5.68.0-f34609ad11-ac6efd861a.zip/node_modules/webpack/lib/Compilation.js:476:10)
      at _next7 (eval at create (/work/test01/.yarn/cache/tapable-npm-2.2.1-8cf5ff3039-3b7a1b4d86.zip/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:14:1)
      at eval (eval at create (/work/test01/.yarn/cache/tapable-npm-2.2.1-8cf5ff3039-3b7a1b4d86.zip/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:34:1)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
  caused by plugins in Compilation.hooks.processAssets
  TypeError: Cannot read properties of undefined (reading 'get')
      at WebpackAssetsManifest.handleProcessAssetsAnalyse (/work/test01/.yarn/__virtual__/webpack-assets-manifest-virtual-f2c3bb0a34/0/cache/webpack-assets-manifest-npm-5.1.0-fad26f5290-30b0929f6a.zip/node_modules/webpack-assets-manifest/src/WebpackAssetsManifest.js:467:37)
      at fn (/work/test01/.yarn/__virtual__/webpack-virtual-7a36ac1fb4/0/cache/webpack-npm-5.68.0-f34609ad11-ac6efd861a.zip/node_modules/webpack/lib/Compilation.js:476:10)
      at _next7 (eval at create (/work/test01/.yarn/cache/tapable-npm-2.2.1-8cf5ff3039-3b7a1b4d86.zip/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:14:1)
      at eval (eval at create (/work/test01/.yarn/cache/tapable-npm-2.2.1-8cf5ff3039-3b7a1b4d86.zip/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:34:1)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
npx webpack-cli info

  System:
    OS: Linux 5.16 Fedora Linux 35 (Thirty Five)
    CPU: (16) x64 AMD Ryzen 7 3700X 8-Core Processor
    Memory: 52.91 GB / 62.70 GB
  Binaries:
    Node: 17.4.0 - /usr/local/bin/node
    Yarn: 3.2.0-rc.13 - /usr/local/bin/yarn
    npm: 8.3.1 - /usr/local/bin/npm
  Browsers:
    Brave Browser: 98.1.35.100
    Chrome: 98.0.4758.80
    Firefox: 96.0.3

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 19 (13 by maintainers)

Most upvoted comments

Oh, seems you have https://github.com/pgnd/test01.git, give me time

@alexander-akait

Because WebpackAssetsManifest doesn’t support renamed assets, sorry we can’t fix it here, if you provide github repo I will show there is problems happens and how to fix it

fyi, i’ve provided reproducer over @

https://github.com/webdeveric/webpack-assets-manifest/issues/219#issuecomment-1034210018

Because WebpackAssetsManifest doesn’t support renamed assets, sorry we can’t fix it here, if you provide github repo I will show there is problems happens and how to fix it