Skip to content

Integrate prototype REPL into primary NodeJS #52510

Description

@avivkeller

What is the problem this feature will solve?

It might be worth considering upgrading the REPL, given the stability of the work happening at https://github.com/nodejs/repl. However, we would need to (probably) reduce its dependencies before proceeding.

Currently, it relies on the following packages:

    "acorn": "^8.7.1",
    "acorn-loose": "^8.3.0",
    "chalk": "^4.1.2",
    "emphasize": "^4.2.0",
    "strip-ansi": "^6.0.1",
    "ws": "^7.3.0"

Replacing chalk with util.inspect.colors seems feasible (I already have a completed local copy for this). We could substitute ws with WebSocket (native implementation) and strip-ansi with native or built-in methods.

acorn and acorn-loose are already in the /deps folder, leaving only emphasize.

emphasize has ten dependencies, so I'm unsure what we would do to reduce its size.

In summary, I think it's time to revisit the discussion around upgrading the REPL.

Activity

  1. avivkeller commented on Apr 13, 2024

    @avivkeller
    MemberAuthor

    This change will take a while to implement, but it would be good to get the ball rolling and start the discussion.

    /cc @devsnek as they were the primary contributor to the REPL repo (sorry)
    /cc @nodejs/repl for obvious reasons

  2. devsnek commented on Apr 13, 2024

    @devsnek
    Member

    i still use the prototype as my daily driver. there are still some interesting bugs in it though. for example if the child process (which runs all the code) becomes frozen it will not be killed after the parent exits. also if an input spans multiple lines, the highlighting can break cursor positioning. there are probably more I'm not thinking of...

  3. avivkeller commented on Apr 13, 2024

    @avivkeller
    MemberAuthor

    Well, maybe it's not ready to be merged just yet, but this issue is meant to start that conversation, so that it can be merged eventually.

    In regards to the little bugs with child_process, if we integrate this NodeJS internals (while new bugs will occur), we may resolve some old ones.

    (P.S. sorry for using the wrong pronouns! I'd hate it if someone did that to me)

  4. added
    replIssues and PRs related to the REPL subsystem.
    on Apr 13, 2024
  5. avivkeller commented on Apr 13, 2024

    @avivkeller
    MemberAuthor

    See nodejs/repl#54 for the drop of a few deps

  6. avivkeller commented on Apr 13, 2024

    @avivkeller
    MemberAuthor

    If we were to merge the REPL into main, we would still need to drop the WS and replace it with the internal inspector.

  7. avivkeller commented on Apr 13, 2024

    @avivkeller
    MemberAuthor

    After some hard work, I managed to (in my PR):

    Drop Dependencies (The main goal)

    1. Drop chalk (Replace with util.inspect.colors) Note that chalk is still pre-installed with emphasize

    2. Drop strip-ansi (Replace with basic implementation)

    3. Drop ws (Replace with inspector) Note that this change changes a lot, and may be unstable

    4. Drop child_process (Replace with inspector)

      Fixes "if the child process (which runs all the code) becomes frozen it will not be killed after the parent exits."

    Little Fixes

    These just came up when I was updating the codebase

    1. Fix multi-line preview
  8. avivkeller commented on Apr 20, 2024

    @avivkeller
    MemberAuthor

    Closing in favor of my PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues requesting new Node.js features.replIssues and PRs related to the REPL subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions