NormalModuleFactory.afterResolve is no longer a waterfall hook
When I tried Webpack 5 RC 0, I received the following error. It looks like this module may be the cause.
[email protected]
[email protected]
[email protected]
C:\Projects\MyProject\node_modules\webpack\lib\NormalModuleFactory.js:251
throw new Error(deprecationChangedHookMessage("afterResolve"));
^
Error: NormalModuleFactory.afterResolve is no longer a waterfall hook, but a bailing hook instead. Do not return the passed object, but modify it instead. Returning false will ignore the request and results in no module created.
at C:\Projects\MyProject\node_modules\webpack\lib\NormalModuleFactory.js:251:14
at Hook.eval [as callAsync] (eval at create (C:\Projects\MyProject\node_modules\webpack\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:14:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (C:\Projects\MyProject\node_modules\webpack\node_modules\tapable\lib\Hook.js:18:14)
at C:\Projects\MyProject\node_modules\webpack\lib\NormalModuleFactory.js:247:30
at eval (eval at create (C:\Projects\MyProject\node_modules\webpack\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:13:1)
at C:\Projects\MyProject\node_modules\webpack\lib\NormalModuleFactory.js:481:7
at C:\Projects\MyProject\node_modules\webpack\lib\NormalModuleFactory.js:116:11
at C:\Projects\MyProject\node_modules\webpack\lib\NormalModuleFactory.js:513:8
at NormalModuleFactory.resolveRequestArray (C:\Projects\MyProject\node_modules\webpack\lib\NormalModuleFactory.js:734:34)
at C:\Projects\MyProject\node_modules\webpack\lib\NormalModuleFactory.js:505:11
at C:\Projects\MyProject\node_modules\webpack\lib\NormalModuleFactory.js:116:11
at C:\Projects\MyProject\node_modules\webpack\lib\NormalModuleFactory.js:585:8
at C:\Projects\MyProject\node_modules\webpack\lib\NormalModuleFactory.js:721:5
at finishResolved (C:\Projects\MyProject\node_modules\webpack\node_modules\enhanced-resolve\lib\Resolver.js:267:11)
at C:\Projects\MyProject\node_modules\webpack\node_modules\enhanced-resolve\lib\Resolver.js:329:25
at C:\Projects\MyProject\node_modules\webpack\node_modules\enhanced-resolve\lib\Resolver.js:396:24
In particular, the returning here:
// at finishResolved (C:\Projects\SaxoTrader\node_modules\webpack\node_modules\enhanced-resolve\lib\Resolver.js:267:11)
const finishResolved = result => {
return callback(
null,
result.path === false
? false
: `${result.path}${result.query || ""}${result.fragment || ""}`,
result
);
};
Please create reproducible test repo
I'm not sure if I'll be able to do that I'm afraid. The modules involved all appear to be internal to webpack, we're not using them directly. Our build is large/complex with many plugins/loaders and can't be pared down to a reproduction case.
It only happens when using webpack-dev-middleware (3.7.2, which is compatible with webpack 5).
I'm ok if you want to close this, I'll reopen if I find any lines of investigation, and I'll try the next RC when it's released.
I think bug in plugin/loader, I can't help without configuration
This is a breaking change in webpack 5, but the error message is not very helpful in finding the offending plugin.
We should improve the error message.
By a process of elimination I found that https://github.com/pmmmwh/react-refresh-webpack-plugin/issues/27 was the issue, which has been fixed but yet to be released.
Agree with keeping this issue to improve the error message, thanks