Open rChaoz opened 1 day ago
This is probably doable. I wonder if there's any tools already doing this. I have a prototype based on Vite 6's module runner in https://github.com/hi-ogawa/vite-environment-examples/tree/main/examples/browser-cli.
To make it work like node's repl, we'll need more proper transforms to handle declarations let, const
and also add return
to the last expression statement. I just found Node does something like this https://github.com/nodejs/node/blob/746b17e1a5a9d09294b4c993a0319be6e5c39837/lib/repl.js#L432
Clear and concise description of the problem
I like to test part of my code in the Node interactive console, i.e. REPL:
However, this of course does not work because it doesn't resolve stuff (like the "$lib" alias, virtual modules etc.). For this, I use
vite-node
. But currently this only works with files - I have to create a file, run it withvite-node
, repeat.Suggested solution
Allow running
vite-node
without arguments to enter interactive mode (REPL).Alternative
Keep using files instead.
Additional context
No response
Validations