[babel 8] Replace lodash/escapeRegExp with escape-string-regexp (#12677)
Co-authored-by: James Addison <jay@jp-hosting.net>
This commit is contained in:
@@ -54,6 +54,7 @@
|
||||
"@babel/types": "workspace:^7.12.10",
|
||||
"convert-source-map": "^1.7.0",
|
||||
"debug": "^4.1.0",
|
||||
"escape-string-regexp": "condition:BABEL_8_BREAKING ? ^4.0.0 : ",
|
||||
"gensync": "^1.0.0-beta.1",
|
||||
"json5": "^2.1.2",
|
||||
"lodash": "^4.17.19",
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// @flow
|
||||
import path from "path";
|
||||
import escapeRegExp from "lodash/escapeRegExp";
|
||||
|
||||
const escapeRegExp = process.env.BABEL_8_BREAKING
|
||||
? require("escape-string-regexp")
|
||||
: require("lodash/escapeRegExp");
|
||||
|
||||
const sep = `\\${path.sep}`;
|
||||
const endSep = `(?:${sep}|$)`;
|
||||
@@ -39,11 +42,13 @@ export default function pathToPattern(
|
||||
// *.ext matches a wildcard with an extension.
|
||||
if (part.indexOf("*.") === 0) {
|
||||
return (
|
||||
// $FlowIgnore
|
||||
substitution + escapeRegExp(part.slice(1)) + (last ? endSep : sep)
|
||||
);
|
||||
}
|
||||
|
||||
// Otherwise match the pattern text.
|
||||
// $FlowIgnore
|
||||
return escapeRegExp(part) + (last ? endSep : sep);
|
||||
}),
|
||||
].join(""),
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
"@babel/core": "workspace:^7.12.10",
|
||||
"@babel/helper-fixtures": "workspace:^7.12.12",
|
||||
"babel-check-duplicated-nodes": "^1.0.0",
|
||||
"escape-string-regexp": "condition:BABEL_8_BREAKING ? ^4.0.0 : ",
|
||||
"jest-diff": "^24.8.0",
|
||||
"lodash": "^4.17.19",
|
||||
"quick-lru": "5.1.0",
|
||||
|
||||
@@ -7,7 +7,6 @@ import {
|
||||
} from "@babel/helper-fixtures";
|
||||
import sourceMap from "source-map";
|
||||
import { codeFrameColumns } from "@babel/code-frame";
|
||||
import escapeRegExp from "lodash/escapeRegExp";
|
||||
import * as helpers from "./helpers";
|
||||
import merge from "lodash/merge";
|
||||
import assert from "assert";
|
||||
@@ -16,9 +15,13 @@ import path from "path";
|
||||
import vm from "vm";
|
||||
import checkDuplicatedNodes from "babel-check-duplicated-nodes";
|
||||
import QuickLRU from "quick-lru";
|
||||
|
||||
import diff from "jest-diff";
|
||||
|
||||
// $FlowIgnore
|
||||
const escapeRegExp = process.env.BABEL_8_BREAKING
|
||||
? require("escape-string-regexp")
|
||||
: require("lodash/escapeRegExp");
|
||||
|
||||
const cachedScripts = new QuickLRU({ maxSize: 10 });
|
||||
const contextModuleCache = new WeakMap();
|
||||
const sharedTestContext = createContext();
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
"./lib/nodeWrapper.js": "./lib/browser.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"escape-string-regexp": "condition:BABEL_8_BREAKING ? ^4.0.0 : ",
|
||||
"find-cache-dir": "condition:BABEL_8_BREAKING ? ^3.3.1 : ^2.0.0",
|
||||
"lodash": "^4.17.19",
|
||||
"make-dir": "^2.1.0",
|
||||
|
||||
@@ -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