shaketbaby / directory-named-webpack-plugin

A Webpack plugin that treats a file with the name of directory as the index file
MIT License
182 stars 17 forks source link

TypeError: resolver.ensureHook is not a function #37

Closed nooikko closed 4 years ago

nooikko commented 4 years ago

Test Repo: (replication commands in the repo) https://github.com/elijah-penney/self-built-react

Description: Upon adding new DirectoryNamedWebpackPlugin() to my webpack.common.js, the error immediately appears on any build that utilizes that config. Adding a config object or true does not change the results of the bug.

Full Error:

TypeError: resolver.ensureHook is not a function
    at module.exports.doApply (C:\Users\Tandry\Documents\development\self-built-react\node_modules\directory-named-webpack-plugin\index.js:28:25)
    at webpack (C:\Users\Tandry\Documents\development\self-built-react\node_modules\webpack\lib\webpack.js:51:13)
    at startDevServer (C:\Users\Tandry\Documents\development\self-built-react\node_modules\webpack-dev-server\bin\webpack-dev-server.js:94:16)
    at C:\Users\Tandry\Documents\development\self-built-react\node_modules\webpack-dev-server\bin\webpack-dev-server.js:166:3
    at C:\Users\Tandry\Documents\development\self-built-react\node_modules\webpack-dev-server\lib\utils\processOptions.js:33:9
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

Versions:

I reviewed #28 which appears to have the same error but pertaining to using an older version of Webpack with Storybook. Since I'm not using Storybook, nor an older version of Webpack, the solutions in that ticket didn't resolve my issue.

Any ideas?

nooikko commented 4 years ago

Looks like I was just missing an object layer. I had:

plugins: [
    new DirectoryNamedWebpackPlugin()
]

instead of:

resolve: {
    plugins: [
      new DirectoryNamedWebpackPlugin()
    ]
  }
shaketbaby commented 4 years ago

That was my suspicion and was going to ask but I was distracted and forgot. Sorry about that and glad you worked it out.