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

Webpack 5 support #1584

Closed
orvillelim opened this issue Apr 15, 2021 · 9 comments · Fixed by #1796
Closed

Webpack 5 support #1584

orvillelim opened this issue Apr 15, 2021 · 9 comments · Fixed by #1796

Comments

@orvillelim
Copy link

Hi will there be any Webpack 5 support anytime soon?

rohit-gohri added a commit to rohit-gohri/redocusaurus that referenced this issue May 12, 2021
Added back node polyfills until redoc supports Webpack 5: Redocly/redoc#1584

Closes #25 #37
rohit-gohri added a commit to rohit-gohri/redocusaurus that referenced this issue May 12, 2021
Added back node polyfills until redoc supports Webpack 5: Redocly/redoc#1584

Closes #25 #37
@rohit-gohri
Copy link

rohit-gohri commented May 13, 2021

This is what you'll need to add to webpack config to fix build for webpack 5 or for use with latest docusaurus beta:

import webpack from 'webpack';
import NodePolyfillPlugin from 'node-polyfill-webpack-plugin';

const webpackConfig = {
  resolve: {
    fallback: {
      fs: false,
    },
  },
  plugins: [
    new webpack.DefinePlugin({
      "process.versions.node": JSON.stringify(process.versions.node || "0.0.0"),
    }),
    new NodePolyfillPlugin(),
  ],
};

If more errors pop up then this article was really helpful for debugging:
https://indepth.dev/posts/1166/this-will-make-you-more-efficient-at-debugging-webpack-unspecified-build-errors

@pglezen
Copy link

pglezen commented May 13, 2021

I ran into this trouble when I attempted to upgrade my Docusaurus installation to the beta version, which internally updates its webpack to v5.

@rohit-gohri
Copy link

I ran into this trouble when I attempted to upgrade my Docusaurus installation to the beta version, which internally updates its webpack to v5.

@pglezen Off topic but I have made a redoc preset for docusaurus, might be useful to you: https://github.com/rohit-gohri/redocusaurus

@theophile-scrive
Copy link

If I understand correctly, the beta version is unusable because it switches to webpack5 (which is not supported)?

Is there a way to constrain the webpack version as an end-user?

@clarencedesmarais
Copy link

clarencedesmarais commented Nov 12, 2021

Tried the solution proposed by @rohit-gohri , unfortunately did not work for me with "webpack": "5.62.1" , still getting :

 Can't resolve 'fs' in path-to-app/node_modules/redoc/bundles

@rohit-gohri
Copy link

Tried the solution proposed by @rohit-gohri , unfortunately did not work for me with "webpack": "5.62.1" , still getting :

 Can't resolve 'fs' in path-to-app/node_modules/redoc/bundles

Updated my answer above to add this:

  resolve: {
    fallback: {
      fs: false,
    },
  },

to fix this error.

@pglezen
Copy link

pglezen commented Nov 18, 2021

This is what you'll need to add to webpack config to fix build for webpack 5 or for use with latest docusaurus beta:

...

I'm sorry for being dense. But where does one find/create a webpack.config.js in a typical Docusaurus project?

@rohit-gohri
Copy link

This is what you'll need to add to webpack config to fix build for webpack 5 or for use with latest docusaurus beta:
...

I'm sorry for being dense. But where does one find/create a webpack.config.js in a typical Docusaurus project?

I think that requires creating a plugin.

You might be interested in https://github.com/rohit-gohri/redocusaurus for a prebuilt solution for adding redoc to Docusaurus.

Or if you want to do it yourself, then this gist gives an example: https://gist.github.com/rohit-gohri/59d0e6a9b4f51d1dd39f5e8894050f74

@10thfloor
Copy link

Confirmed this works for Redoc + Gatsby as well.

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

Successfully merging a pull request may close this issue.

9 participants