From 2a50c176cfb207e36d999d538051ce13d59d200c Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Mon, 21 Jan 2019 22:39:39 +0100 Subject: [PATCH] Make HMR still apply updates when there is a webpack warning (#6099) Fixes #5363 I noticed this happening when making some changes on the nextjs.org/learn app. Basically we didn't apply updates when a warning was emitted from webpack. This would cause issues for users using eslint-loader or similar too. --- packages/next/client/dev-error-overlay/hot-dev-client.js | 1 - test/integration/basic/next.config.js | 9 +++++++++ test/integration/basic/warning-loader.js | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 test/integration/basic/warning-loader.js diff --git a/packages/next/client/dev-error-overlay/hot-dev-client.js b/packages/next/client/dev-error-overlay/hot-dev-client.js index f2c5073d..7bb1648e 100644 --- a/packages/next/client/dev-error-overlay/hot-dev-client.js +++ b/packages/next/client/dev-error-overlay/hot-dev-client.js @@ -216,7 +216,6 @@ function processMessage (e) { if (obj.warnings.length > 0) { handleWarnings(obj.warnings) - break } if (obj.errors.length > 0) { diff --git a/test/integration/basic/next.config.js b/test/integration/basic/next.config.js index 35dcf0f6..738c742d 100644 --- a/test/integration/basic/next.config.js +++ b/test/integration/basic/next.config.js @@ -1,6 +1,15 @@ +const path = require('path') module.exports = { onDemandEntries: { // Make sure entries are not getting disposed. maxInactiveAge: 1000 * 60 * 60 + }, + webpack (config) { + config.module.rules.push({ + test: /pages[\\/]hmr/, + loader: path.join(__dirname, 'warning-loader.js') + }) + + return config } } diff --git a/test/integration/basic/warning-loader.js b/test/integration/basic/warning-loader.js new file mode 100644 index 00000000..730ce29a --- /dev/null +++ b/test/integration/basic/warning-loader.js @@ -0,0 +1,4 @@ +module.exports = function (source) { + this.emitWarning(new Error('This is an expected warning added by warning-loader.js')) + return source +}