speed-measure-webpack-plugin icon indicating copy to clipboard operation
speed-measure-webpack-plugin copied to clipboard

Breaks with incremental builds

Open mcintyret opened this issue 7 years ago • 11 comments

Several plugins I have tried to use alongside this plugin break when webpack starts an incremental build after a code change. The issue seems to be that all the hooks registered on the webpack 4 compiler.hooks object are missing in the incremental compile. The plugins then fail with errors like TypeError: Cannot read property 'call' of undefined. Removing the speed-measure-webpack-plugin fixes the issue.

mcintyret avatar May 31 '18 20:05 mcintyret

Hey @mcintyret - which plugins are you using that seem to be failing?

Thanks for raising :)

stephencookdev avatar Jun 01 '18 11:06 stephencookdev

I saw the issue with both hard-source-webpack-plugin and fork-ts-checker-webpack-plugin

mcintyret avatar Jun 02 '18 18:06 mcintyret

Okay cool, thanks. I'll try my best to get some time this week to have a look at those and see why they're having issues :thinking:

stephencookdev avatar Jun 04 '18 07:06 stephencookdev

Break incremental builds too:

          content: childCompilation.assets[outputName].source()
                                                       ^

TypeError: Cannot read property 'source' of undefined```

`[email protected]`

rustjson avatar Jul 20 '18 05:07 rustjson

@stephencookdev I really like this plugin any progress on this? Any pointers to look at for fixing this?

Nilos avatar Oct 09 '18 08:10 Nilos

So the issue of childCompilation.assets[outputName].source() I believe might actually be a separate root issue...

But the issue of the compiler.hooks missing, has 2 possible causes

Either, this wrapHooks call is returning something stupid.

Or, compiler itself isn't being wrapped correctly, so it's not actually a proxy that hits that wrapHooks function as we would expect.

Longer term, I really want to expand our integration tests to be able to check incremental builds, as well as just plain builds. It makes testing + fixing issues a lot easier, if nothing else...

Unfortunately I'm really struggling to find time to work on this repo at the moment! Any help would be massively appreciated :pray: I'll try my best to write up a decent CONTRIBUTING.md in the next couple of days

stephencookdev avatar Oct 10 '18 18:10 stephencookdev

Similar issue with [email protected], [email protected]:

My manifest options are set as follows:

			new ManifestPlugin({
				seed: {}, // TODO: remove after upgrading to v3: https://github.com/danethurber/webpack-manifest-plugin/issues/144
				fileName: 'client-script-manifest.json',
				writeToFileEmit: true,  // always write a manifest.json file, even with webpack-dev-server
				publicPath: ''
			}),

And getting the following err after the first build:

 95% emitting ManifestPlugin✖ 「wdm」: TypeError: Cannot read property 'call' of undefined
    at ManifestPlugin.<anonymous> (/Users/chandoka/Documents/[REDCATED]/application/node_modules/webpack-manifest-plugin/lib/plugin.js:191:53)
    at args (/Users/chandoka/Documents/[REDCATED]/application/node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:52:19)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/chandoka/Documents/[REDCATED]/application/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:16:1)
    at Compiler.emitAssets (/Users/chandoka/Documents/[REDCATED]/application/node_modules/webpack/lib/Compiler.js:358:19)
    at onCompiled (/Users/chandoka/Documents/[REDCATED]/application/node_modules/webpack/lib/Watching.js:50:19)
    at hooks.afterCompile.callAsync.err (/Users/chandoka/Documents/[REDCATED]/application/node_modules/webpack/lib/Compiler.js:547:14)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/chandoka/Documents/[REDCATED]/application/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:15:1)
    at compilation.seal.err (/Users/chandoka/Documents/[REDCATED]/application/node_modules/webpack/lib/Compiler.js:544:30)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/chandoka/Documents/[REDCATED]/application/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:10:1)
    at AsyncSeriesHook.lazyCompileHook (/Users/chandoka/Documents/[REDCATED]/application/node_modules/tapable/lib/Hook.js:154:20)

Hard to reproduce such a large app but hopefully the additional logs will help debug.

artivilla avatar Nov 13 '18 18:11 artivilla

I thought I would chip in here and add my 2-cents.

TypeError: Cannot read property 'call' of undefined
    at /var/www/glasshouse-games/Frontend/node_modules/autodll-webpack-plugin/lib/plugin.js:152:48

Is occurring for me when using SPM plugin with nextjs and a custom webpack config at next.config.js as follows:

module.exports = withCSS({
  target: 'serverless',
  webpack: smp.wrap((config, {}) => config),
  env: { env: process.env.NODE_ENV },
})

I will keep playing and update if I get any ideas where/why it is falling over.

hutber avatar Nov 24 '19 12:11 hutber

Is there any solution to this problem now?

xccjk avatar Nov 13 '20 09:11 xccjk

I hacked this into node_modules/webpack-manifest-plugin/lib/plugin.js

image

    if (compiler.hooks) {
      if (!compiler.hooks.webpackManifestPluginAfterEmit) {
        compiler.hooks.compilation.tap({
          name: 'ManifestPlugin',
          stage: Infinity
        }, function (compilation) {
          compilation.applyPluginsAsync('webpack-manifest-plugin-after-emit', manifest, compileCallback);
        });
      } else {
        compiler.hooks.webpackManifestPluginAfterEmit.call(manifest);
      }
    } else {
      compilation.applyPluginsAsync('webpack-manifest-plugin-after-emit', manifest, compileCallback);
    }

BLamy avatar Jun 22 '21 08:06 BLamy

Is there any update on this issue? I am also facing the same issue with ts-fork plugin.

techimist avatar Mar 10 '22 16:03 techimist