webpack-assets-manifest: inDevServer method crashes with webpack 5

The problem

Can not create assets manifest file after update to webpack@5. webpack-assets-manifest throws an error in inDevServer https://github.com/webdeveric/webpack-assets-manifest/blob/master/src/WebpackAssetsManifest.js#L838

Because this.compiler.outputFileSystem is [Object: null prototype]

Technical details

HookWebpackError: Cannot read properties of undefined (reading 'name')
        at makeWebpackError ($HOME/path/webpack.buildconfig.library/node_modules/webpack/lib/HookWebpackError.js:48:9)
        at $HOME/path/webpack.buildconfig.library/node_modules/webpack/lib/Compilation.js:3055:12
        at eval (eval at create ($HOME/path/webpack.buildconfig.library/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:30:1)
        at processTicksAndRejections (node:internal/process/task_queues:96:5)
    -- inner error --
    TypeError: Cannot read properties of undefined (reading 'name')
        at WebpackAssetsManifest.inDevServer ($HOME/path/webpack.buildconfig.library/node_modules/webpack-assets-manifest/src/WebpackAssetsManifest.js:838:97)
        at WebpackAssetsManifest.getOutputPath ($HOME/path/webpack.buildconfig.library/node_modules/webpack-assets-manifest/src/WebpackAssetsManifest.js:856:15)
        at WebpackAssetsManifest.emitAssetsManifest ($HOME/path/webpack.buildconfig.library/node_modules/webpack-assets-manifest/src/WebpackAssetsManifest.js:418:29)
        at WebpackAssetsManifest.handleProcessAssetsReport ($HOME/path/webpack.buildconfig.library/node_modules/webpack-assets-manifest/src/WebpackAssetsManifest.js:633:16)
        at fn ($HOME/path/webpack.buildconfig.library/node_modules/webpack/lib/Compilation.js:534:19)
        at _next4 (eval at create ($HOME/path/webpack.buildconfig.library/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:22:17)
        at eval (eval at create ($HOME/path/webpack.buildconfig.library/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:41:1)
        at processTicksAndRejections (node:internal/process/task_queues:96:5)
    caused by plugins in Compilation.hooks.processAssets
    TypeError: Cannot read properties of undefined (reading 'name')
        at WebpackAssetsManifest.inDevServer ($HOME/path/webpack.buildconfig.library/node_modules/webpack-assets-manifest/src/WebpackAssetsManifest.js:838:97)
        at WebpackAssetsManifest.getOutputPath ($HOME/path/webpack.buildconfig.library/node_modules/webpack-assets-manifest/src/WebpackAssetsManifest.js:856:15)
        at WebpackAssetsManifest.emitAssetsManifest ($HOME/path/webpack.buildconfig.library/node_modules/webpack-assets-manifest/src/WebpackAssetsManifest.js:418:29)
        at WebpackAssetsManifest.handleProcessAssetsReport ($HOME/path/webpack.buildconfig.library/node_modules/webpack-assets-manifest/src/WebpackAssetsManifest.js:633:16)
        at fn ($HOME/path/webpack.buildconfig.library/node_modules/webpack/lib/Compilation.js:534:19)
        at _next4 (eval at create ($HOME/path/webpack.buildconfig.library/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:22:17)
        at eval (eval at create ($HOME/path/webpack.buildconfig.library/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:41:1)
        at processTicksAndRejections (node:internal/process/task_queues:96:5)

Webpack version

webpack@5.65.0

Webpack config

    {
      mode: 'production',
      devtool: 'hidden-source-map',
      resolve: {
        extensions: [
          '.ts',   '.tsx',
          '.js',   '.jsx',
          '.json', '.ts',
          '.tsx',  '.js',
          '.jsx',  '.json'
        ],
        alias: {}
      },
      module: {
        rules: [
          [Object], [Object],
          [Object], [Object],
          [Object], [Object],
          [Object]
        ]
      },
      plugins: [
        BundleAnalyzerPlugin {
          opts: [Object],
          server: null,
          logger: [Logger]
        },
        ScopeAmdModulePlugin { scope: 'deps.amd' },
        WebpackAssetsManifest {
          hooks: [Object],
          options: [Object],
          assets: [Object: null prototype] {},
          assetNames: Map(0) {},
          currentAsset: null,
          compiler: null,
          [Symbol(isMerging)]: false
        }
      ],
      optimization: { minimize: true, minimizer: [ [TerserPlugin] ] },
      entry: [
        'tests/fixtures/react.library.app.tsx',
        'tests/fixtures/index.html'
      ],
      output: {
        filename: 'react.library.app.js',
        path: '$HOME/path/webpack.buildconfig.library/tests/fixtures/dist/react-library/production'
      }
    }

Operating system

MacOs Catalina

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 12
  • Comments: 15 (15 by maintainers)

Most upvoted comments

@blackrabbit99 A new version has been published.

I was able to see the null prototype logs when using Jest. I don’t have time to dig into it more but my assumption is that there is some auto mocking going on. I ran the same test case in Mocha and it did not give me the null prototype which just indicates this issue is related to Jest. I’ll try to find some time later today or tomorrow to review you PR again.

I have the same feeling. I’m trying to localise problem because project is quite big. Working on it.