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

I may have a fix for "support for webpack v5" #1740

Closed
wh1t3h47 opened this issue Jan 31, 2021 · 6 comments
Closed

I may have a fix for "support for webpack v5" #1740

wh1t3h47 opened this issue Jan 31, 2021 · 6 comments
Labels

Comments

@wh1t3h47
Copy link

wh1t3h47 commented Jan 31, 2021

I am opening this issue because the original one was flagged as spam and I coudn't comment on it
#1703

I was able to solve this problem as described:
1 - Eject your project;
2 - Fix webpack configuration to port to webpack v5; how to do it?

There is also a comment which says something like TODO remove in webpack 5, remove the line below;

3 - Search for formatWebpackMessages(webpackMessages) inside config/build.js;
4 - Replace with the following block of code:

        const webpackMessages = stats.toJson({
          all: false,
          warnings: true,
          errors: true,
        });
        webpackMessages.errors = webpackMessages.errors.map(
          /** @param {object|string} error either from webpack 4 or 5 */
          (error) => (typeof error === 'string')? error: (error.message || ''),
        );
        messages = formatWebpackMessages(webpackMessages);
      }

I hope this helps.

EDIT:
Since we have to support webpack v4 and v5, I made the above code detect if the error object is from webpack 4

@wh1t3h47 wh1t3h47 reopened this Jan 31, 2021
@wh1t3h47 wh1t3h47 changed the title I have a fix for "support for webpack v5" I may have a fix for "support for webpack v5" Jan 31, 2021
@jasonwilliams
Copy link
Collaborator

@sapegin or @elevatebart why is #1703 locked? Can we re-open it? We need a space for webpack 5 issues to be raised

@rgbkrk

This comment has been minimized.

@elevatebart
Copy link
Collaborator

@jasonwilliams @rgbkrk unfortunately react-styleguidist is relying on a library that is part of create-react-app react-dev-utils. This library is not compatible with webpack 5 yet.

There is good news though: It will be getting updated soon as this PR has just been merged 11 days ago. When the lib is released I will update the dependency and release a version of rsg@11. Until then we can only hack a fix.

I have been (loosely) trying to do so but without success yet.

@juanca
Copy link
Contributor

juanca commented Sep 21, 2021

I was able to use the react-dev-utils pre-release in a fork for react-styleguidist. I don't know if people want to wait or perhaps react-styleguidist can also have a pre-release. I do have to fix a few things in my project using react-styleguidist but I don't think that's related to either styleguidist or react-dev-utils

https://github.com/juanca/react-styleguidist/tree/master

P.S. I would have made a PR but I don't seem to have a compatible version of NPM and I had to commit the artifacts.

@juanca
Copy link
Contributor

juanca commented Sep 21, 2021

It is almost 100% compatible as far as I can tell. There is some fixing needed in the web socket integration -- we seem to be trying to ship the process key to the frontend but it really needs to be replaced with some DefinePlugin.

Screen Shot 2021-09-21 at 12 49 02 PM

It is on line 63 of the attached screenshot.

@github-actions
Copy link

🎉 This issue has been resolved in version 11.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

No branches or pull requests

5 participants