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

Allow using custom config in babel-node --eval #16642

Merged

Conversation

slatereax
Copy link
Contributor

@slatereax slatereax commented Jul 13, 2024

Q                       A
Fixed Issues? Fixes #11877, fixes #16675
Patch: Bug Fix? Yes
Major: Breaking Change?
Minor: New Feature?
Tests Added Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

Transform code for babel-node eval does not use the options that were passed in the cli flags. Also, replPlugin, which is used for code transformation, only allows var variables, although modern versions of node repl support let and const.

Based on the history of this file, it appears that this code was written in 2017 when node did not support any variables other than var, but there is no need for this check now. If anyone needs to use babel-node with node < 6.0.0, they can pass their configuration file through --config-file.

@babel-bot
Copy link
Collaborator

babel-bot commented Jul 13, 2024

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

Co-authored-by: Huáng Jùnliàng <[email protected]>
@slatereax slatereax requested a review from JLHwung July 15, 2024 00:26
@nicolo-ribaudo nicolo-ribaudo added PR: Bug Fix 🐛 A type of pull request used for our changelog categories pkg: cli pkg: node and removed pkg: cli labels Jul 15, 2024
Copy link
Contributor

@JLHwung JLHwung left a comment

Choose a reason for hiding this comment

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

Thanks.

@nicolo-ribaudo nicolo-ribaudo added PR: New Feature 🚀 A type of pull request used for our changelog categories and removed PR: Bug Fix 🐛 A type of pull request used for our changelog categories labels Jul 15, 2024
@nicolo-ribaudo nicolo-ribaudo added this to the v7.25.0 milestone Jul 15, 2024
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.

Thanks!

@nicolo-ribaudo nicolo-ribaudo added the PR: Ready to be Merged A pull request with already two approvals, but waiting for the next minor release label Jul 17, 2024
@JLHwung
Copy link
Contributor

JLHwung commented Jul 24, 2024

@slatereax
I realize that this PR does not add new tests, could you add two new tests to packages/babel-node/test/fixtures/cli ? One for #11877 and another one for #16675. You can check that folder to see how tests are constructed.

@JLHwung JLHwung self-requested a review July 24, 2024 20:49
@nicolo-ribaudo
Copy link
Member

@JLHwung I added two tests, please take a look!

@JLHwung
Copy link
Contributor

JLHwung commented Jul 25, 2024

@JLHwung I added two tests, please take a look!

Thanks, in #11877 we do load configs but they are not passed to the eval transform so the new tests are actually passing on the main branch. Can you add a simple plugin to manipulate the input source? So that we are sure the resolved config is applied.

@nicolo-ribaudo
Copy link
Member

Done!

@nicolo-ribaudo nicolo-ribaudo changed the title Allow using custom config in babel-node eval and fix code transform Allow using custom config in babel-node --eval Jul 26, 2024
@nicolo-ribaudo nicolo-ribaudo merged commit 0a26578 into babel:main Jul 26, 2024
51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: node PR: New Feature 🚀 A type of pull request used for our changelog categories PR: Ready to be Merged A pull request with already two approvals, but waiting for the next minor release
Projects
None yet
4 participants