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

babel-node: support require flag in repl mode #12297

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 11 additions & 6 deletions packages/babel-node/src/_babel-node.js
Expand Up @@ -187,12 +187,7 @@ if (program.eval || program.print) {
});
args = args.slice(i);

// We have to handle require ourselves, as we want to require it in the context of babel-register
if (program.require) {
require(resolve.sync(program.require, {
basedir: process.cwd(),
}));
}
requireArgs();

// make the filename absolute
const filename = args[0];
Expand All @@ -206,10 +201,20 @@ if (program.eval || program.print) {

Module.runMain();
} else {
requireArgs();
replStart();
}
}

// We have to handle require ourselves, as we want to require it in the context of babel-register
function requireArgs() {
if (program.require) {
require(resolve.sync(program.require, {
basedir: process.cwd(),
}));
}
}

function replStart() {
repl.start({
prompt: "babel > ",
Expand Down