This is an experimental Vite plugin that lets you write functions in .container.ts, import them from your Worker, and call them like ordinary async functions. The call actually executes inside a Cloudflare Container (beta).
How it works (black magic):
It statically analyzes
.container.ts and “clips/crops” the function body passed to nodejsFn(...)Bundles that extracted code into a small Node server
Generates a Docker image for it and packages it for Cloudflare Containers
Vite rewrites imports of *.container.ts into generated proxy modules
At runtime, the proxy turns your function call into a container RPC (types preserved)
Caveats: very experimental, requires Cloudflare Containers + Durable Objects, args/returns must be serializable, cold starts exist. Feedback welcome on approach/edge cases.