Skip to content

repl: integrate experimental repl

Rodrigo Muino Tomonari requested to merge github/fork/RedYetiDev/patch-11 into main

Summary

This PR introduces an overhauled REPL for Node.js, inspired by the groundwork laid by @devsnek and their team on nodejs/repl. While significant changes have been made to the team's prototype REPL, credit for the concept belongs to them for their initial codebase.

Modifications

Technical

  • Class This REPL uses an ECMAScript class, rather than the REPLServer function prototype
  • Execution Context Contrary to the current REPL, which uses a mix of an inspector session and a virtual context, and the prototype REPL, which uses child_process and an inspector session, this REPL uses only a virtual context.

General

  • Syntax Highlighting Using the a custom implementation, syntax highlighting (in real-time) is now a feature of this REPL
  • (Coming Soon) Annotations Function annotations are under development
  • Runtime Variables Differing from the typical _ and _error variables, this REPL has an _X variable (where X is any line number)

Upcoming Features

These features are under development but are not included in this integration (as they are incomplete)

  • Anotations An annotations system, similar to that of the prototype REPL is under development

Usage

To try out this experimental REPL, users must enable it with the --experimental-repl CLI flag; otherwise, the stable REPL remains unaffected.

Limitations

While this iteration shows promise, it comes with certain limitations due to its experimental nature:

  1. Annotations is a work in progress. Although there's a prototype implementation, it heavily relies on 'requires'. I aim for a more dynamic approach, avoiding the generated one.
  2. Top-level await is unsupported

Why?

The Node.js REPL has remained unchanged for years, and it's time for a makeover.

[!CAUTION] This REPL is highly experimental, and its use may lead to unintended side effects.

Merge request reports

Loading