Will Playgroupd support Run and Log

我经常会有一些小想法在 Playground 验证
但是 Playground 只是把 ReScript 的代码编译成 JavaScript 代码
而我需要查看代码运行的结果,而编译后的 JS 代码,通常会依赖到 stdlib API 等
导致我也无法直接复制到 Console 中执行,因为缺少这些依赖
所以有没有可能在 Playground 中提供 Run 和 Log 的功能,像 TS 的 Playground 一样

I often have some ideas to validate in Playground
But Playground just compiles the ReScript code into JavaScript
I need to see the results of the code running
and the compiled JS code usually depends on the stdlib API
So, I couldn’t copy the JS code directly to the Console for execution
because of the lack of these dependencies

Is it possible to support Run and Log in Playgrounds, like TS Playground

This is TypeScript Playground

This is ReScript Playground

2 Likes

I was about to ask the same question. Now I have a sample rescript project where I try out my ideas. That was my work around for the issue

是的,我现在也是在本地有一个小项目。但是想把想法分享给朋友的话,还是不太方便。

Yes. I have a sample node project in my PC too. but when I want to share my ideas to my friends, Run and Log is more useful, I think

1 Like

Note the old playground I maintained used to support this feature.
It is supported through AMDJS under the hood

There’s an open PR but I’m not sure about its status.

Hi, author here! It’s currently blocked by a few things:

  • My spare time :sweat_smile: but anyone should feel free to build on the PR
  • The proposed approach where code is executed in a worker is blocked by a next.js bug (details in the PR)

There is also some more engineering to be done in figuring out how to load ReScript stdlib modules in the worker, but this seems doable from the conversations I’ve had.

There is also another WIP PR that works by executing the code in an iframe: https://github.com/rescript-association/rescript-lang.org/pull/420

1 Like

i’d also be keen on pushing this forward, since I have been neglecting the playground improvements for the longest time. The second half of this year has been quite busy, but I am sure we will get this done at some point :smiley:

I wonder if upgrading Next will fix the bug?

3 Likes