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

Polish @babel/node REPL #12786

Merged
merged 2 commits into from Feb 10, 2021
Merged

Conversation

JLHwung
Copy link
Contributor

@JLHwung JLHwung commented Feb 9, 2021

Q                       A
Fixed Issues? Fixes #10739
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

This PR polishes the @babel/node REPL.

  • Toggled on preview: true REPL options: it will output the preview (like Chrome DevTools did) of evaluation result on supported node.js version (v13.4.0, v12.17.0)
  • setup history from process.env.NODE_REPL_HISOTRY, if it is not given, Node.js will default to ~/.node_repl_history (v11.10.0). Although we could implement REPL history support for lower versions, I don't think it is worthy since Babel 8 will drop Node < 12 support. Thanks for @0xdevalias offering a detailed report (babel-node should support NODE_REPL_HISTORY #10739) on this feature!

I marked this PR as Polish because there is no new options/methods added.

@JLHwung JLHwung added PR: Polish 💅 A type of pull request used for our changelog categories area: repl labels Feb 9, 2021
@babel-bot
Copy link
Collaborator

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/40085/

Copy link
Member

@nicolo-ribaudo nicolo-ribaudo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love when improvements are just a few lines of code 😂

@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 9, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit db1be54:

Sandbox Source
babel-repl-custom-plugin Configuration
babel-plugin-multi-config Configuration

Copy link
Member

@hzoo hzoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow nice!

my q with creating files is wondering how big they get without clearing (reminded of babel register cache, tho I'm sure this is much smaller)

@JLHwung
Copy link
Contributor Author

JLHwung commented Feb 10, 2021

@hzoo The ~/.node_repl_history is not created by Babel, it is created when you run a Node.js REPL or in this case we set up a REPL server if you have never run node REPL before. The change in this PR instruct node to reuse current ~/.node_repl_history. By default Node.js will clear REPL history when it is more than 1000 lines: https://nodejs.org/api/repl.html#repl_environment_variable_options

Note that if users do not want @babel/node reusing Node.js REPL history, they should provide their own REPL_HISTORY

NODE_REPL_HISTORY=~/.babel_node_repl_history babel-node

@nicolo-ribaudo
Copy link
Member

Does this need to wait for a minor version?

@JLHwung
Copy link
Contributor Author

JLHwung commented Feb 10, 2021

@nicolo-ribaudo I think it can be shipped in patch.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: repl outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Polish 💅 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

babel-node should support NODE_REPL_HISTORY
4 participants