UNPKG

are-you-es5

Version:

A package to help you find out which of your `node_modules` aren't ES5 so you can add them to your transpilation steps.

38 lines 1.61 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const crossEnvSlash = '[\\/]'; const nodeModules = `${crossEnvSlash}node_modules${crossEnvSlash}`; const escape = (dep) => dep.replace('/', '\\/'); /** Create a string regexp from a list of dependencies */ function getBabelLoaderIgnoreRegex(dependencies) { // [\\\\/] is a bit confusing but what it's doing is matching either a // backslash or forwards slash. Forwards slashes don't need to be // escaped inside a character group, and we need to escape the // backslash twice because we're in a string, and in a regex. // // If you console.log the regex it'll actually turn into: // [\\/] // // Printing out a regexp isn't proposing this escaped return `/[\\\\/]node_modules[\\\\/](?!(${dependencies .map(escape) .join('|')})[\\\\/])/`; } exports.getBabelLoaderIgnoreRegex = getBabelLoaderIgnoreRegex; /** * Create a Regexp that includes a list of dependencies * @param dependencies list of dependencies to include */ function buildIncludeRegexp(dependencies) { return new RegExp(`${nodeModules}?(${dependencies.map(escape).join('|')})${crossEnvSlash}`); } exports.buildIncludeRegexp = buildIncludeRegexp; /** * Create a Regexp that excludes a list of dependencies * @param dependencies list of dependencies to excludes */ function buildExcludeRegexp(dependencies) { return new RegExp(`${nodeModules}(?!(${dependencies.map(escape).join('|')})${crossEnvSlash})`); } exports.buildExcludeRegexp = buildExcludeRegexp; //# sourceMappingURL=babel-loader-regex-builder.js.map