Skip to content

Enable top-level await in yarn rw console #1613

@jtoar

Description

@jtoar

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 the asyncRepl.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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions