Webpack.js.org: resolverFactory.plugin method is not a function

Created on 31 Oct 2020  路  10Comments  路  Source: webpack/webpack.js.org


Bug report




What is the current behavior?
I use a plugin called webpack-concat-plugin https://github.com/hxlniada/webpack-concat-plugin, which was working correctly with webpack version 4.
When trying to migrate to version 5 I've got this error

compiler.resolverFactory.plugin is not a function

This is where the code is failing: https://github.com/hxlniada/webpack-concat-plugin/blob/master/index.js#L121
Initially I thought there was some migration necessary, but checking webpack documentation says that should still be available and this plugin is using that exactly like in the docs here https://webpack.js.org/api/resolvers/

I did some investigation and saw that the ResolverFactory in version 4 extended Tapable and that plugin method was coming from there.

Not sure if this is a bug in webpack version 5, or if the documentation is incorrect about that method being available.
I checked the migration docs and couldn't find anything about it.

If the current behavior is a bug, please provide the steps to reproduce.
I don't know how to build a plugin, but the plugin that I mentioned (webpack-concat-plugin) above is really simple and relies on that possibly deprecated method.

import ConcatPlugin from '../../../index';

module.exports = {
    entry: './index.js',
    plugins: [
        new ConcatPlugin({
            name: 'file',
            fileName: '[name].js',
            filesToConcat: ['../../fixtures/a.js', '../../fixtures/b.js', 'is-object']
        })
    ],
};






What is the expected behavior?
This plugin should work, since the documentation says to use compiler.resolverFactory.plugin. Or the documentation should not include that information and provide a migration path.


Other relevant information:
webpack version: 5.3.2
Node.js version: 12.18.4
Operating System: Windows 10
Additional tools:

Most helpful comment

Will check the deprecation note in v4 and fix that library. Thank you.

@jandreola Did you manage to fix webpack-concat-plugin
I have the same issue.

All 10 comments

For maintainers only:

  • [ ] webpack-4
  • [ ] webpack-5
  • [ ] bug
  • [ ] critical-bug
  • [ ] enhancement
  • [ ] documentation
  • [ ] performance
  • [ ] dependencies
  • [ ] question

Please open an issue in webpack-concat-plugin, this plugin uses old API and it was removed

No changelog, because it was in changelog for v4 and will be deprecated for v4, in v5 we just remove it

I will open an issue for updating docs

Let's keep open

Will check the deprecation note in v4 and fix that library. Thank you.

Yes, you need to migrate on hooks, please use:

compiler.resolverFactory.hooks.resolver.for('normal').tap('name', (resolver) => {
 // Resolver here
});

more complex case:

compiler.resolverFactory.hooks.resolver
  .for('normal')
  .tap('name', (resolver) => {
    resolver.hooks.result.tap('MyPlugin', (result) => {
    console.log(result);
    return result;
  });
});

/cc @chenxsan need update https://webpack.js.org/api/resolvers/ page

WIP.

Will check the deprecation note in v4 and fix that library. Thank you.

@jandreola Did you manage to fix webpack-concat-plugin
I have the same issue.

why it's closed? Having the same error on latest concat plugin version

Was this page helpful?
0 / 5 - 0 ratings