Fork me on GitHub

has anybody played with webviews in vs code extensions with shadow-cljs / figwheel?


I'm trying to get a browser repl connected to a vscode webview that runs shadow-cljs source


I only have superficial knowledge of how the vscode extension scaffolding works, but it appears that it wants to load the js payload from a dynamically generated UUID. This is similar / same to how chrome/ff extensions work with some hashified resource locator inside the browser's own resource space. However, the UUID application also seems to rewrite the browser repl websocket server URL


in other words when you set up a browser repl, an injected <ws://localhost:9630/api/remote-relay>... becomes <ws://some-long-uuid-string:9630/api/remote-relay>...


If you have worked through this before, I'd be grateful for some pointers!


Got it. The answer is to explicitly set :devtools-url inside the :devtools map for the shadow-cljs build configuration. When not set, it will derive the URL from a dynamic function call (`shadow.cljs.devtools.client.env.get_ws_relay_url`). I didn't look deeper but I am guessing the dynamic URL picks up host (in this case, vs-code-wrapped) information for the websocket server address, and adding the explicit setting probably forces it to be a string constant


I hope this setup will allow faster vs code extension development. Set up the main extension instance to connect via cljs repl ( is a good guide). Then for webviews, with the configuration above, you can set up hot reload / browser-repl.