Only compile files inside the cwd in babel-register. (#5590)

This commit is contained in:
Logan Smyth
2017-09-01 22:07:26 -07:00
committed by Henry Zhu
parent 5df70e6a94
commit d6ba4d0a24

View File

@@ -107,16 +107,11 @@ export default function register(opts?: Object = {}) {
Object.assign(transformOpts, opts);
if (!transformOpts.ignore && !transformOpts.only) {
transformOpts.only = [
// Only compile things inside the current working directory.
new RegExp("^" + escapeRegExp(process.cwd()), "i"),
];
transformOpts.ignore = [
// Ignore any node_modules content outside the current working directory.
new RegExp(
"^(?!" +
escapeRegExp(process.cwd()) +
").*" +
escapeRegExp(path.sep + "node_modules" + path.sep),
"i",
),
// Ignore any node_modules inside the current working directory.
new RegExp(
"^" +