Skip to content

fix!: HMR not work on online IDEs#2639

Merged
chenjiahan merged 1 commit intomainfrom
ide_hmr_0620
Jun 20, 2024
Merged

fix!: HMR not work on online IDEs#2639
chenjiahan merged 1 commit intomainfrom
ide_hmr_0620

Conversation

@chenjiahan
Copy link
Copy Markdown
Member

@chenjiahan chenjiahan commented Jun 20, 2024

Summary

Fix HMR not work on online IDEs (such as MarsCode).

The default value ofclient.port should be window.location.port instead of server.port, this allows online IDEs to proxy the ws requests to dev server correctly.

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@netlify
Copy link
Copy Markdown

netlify bot commented Jun 20, 2024

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit 9e75e2c
🔍 Latest deploy log https://app.netlify.com/sites/rsbuild/deploys/6673aa956081190008bf5f4b
😎 Deploy Preview https://deploy-preview-2639--rsbuild.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 79 (🔴 down 2 from production)
Accessibility: 97 (no change from production)
Best Practices: 100 (no change from production)
SEO: 92 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@chenjiahan chenjiahan merged commit 38f3340 into main Jun 20, 2024
@chenjiahan chenjiahan deleted the ide_hmr_0620 branch June 20, 2024 04:54
});
const devConfig = getDevConfig({
config,
port,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @chenjiahan, this should be a breaking change for v1.
This means that the dev config will no longer use the port passed from the server config.
I have a case where the assets are served on a different port (3000) than the webpack server (3800). I configured the server with the correct port 3800, but then the HMR broke because it was using the fallback on location.port which returns 3000 and not 3800.
The fix is to also specify the port for dev.client.port, which I think is a shame, if the webpack server has a different port, the HMR should follow it, unless we say otherwise by configuring it differently.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that this is a breaking change, I have updated the release note and added it to breaking change list. https://github.com/web-infra-dev/rsbuild/releases/tag/v1.0.0-alpha.0

Copy link
Copy Markdown
Member Author

@chenjiahan chenjiahan Jul 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I knew this change would break the websocket if client and server use different ports, and users need to set dev.client.port, it is expected. Vite also requires the similar setup (server.hmr.clientPort).

Copy link
Copy Markdown

@CPatchane CPatchane Jul 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok then, at least the breaking change is now documented, thanks!

@chenjiahan chenjiahan changed the title fix: HMR not work on online IDEs fix!: HMR not work on online IDEs Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants