workers-sdk
workers-sdk copied to clipboard
Cloudflare Workers REPL
Describe the solution
While it’s nice to use stackblitz etc for making a quick worker, it’s not great to have to define an http interface for input and out put. It would be nice to have a repl style interface for quickly running code.
How's this? 🙂
miniflare --repl
> await new HTMLRewriter().on("p", { element(e) { e.setInnerContent("new") } }).transform(new Response("<p>old</p>")).text()
'<p>new</p>'
> const id = env.COUNTER.newUniqueId()
undefined
> const stub = env.COUNTER.get(id)
undefined
> await (await stub.fetch("/")).text()
'1'
> await (await stub.fetch("/")).text()
'2'
>
Automatically loads scripts/bindings from wrangler.toml files too, so your Durable Objects/KV namespaces work out-of-the-box.
amazing!!! is this available as an api? we can then do all our custom build stuff that we do
Yep!
import { Miniflare } from "miniflare";
const mf = new Miniflare(...);
mf.startREPL();
you're so awesome
Potentially can have a rethink in the future once we know more clearly the repl story with the open source runtime.
was this completed, or is this not going to be done?
@threepointone sorry about that, I should've clarified before closing. This is something we're not going to do for now. We can definitely reevaluate that once miniflare is the default for local dev.