gen-html-bundle.ts – how to load custom code components

I’ve copied most of the genLoaderHtmlBundle function inside platform/wab/src/wab/server/loader/gen-html-bundle.ts to have my “own” html code generation endpoint with working hydration and without needing an additional framework. Also it’s a lot faster than the codegen endpoint (probably due to load etc).

The main problem I have now is that it only works with built-in components. When I use custom code components, it fails. I tried to register the components, as the loader gets initialized, but without success. When I change the host to the host that is used inside plasmic studio, I’m getting an Plasmic: doing a fresh fetch... Error: Error parsing JSON response: SyntaxError: Unexpected token '<', "<html lang"... is not valid JSON; status: 404; response [...] error. Probably because the host doesn’t respond how plasmic expects.

So how can I use the genLoaderHtmlBundle function with custom code components? Registering them inside the function seem to be ignored, and I don’t know how the host endpoint should be responding.

I am not aware of any attempts to do that, but registering the components after initPlasmicLoader should work if you have the components properly built and accessible in your server.

If you don’t have a hosted endpoint that’s able to perform the codegen, changing the host is only going to break the loader.