Skip to content
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

vite-node: Support interactive console (REPL) #6919

Closed
4 tasks done
rChaoz opened this issue Nov 17, 2024 · 2 comments
Closed
4 tasks done

vite-node: Support interactive console (REPL) #6919

rChaoz opened this issue Nov 17, 2024 · 2 comments
Labels
enhancement: pending triage p2-to-be-discussed Enhancement under consideration (priority)

Comments

@rChaoz
Copy link

rChaoz commented Nov 17, 2024

Clear and concise description of the problem

I like to test part of my code in the Node interactive console, i.e. REPL:

$ node
> const { myFunc } = await import("$lib/my/file")
> myFunc(123)

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 with vite-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

@rChaoz rChaoz changed the title vite-node: Support REPL vite-node: Support interactive console (REPL) Nov 17, 2024
@hi-ogawa
Copy link
Contributor

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

@hi-ogawa hi-ogawa moved this to P2 - 3 in Team Board Nov 18, 2024
@hi-ogawa hi-ogawa added the p2-to-be-discussed Enhancement under consideration (priority) label Nov 18, 2024
@sheremet-va sheremet-va moved this from P2 - 3 to Rejected in Team Board Nov 21, 2024
@hi-ogawa
Copy link
Contributor

Team decided that we don't add a new feature on top of vite-node anymore as we plan to migrate to use a primitive from Vite core directly. Repl-like feature can be implemented on top of Vite ssr/module runner level, so I'll experiment with that instead.

Thanks for the idea, but closing this issue for now.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement: pending triage p2-to-be-discussed Enhancement under consideration (priority)
Projects
Archived in project
Development

No branches or pull requests

2 participants