Skip to content

Commit

Permalink
Allow -r from node_modules with @babel/node
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Dec 16, 2019
1 parent 0b3f883 commit a1dacfc
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/babel-node/package.json
Expand Up @@ -25,6 +25,7 @@
"lodash": "^4.17.13",
"node-environment-flags": "^1.0.5",
"regenerator-runtime": "^0.13.3",
"resolve": "^1.13.1",
"v8flags": "^3.1.1"
},
"peerDependencies": {
Expand Down
9 changes: 4 additions & 5 deletions packages/babel-node/src/_babel-node.js
Expand Up @@ -8,6 +8,7 @@ import vm from "vm";
import "core-js/stable";
import "regenerator-runtime/runtime";
import register from "@babel/register";
import resolve from "resolve";

import pkg from "../package.json";

Expand Down Expand Up @@ -188,11 +189,9 @@ if (program.eval || program.print) {

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

// make the filename absolute
Expand Down
@@ -0,0 +1 @@
console.log("dep");
@@ -0,0 +1 @@
console.log("foo");
@@ -0,0 +1,3 @@
{
"args": ["foo", "-r", "./dep"]
}
@@ -0,0 +1,2 @@
dep
foo

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a1dacfc

Please sign in to comment.