Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cloudflare Workers REPL #1263

Closed
threepointone opened this issue Jun 14, 2022 · 7 comments
Closed

Cloudflare Workers REPL #1263

threepointone opened this issue Jun 14, 2022 · 7 comments
Labels
blocked Blocked on other work discussion This issue is being used to discuss a topic rather than track a feature or bug. enhancement New feature or request

Comments

@threepointone
Copy link
Contributor

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.

@threepointone threepointone added enhancement New feature or request discussion This issue is being used to discuss a topic rather than track a feature or bug. labels Jun 14, 2022
mrbbot added a commit to cloudflare/miniflare that referenced this issue Jun 15, 2022
Adds a `--repl` flag to start an interactive REPL. Allows any other
option to be passed alongside, and automatically loads bindings from
`wrangler.toml` files too. Specifying a script is optional when
`--repl` is enabled.
@mrbbot
Copy link
Contributor

mrbbot commented Jun 15, 2022

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.

@threepointone
Copy link
Contributor Author

amazing!!! is this available as an api? we can then do all our custom build stuff that we do

@mrbbot
Copy link
Contributor

mrbbot commented Jun 15, 2022

Yep!

import { Miniflare } from "miniflare";
const mf = new Miniflare(...);
mf.startREPL();

@threepointone
Copy link
Contributor Author

you're so awesome

@cameron-robey
Copy link
Contributor

Potentially can have a rethink in the future once we know more clearly the repl story with the open source runtime.

@cameron-robey cameron-robey added the blocked Blocked on other work label Sep 15, 2022
@admah admah closed this as completed Jan 9, 2023
@threepointone
Copy link
Contributor Author

was this completed, or is this not going to be done?

@admah
Copy link
Contributor

admah commented Jan 9, 2023

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Blocked on other work discussion This issue is being used to discuss a topic rather than track a feature or bug. enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants