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

HMR is broken #1785

Closed
flunderpero opened this issue Apr 25, 2021 · 6 comments
Closed

HMR is broken #1785

flunderpero opened this issue Apr 25, 2021 · 6 comments
Labels

Comments

@flunderpero
Copy link

Current behavior

When I run styleguidist server I get this in the browser console:

main.bundle.js:10926 Uncaught ReferenceError: process is not defined
    at eval (webpackHotDevClient.js:63)
    at Object../node_modules/react-dev-utils/webpackHotDevClient.js (main.bundle.js:4329)
    at __webpack_require__ (main.bundle.js:10923)
    at main.bundle.js:11966
    at main.bundle.js:11970

HMR is obviously not working. With webpack 5 process is no longer defined and the webpackHotDevClient.js first looks into process.env and then falls back to location in order to find the right HMR server. I think styleguidist just uses an old version.

The problem has been reported elsewhere, too: vue-styleguidist/vue-styleguidist#1044

To reproduce

Just start styleguidist 11.1.6 in server mode and look into the browser console.

Workaround
My current workaround is to define process.env like this in styleguide.config.js:

    webpackConfig: {
        plugins:[
            new webpack.DefinePlugin({
                process: {env: {}}
            })
        ]
    }
@elevatebart
Copy link
Collaborator

@sapegin It feels like we could mock process, if it does not exist ;)
Should I make a PR?

@sapegin
Copy link
Member

sapegin commented Apr 26, 2021

Sure, if that helps ;-)

@vileen
Copy link

vileen commented May 31, 2021

Huh, weird, for me it helped but caused another error WebSocket connection to 'ws://localhost:9000/sockjs-node' failed: and I don't even have sockjs-node

@schorfES
Copy link

As @flunderpero wrote, it's caused due to a miss-match between the webpack version and the styleguidist webpack-configuration. Styleguidist targets v4 of webpack, while following the getting started docs v5 would be installed as latest version. If there are no other dependencies in you project to webpack at version 5, you should downgrade webpack by running npm i -D webpack@4 – that helped me.

@adamjw3
Copy link

adamjw3 commented Sep 28, 2021

I've ran into the same error, i'm using next js and sass (webpack 5). @flunderpero i tried your fix with the plugins options but didn't work. can you share your full solution?

@stale
Copy link

stale bot commented Apr 16, 2022

😴 This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week without any further activity. Consider opening a pull request if you still have this issue or want this feature.

@stale stale bot added the wontfix label Apr 16, 2022
@stale stale bot closed this as completed Apr 27, 2022
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

6 participants