Turbo87/webpack-notifier

Error when using postcss-loader: "Cannot read property 'module' of undefined"

Closed this issue · 2 comments

I'm using Webpack Encore 0.22.2 with Webpack 4.28.3 and webpack-notifier 1.6.0. After including postcss-loader version 3, suddenly there is this error:

$ encore production
Running webpack ...

  WARNING   Webpack is already provided by Webpack Encore, also adding it to your package.json file may cause issues.
TypeError: Cannot read property 'module' of undefined
	at module.exports.WebpackNotifierPlugin.compileMessage (my_project_root_dir\node_modules\webpack-notifier\index.js:42:15)
	at module.exports.WebpackNotifierPlugin.compilationDone (my_project_root_dir\node_modules\webpack-notifier\index.js:57:20)
	at AsyncSeriesHook.eval [as callAsync] (eval at create (my_project_root_dir\node_modules\tapable\lib\HookCodeFactory.js:32:10), <anonymous>:9:1)
	at AsyncSeriesHook.lazyCompileHook (my_project_root_dir\node_modules\tapable\lib\Hook.js:154:20)
	at emitRecords.err (my_project_root_dir\node_modules\webpack\lib\Compiler.js:257:22)
	at Compiler.emitRecords (my_project_root_dir\node_modules\webpack\lib\Compiler.js:371:39)
	at emitAssets.err (my_project_root_dir\node_modules\webpack\lib\Compiler.js:251:10)
	at hooks.afterEmit.callAsync.err (my_project_root_dir\node_modules\webpack\lib\Compiler.js:357:14)
	at _err0 (eval at create (my_project_root_dir\node_modules\tapable\lib\HookCodeFactory.js:32:10), <anonymous>:20:1)
	at my_project_root_dir\node_modules\assets-webpack-plugin\dist\index.js:148:9
	at my_project_root_dir\node_modules\assets-webpack-plugin\dist\lib\output\createQueuedWriter.js:16:7
	at my_project_root_dir\node_modules\assets-webpack-plugin\dist\lib\output\createOutputWriter.js:74:13
	at my_project_root_dir\node_modules\graceful-fs\graceful-fs.js:45:10
	at FSReqWrap.oncomplete (fs.js:135:15)
error Command failed with exit code 1.

Deactivating the build notifications solves the problem, but then I have no build notifications.

I debugged the script at line 25, in this case error really is undefined, this.lastBuildSucceeded is false, stats.hasErrors() is false, but stats.hasWarnings() is true. Yet, stats.compilation.warnings is an empty array.

Gvozd commented

@YetiCGN
Please try the latest version
Does the problem recur?

Please give a minimally reproducible example (preferably in the form of a repository) that reproduces the problems

@Gvozd Wow, you had me digging through my history from almost two years ago, but I did find the project I was working on at the moment and it still had this part in its webpack.config.js:

// show OS notifications when builds finish/fail
// FIXME Deactivated due to https://github.com/Turbo87/webpack-notifier/issues/52
//.enableBuildNotifications()

But I can confirm that the problem doesn't occur with the latest 1.10.1.