1
Show HN: Vite plugin to call Node.js native code from CF Workers via Containers
Cloudflare Workers are great, but they’re not Node.js, so native addons don’t run. I wanted a way to keep writing a normal Workers app while still using Node-native libraries (canvas/sharp/etc), without standing up and maintaining a separate service.
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.