-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Enable top-level await in yarn rw console #1613
Comments
@peterp at the contributor's meetup today, @mojombo suggested we resolve promises automatically. that could be a lot easier than enabling top-level await. I think we'd have to override the repl's eval, but there's examples for that. to be more explicit, using the console would just be like:
so everyone typing at the console would never have to type update: this might not be mutually exclusive with enabling top-level await, but just seems like it could be done sooner. |
Update (05.28.2021)
Right now we abstract away the need for top-level await in Redwood console by automatically resolving promises. This works but it'd I think it'd still be super nice to have top level await.
Original
Right now the console command requires the
NODE_OPTIONS
env var be set to--experimental-repl-await
. This isn't an ideal workflow, especially since the console command will be in the tutorial II, so I tried to fix this by using execa (see this PR: #1603). But now the repl is starting on every command. It seems that yargs is executing theasyncRepl.js
file no matter what.The only reason I abstracted the code to start the repl into another file was, you have to pass files to the node CLI:
node --experimental-repl-await asyncRepl.js
. Maybe you can just pass a giant string to be evaled (I didn't try) but that doesn't seem sustainable, especially once we add all the services to the repl's context.Another option is to hack the eval the repl uses: nodejs/node#13209 (comment).
Note that the console command breaks if the prisma client isn't generated. This definitely has to be fixed, but isn't the same problem.
The text was updated successfully, but these errors were encountered: