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

[Bug]: webSocketURL cannot be configured #4345

Closed
Swivelgames opened this issue Jan 8, 2025 · 2 comments
Closed

[Bug]: webSocketURL cannot be configured #4345

Swivelgames opened this issue Jan 8, 2025 · 2 comments

Comments

@Swivelgames
Copy link

Swivelgames commented Jan 8, 2025

Version

**Remote Dev Environment:**

  System:
    OS: Linux 6.12 Arch Linux
    CPU: (8) x64 QEMU Virtual CPU version 2.5+
    Memory: 9.84 GB / 13.65 GB
    Container: Yes
    Shell: 5.9 - /usr/bin/zsh
  npmPackages:
    @rsbuild/core: ^1.1.13 => 1.1.13
    @rsbuild/plugin-react: ^1.1.0 => 1.1.0

**Docker Host:**

  System:
    OS: Linux 6.12 Arch Linux
    CPU: (16) x64 AMD Ryzen 7 5800X3D 8-Core Processor
    Memory: 54.26 GB / 62.72 GB
    Container: Yes
    Shell: 5.9 - /usr/bin/zsh

Details

I'm running rsbuild inside of a Docker container proxied behind Traefik.

rspack provides the ability to reconfigure the HMR websocket for these exact use-cases, but rsbuild doesn't appear to be respecting my options.

Reproduce Steps

I'm using the following RSPack Config:

import { pluginModuleFederation } from "@module-federation/rsbuild-plugin"
import { defineConfig } from "@rsbuild/core"
import { pluginReact } from "@rsbuild/plugin-react"

/**
 * RSPack Config
 */
export default defineConfig({
	plugins: [
		pluginReact(),
		pluginModuleFederation({
			name: "some_base_url",
			exposes: {
				"./button": "./src/button.tsx",
			},
			shared: ["react", "react-dom"],
		}),
	],
	server: {
		open: false,
		port: 3000,
		host: "0.0.0.0",
		base: "/some_base_url",
	},
	tools: {
		rspack: config => ({
			...config,
			devServer: {
				...(config.devServer || {}),
				client: {
					...(config.devServer?.client || {}),
					webSocketURL: {
						...(config.devServer?.client?.webSocketURL || {}),
						pathname: "/some_base_url",
					},
				},
			},
		}),
	},
})

It still seems to be requesting:

  • ws://localhost:3000/rsbuild-hmr

instead of:

  • ws://localhost:3000/some_base_url/rsbuild-hmr

I've tried other methods as well, including:

		rspack: config => ({
			...config,
			devServer: {
				...(config.devServer || {}),
				client: {
					...(config.devServer?.client || {}),
					webSocketURL: "ws://localhost:3000/some_base_url/global_ui",
				},
			},
		}),

And others. But none seem to be functional.

@chenjiahan
Copy link
Member

@Swivelgames
Copy link
Author

Whoops :/

That seems to have fixed it. My apologies!

import { pluginModuleFederation } from "@module-federation/rsbuild-plugin"
import { defineConfig } from "@rsbuild/core"
import { pluginReact } from "@rsbuild/plugin-react"

/**
 * RSPack Config
 */
export default defineConfig({
	plugins: [
		pluginReact(),
		pluginModuleFederation({
			name: "some_base_url",
			exposes: {
				"./button": "./src/button.tsx",
			},
			shared: ["react", "react-dom"],
		}),
	],
	server: {
		open: false,
		port: 3000,
		host: "0.0.0.0",
		base: "/some_base_url",
	},
	dev: {
		client: {
				path: "/some_base_url",
			},
		},
	},
})

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

No branches or pull requests

2 participants