Skip to content

feat: auto-register extension dev servers with host#2220

Open
dschmidt wants to merge 1 commit intofeat/module-federationfrom
feat/dev-remote-registration
Open

feat: auto-register extension dev servers with host#2220
dschmidt wants to merge 1 commit intofeat/module-federationfrom
feat/dev-remote-registration

Conversation

@dschmidt
Copy link
Contributor

Summary

Remote extension dev servers automatically register themselves with the host dev server on startup — no more manual config.json editing for dev.

  • Host (vite.config.ts): REST API at /_dev/apps (POST/DELETE/GET), health check every 10s, merges registered remotes into /config.json proxy response, triggers browser reload via HMR
  • Remote (extension-sdk): Registration plugin posts to host on httpServer.listening, watches src/manifest.json and src/config.json for changes and re-registers
  • Config: Reads manifest.json defaults + config.json overrides with deep merge (matches Go-side mergo behavior)
  • Cleanup: Host health check removes unreachable remotes within 10s

How it works

  1. Start host: pnpm vite (port 9201)
  2. Start any extension: pnpm vite (any port)
  3. Extension auto-registers → browser reloads → app appears
  4. Stop extension → health check cleans up → browser reloads → app gone
  5. Edit src/manifest.json or src/config.json → re-registers → browser reloads with new config

Configuration

Option Default Description
overrides.hostUrl https://host.docker.internal:9201 Host dev server URL
OPENCLOUD_WEB_HOST_URL env (same) Alternative to override in code

Debug

curl -sk https://host.docker.internal:9201/_dev/apps

Test plan

  • Start host, then start extension → app auto-appears
  • Edit manifest.json config → browser reloads with updated config
  • Stop extension (Ctrl+C) → health check removes it within 10s
  • Start extension before host → graceful failure, works after host starts + reload
  • Multiple extensions on different ports simultaneously

@dschmidt dschmidt force-pushed the feat/module-federation branch from d63c892 to 02aefea Compare March 25, 2026 12:02
@dschmidt dschmidt force-pushed the feat/dev-remote-registration branch from adb2b46 to 362d63c Compare March 25, 2026 12:02
@dschmidt
Copy link
Contributor Author

A few minor things to improve:

 const hostUrl =
      overrides?.hostUrl ||
      process.env.OPENCLOUD_WEB_HOST_URL ||
      'https://host.docker.internal:9201'

These names aren't great.

I noticed that we detect when remotes/apps become stale, but if the Web Vite instance is restarted - apps never reregister..

@dschmidt dschmidt force-pushed the feat/module-federation branch from 7c32f22 to 4ab6bad Compare March 25, 2026 12:52
@dschmidt dschmidt force-pushed the feat/dev-remote-registration branch from 362d63c to 47be114 Compare March 25, 2026 12:52
@dschmidt dschmidt force-pushed the feat/module-federation branch from 4ab6bad to 2419cca Compare March 25, 2026 12:56
@dschmidt dschmidt force-pushed the feat/dev-remote-registration branch from 47be114 to bda2b29 Compare March 25, 2026 12:57
@dschmidt dschmidt force-pushed the feat/module-federation branch from 2419cca to 8cb0109 Compare March 25, 2026 13:14
@dschmidt dschmidt force-pushed the feat/dev-remote-registration branch 2 times, most recently from 4ace702 to d91eff3 Compare March 25, 2026 13:30
@dschmidt dschmidt force-pushed the feat/module-federation branch from 8cb0109 to f496f9a Compare March 25, 2026 13:31
@dschmidt dschmidt force-pushed the feat/dev-remote-registration branch from d91eff3 to 8b8c296 Compare March 25, 2026 13:31
Remote extension dev servers automatically register themselves with the
host dev server on startup. The host merges registered remotes into
/config.json responses and triggers a browser reload.

- Host: REST API at /_dev/apps (POST/DELETE/GET) with health check
- Remote: registration plugin in extension-sdk with config watching
- Config: reads manifest.json defaults + config.json overrides (deep merge)
- Cleanup: host health check removes stale remotes every 10 seconds
@dschmidt dschmidt force-pushed the feat/dev-remote-registration branch from 8b8c296 to 42d3914 Compare March 25, 2026 13:49
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