Open shallow-alchemy opened 1 day ago
guh, I'm totally going to get thumbs downed for this, but for anyone else stuck on this like we've been, my (admittedly hacky) current workaround is to put this in the remote:
import { mkdir, existsSync, writeFile } from 'fs'
const redText = '\x1b[1;37;41m'
const noPathMsg = 'No hostPath configured!'
const invalidPathMsg = 'No hostPath found. Please configure a path to an existing host application.'
const BD = '.remote' // BindingDirectory
const BFN = 'remote' // BindingFileName
const BE = '.binding' // BindingExtension
const RsBuildHostBinding = (hostPath): RsbuildPlugin => {
return ({
name: 'bindToHost',
setup(api) {
api.onDevCompileDone(() => {
if (!hostPath) return console.log(redText, noPathMsg)
if (!existsSync(hostPath)) return console.log(redText, invalidPathMsg)
mkdir(
`${hostPath}/${BD}`,
() => console.log(`Created ${BD} directory in host`)
)
writeFile(
`${hostPath}/${BD}/${BFN}${BE}`,
`${Date.now()}`,
() => console.log(`Updated ${BFN}${BE}`)
)
})
},
})
}
and add it to your plugins:
plugins: [ RsBuildHostBinding('../path/to/host/repo') ]
and to put this in your host:
dev: {
watchFiles: {
paths: '.remote',
type: 'reload-page'
}
},
and add the .remote
dir that the plugin creates to your .gitignore.
it ain't pretty, but we can dev now 😄
The hmr failed because rsbuild correct the server.port
meanings , it not equals dev.client.port
related pr https://github.com/web-infra-dev/rsbuild/pull/2639
And i update the example configuration to fix the issue https://github.com/module-federation/module-federation-examples/compare/fix/update-port?expand=1
adding the client port fixes it. Thank you for the quick response!
Describe the bug
Live reload does not work for example manifest protocol (this example)
Reproduction
Correct typescript and port errors and start above example using pnpm
Used Package Manager
npm
System Info
Validations