[babel 8] Replace lodash/escapeRegExp with escape-string-regexp (#12677)
Co-authored-by: James Addison <jay@jp-hosting.net>
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import deepClone from "lodash/cloneDeep";
|
||||
import sourceMapSupport from "source-map-support";
|
||||
import * as registerCache from "./cache";
|
||||
import escapeRegExp from "lodash/escapeRegExp";
|
||||
import * as babel from "@babel/core";
|
||||
import { OptionManager, DEFAULT_EXTENSIONS } from "@babel/core";
|
||||
import { addHook } from "pirates";
|
||||
@@ -9,6 +8,11 @@ import fs from "fs";
|
||||
import path from "path";
|
||||
import Module from "module";
|
||||
|
||||
// $FlowIgnore
|
||||
const escapeRegExp = process.env.BABEL_8_BREAKING
|
||||
? require("escape-string-regexp")
|
||||
: require("lodash/escapeRegExp");
|
||||
|
||||
const maps = {};
|
||||
let transformOpts = {};
|
||||
let piratesRevert = null;
|
||||
@@ -145,16 +149,19 @@ export default function register(opts?: Object = {}) {
|
||||
if (transformOpts.ignore === undefined && transformOpts.only === undefined) {
|
||||
transformOpts.only = [
|
||||
// Only compile things inside the current working directory.
|
||||
// $FlowIgnore
|
||||
new RegExp("^" + escapeRegExp(cwd), "i"),
|
||||
];
|
||||
transformOpts.ignore = [
|
||||
// Ignore any node_modules inside the current working directory.
|
||||
new RegExp(
|
||||
"^" +
|
||||
// $FlowIgnore
|
||||
escapeRegExp(cwd) +
|
||||
"(?:" +
|
||||
path.sep +
|
||||
".*)?" +
|
||||
// $FlowIgnore
|
||||
escapeRegExp(path.sep + "node_modules" + path.sep),
|
||||
"i",
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user