Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NormalModuleFactory.afterResolve is no longer a waterfall hook #248

Open
robatwilliams opened this issue Sep 21, 2020 · 5 comments
Open

Comments

@robatwilliams
Copy link

When I tried Webpack 5 RC 0, I received the following error. It looks like this module may be the cause.

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
  );
};
@alexander-akait
Copy link
Member

Please create reproducible test repo

@robatwilliams
Copy link
Author

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.

@alexander-akait
Copy link
Member

I think bug in plugin/loader, I can't help without configuration

@sokra
Copy link
Member

sokra commented Sep 21, 2020

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.

@robatwilliams
Copy link
Author

By a process of elimination I found that pmmmwh/react-refresh-webpack-plugin#27 was the issue, which has been fixed but yet to be released.

Agree with keeping this issue to improve the error message, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants