Redwood REPL (Codepen, Codesandbox, Other?)

Something I’ve thought off and on about for a while is the virtue of really simple REPL’s like Svelte has on their website. A good stopgap to getting a full blown REPL would be something like a Codesandbox which has presets for things like Gatsby, Next, and Nuxt and even Blitz has one.

My intuition is that it would be harder to do on Codepen than Codesandbox but I could be wrong about that. I have no idea what it would take to get something like this going for Redwood, but I wanted to throw it out there for the community if anyone has thoughts on this.

1 Like

I listened to a DevNews podcast episode a while ago where they talked about CodeSandbox getting a bunch of funding. And they also talked about how people were using CodeSandbox, and it made me think about having CodeSandbox embedded on the RedwoodJS page, with a project setup and loaded that people could just play around with. With their Docker container sandboxes I think it would be possible to get Redwood running.
But one thing we wouldn’t be able to show off is our awesome VSCode plugin.

Yes that’s perfect, that basically merges the two things I had in my mind (REPL on the home page, something to do with Codesandbox).

I would guess we’d want to get something simple set up first and then find a way to layer the VSCode plugin on top. But that’s way outside my expertise and would be a question for @aldonline.

Unfortunately it’s not that simple. CodeSandbox themselves have to port the extension to make it work. Here’s the list of extensions they have available https://github.com/codesandbox/codesandbox-client/tree/master/standalone-packages/vscode-extensions/out/extensions

@dom you started work on this, yes? Tried to find the PR but seems you closed it out.

Any thoughts/learnings from your exploration?

@thedavid yes so far it’s one of those forever-a-draft PRs:

The hard parts were: 1) getting a node.js + babel REPL, 2) making sure top-level await is enabled (it was an experimental feature at the time; I think it still is), and 3) knowing how to use the @redwoodjs/structure package.

But I think what I briefly tried to do here differs from what @ajcwebdev is suggesting (please chime in to correct me)–Anthony is saying that we should have a live Redwood project, whereas this is having a REPL specific to your project, mainly to interact with the database.

2 Likes

Correct I’m thinking about a general project that basically starts you off with the splash page and you could immediately start using the CLI and building a project. So there wouldn’t be any database at all beyond what you would need to mock.

Any reason we can’t merge this as a start? I’ve had several instances recently where I just wanted to open a REPL and write some prisma queries for the tutorial without having to actually open the app in dev mode, write the service, write the SDL, write the front-end query, UGH.

2 Likes

@rob I remembered there being a REPL in Prisma Studio so I was gonna direct you there since that’s also integrated with Redwood, but I just fired it up and it doesn’t seem to be there anymore.

Yargs doesn’t have a way to label a command as experimental yet (see: https://github.com/yargs/yargs/issues/1638), which would be a nice-to-have here. But isn’t a breaking change or anything, so I’m game! For merging this. I just pulled it down; it still works and would definitely solve your problem.

2 Likes