rohit-gohri / redocusaurus

OpenAPI for Docusaurus with Redoc
https://redocusaurus.vercel.app/
MIT License
600 stars 111 forks source link

Webpack missing in Peer Dependencies #322

Closed zackerydev closed 5 months ago

zackerydev commented 5 months ago

👋🏻 Hey there, we love this project and are using it for an internal documentation site.

We have somewhat of a special use case and I wanted to contribute this back just in case there's someone else who runs into this.

We are running a pnpm monorepo, with multiple applications, some on Webpack 4 and some on Webpack 5.

When using this plugin we were met with the following error:

  Error: Child compilation failed:
  NormalModuleFactory.beforeResolve (NormalModuleReplacementPlugin) 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.

The reason is - the docusaurus-theme-redoc components imports webpack but doesn't declare it in its peerDependencies.

Because of this pnpm does not know to give it 5, and as such it resolves to a random/most common version in our mono repo.

The quick workaround is to declare this in the root package.json:

  "pnpm": {
    "packageExtensions": {
      "docusaurus-theme-redoc": {
        "peerDependencies": {
          "webpack": "^5.89.0"
        }
      },
    },
}

I'll raise this PR to fix this shortly! Thanks for the great project!

rohit-gohri commented 5 months ago

Thanks for reporting! Would be happy to accept a PR. Monorepo bugs can be tricky