Don't use require() in ESM files (#12728)
* Update `yarn-plugin-conditions` * Don't use `require()` in ESM files
This commit is contained in:
5
packages/babel-core/src/config/helpers/escape-regexp.cjs
Normal file
5
packages/babel-core/src/config/helpers/escape-regexp.cjs
Normal file
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = process.env.BABEL_8_BREAKING
|
||||
? require("escape-string-regexp")
|
||||
: require("lodash/escapeRegExp");
|
||||
@@ -1,9 +1,8 @@
|
||||
// @flow
|
||||
import path from "path";
|
||||
|
||||
const escapeRegExp = process.env.BABEL_8_BREAKING
|
||||
? require("escape-string-regexp")
|
||||
: require("lodash/escapeRegExp");
|
||||
// $FlowIgnore
|
||||
import escapeRegExp from "./helpers/escape-regexp";
|
||||
|
||||
const sep = `\\${path.sep}`;
|
||||
const endSep = `(?:${sep}|$)`;
|
||||
@@ -42,13 +41,11 @@ 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(""),
|
||||
|
||||
Reference in New Issue
Block a user