@babel/core
Advanced tools
Comparing version 7.0.0-beta.53 to 7.0.0-beta.54
@@ -19,12 +19,2 @@ "use strict"; | ||
function _micromatch() { | ||
const data = _interopRequireDefault(require("micromatch")); | ||
_micromatch = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _debug() { | ||
@@ -42,2 +32,4 @@ const data = _interopRequireDefault(require("debug")); | ||
var _patternToRegex = _interopRequireDefault(require("./pattern-to-regex")); | ||
var _files = require("./files"); | ||
@@ -143,3 +135,5 @@ | ||
if (!Array.isArray(babelrcPatterns)) babelrcPatterns = [babelrcPatterns]; | ||
babelrcPatterns = babelrcPatterns.map(pat => _path().default.resolve(context.cwd, pat)); | ||
babelrcPatterns = babelrcPatterns.map(pat => { | ||
return typeof pat === "string" ? _path().default.resolve(context.cwd, pat) : pat; | ||
}); | ||
@@ -150,3 +144,8 @@ if (babelrcPatterns.length === 1 && babelrcPatterns[0] === absoluteRoot) { | ||
return (0, _micromatch().default)(pkgData.directories, babelrcPatterns).length > 0; | ||
return babelrcPatterns.some(pat => { | ||
if (typeof pat === "string") pat = (0, _patternToRegex.default)(pat, context.cwd); | ||
return pkgData.directories.some(directory => { | ||
return matchPattern(pat, context.cwd, directory); | ||
}); | ||
}); | ||
} | ||
@@ -324,2 +323,3 @@ | ||
delete options.env; | ||
delete options.overrides; | ||
delete options.plugins; | ||
@@ -330,2 +330,5 @@ delete options.presets; | ||
delete options.only; | ||
delete options.test; | ||
delete options.include; | ||
delete options.exclude; | ||
@@ -389,36 +392,15 @@ if (options.sourceMap) { | ||
function configFieldIsApplicable(context, test, dirname) { | ||
if (typeof context.filename !== "string") { | ||
throw new Error(`Configuration contains explicit test/include/exclude checks, but no filename was passed to Babel`); | ||
} | ||
const ctx = context; | ||
const patterns = Array.isArray(test) ? test : [test]; | ||
return matchesPatterns(ctx, patterns, dirname, false); | ||
return matchesPatterns(context, patterns, dirname); | ||
} | ||
function shouldIgnore(context, ignore, only, dirname) { | ||
if (ignore) { | ||
if (typeof context.filename !== "string") { | ||
throw new Error(`Configuration contains ignore checks, but no filename was passed to Babel`); | ||
} | ||
const ctx = context; | ||
if (matchesPatterns(ctx, ignore, dirname)) { | ||
debug("Ignored %o because it matched one of %O from %o", context.filename, ignore, dirname); | ||
return true; | ||
} | ||
if (ignore && matchesPatterns(context, ignore, dirname)) { | ||
debug("Ignored %o because it matched one of %O from %o", context.filename, ignore, dirname); | ||
return true; | ||
} | ||
if (only) { | ||
if (typeof context.filename !== "string") { | ||
throw new Error(`Configuration contains ignore checks, but no filename was passed to Babel`); | ||
} | ||
const ctx = context; | ||
if (!matchesPatterns(ctx, only, dirname)) { | ||
debug("Ignored %o because it failed to match one of %O from %o", context.filename, only, dirname); | ||
return true; | ||
} | ||
if (only && !matchesPatterns(context, only, dirname)) { | ||
debug("Ignored %o because it failed to match one of %O from %o", context.filename, only, dirname); | ||
return true; | ||
} | ||
@@ -429,50 +411,18 @@ | ||
function matchesPatterns(context, patterns, dirname, allowNegation = true) { | ||
const res = []; | ||
const strings = []; | ||
const fns = []; | ||
patterns.forEach(pattern => { | ||
if (typeof pattern === "string") strings.push(pattern);else if (typeof pattern === "function") fns.push(pattern);else res.push(pattern); | ||
}); | ||
const filename = context.filename; | ||
if (res.some(re => re.test(context.filename))) return true; | ||
if (fns.some(fn => fn(filename))) return true; | ||
function matchesPatterns(context, patterns, dirname) { | ||
return patterns.some(pattern => matchPattern(pattern, dirname, context.filename)); | ||
} | ||
if (strings.length > 0) { | ||
const possibleDirs = getPossibleDirs(context); | ||
const absolutePatterns = strings.map(pattern => { | ||
const negate = pattern[0] === "!"; | ||
function matchPattern(pattern, dirname, pathToTest) { | ||
if (typeof pattern === "function") return !!pattern(pathToTest); | ||
if (negate && !allowNegation) { | ||
throw new Error(`Negation of file paths is not supported.`); | ||
} | ||
if (negate) pattern = pattern.slice(1); | ||
return (negate ? "!" : "") + _path().default.resolve(dirname, pattern); | ||
}); | ||
if ((0, _micromatch().default)(possibleDirs, absolutePatterns, { | ||
nocase: true, | ||
nonegate: !allowNegation | ||
}).length > 0) { | ||
return true; | ||
} | ||
if (typeof pathToTest !== "string") { | ||
throw new Error(`Configuration contains string/RegExp pattern, but no filename was passed to Babel`); | ||
} | ||
return false; | ||
} | ||
const getPossibleDirs = (0, _caching.makeWeakCache)(context => { | ||
let current = context.filename; | ||
if (typeof current !== "string") return []; | ||
const possibleDirs = [current]; | ||
while (true) { | ||
const previous = current; | ||
current = _path().default.dirname(current); | ||
if (previous === current) break; | ||
possibleDirs.push(current); | ||
if (typeof pattern === "string") { | ||
pattern = (0, _patternToRegex.default)(pattern, dirname); | ||
} | ||
return possibleDirs; | ||
}); | ||
return pattern.test(pathToTest); | ||
} |
@@ -66,2 +66,4 @@ "use strict"; | ||
var _patternToRegex = _interopRequireDefault(require("../pattern-to-regex")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -251,7 +253,16 @@ | ||
const readIgnoreConfig = (0, _utils.makeStaticFileCache)((filepath, content) => { | ||
const ignore = content.split("\n").map(line => line.replace(/#(.*?)$/, "").trim()).filter(line => !!line); | ||
const ignoreDir = _path().default.dirname(filepath); | ||
const ignorePatterns = content.split("\n").map(line => line.replace(/#(.*?)$/, "").trim()).filter(line => !!line); | ||
for (const pattern of ignorePatterns) { | ||
if (pattern[0] === "!") { | ||
throw new Error(`Negation of file paths is not supported.`); | ||
} | ||
} | ||
return { | ||
filepath, | ||
dirname: _path().default.dirname(filepath), | ||
ignore | ||
ignore: ignorePatterns.map(pattern => (0, _patternToRegex.default)(pattern, ignoreDir)) | ||
}; | ||
@@ -258,0 +269,0 @@ }); |
@@ -144,8 +144,8 @@ "use strict"; | ||
value.forEach((item, i) => { | ||
if (typeof item !== "string") { | ||
throw new Error(`.${key}[${i}] must be a string.`); | ||
if (!checkValidTest(value)) { | ||
throw new Error(`.${key}[${i}] must be a string/Function/RegExp.`); | ||
} | ||
}); | ||
} else if (typeof value !== "string") { | ||
throw new Error(`.${key} must be a undefined, a boolean, a string, ` + `or an array of strings, got ${JSON.stringify(value)}`); | ||
} else if (!checkValidTest(value)) { | ||
throw new Error(`.${key} must be a undefined, a boolean, a string/Function/RegExp ` + `or an array of those, got ${JSON.stringify(value)}`); | ||
} | ||
@@ -152,0 +152,0 @@ |
{ | ||
"name": "@babel/core", | ||
"version": "7.0.0-beta.53", | ||
"version": "7.0.0-beta.54", | ||
"description": "Babel compiler core.", | ||
@@ -33,9 +33,9 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@babel/code-frame": "7.0.0-beta.53", | ||
"@babel/generator": "7.0.0-beta.53", | ||
"@babel/helpers": "7.0.0-beta.53", | ||
"@babel/parser": "7.0.0-beta.53", | ||
"@babel/template": "7.0.0-beta.53", | ||
"@babel/traverse": "7.0.0-beta.53", | ||
"@babel/types": "7.0.0-beta.53", | ||
"@babel/code-frame": "7.0.0-beta.54", | ||
"@babel/generator": "7.0.0-beta.54", | ||
"@babel/helpers": "7.0.0-beta.54", | ||
"@babel/parser": "7.0.0-beta.54", | ||
"@babel/template": "7.0.0-beta.54", | ||
"@babel/traverse": "7.0.0-beta.54", | ||
"@babel/types": "7.0.0-beta.54", | ||
"convert-source-map": "^1.1.0", | ||
@@ -45,3 +45,2 @@ "debug": "^3.1.0", | ||
"lodash": "^4.17.5", | ||
"micromatch": "^2.3.11", | ||
"resolve": "^1.3.2", | ||
@@ -52,5 +51,5 @@ "semver": "^5.4.1", | ||
"devDependencies": { | ||
"@babel/helper-transform-fixture-test-runner": "7.0.0-beta.53", | ||
"@babel/register": "7.0.0-beta.53" | ||
"@babel/helper-transform-fixture-test-runner": "7.0.0-beta.54", | ||
"@babel/register": "7.0.0-beta.54" | ||
} | ||
} |
123465
14
42
3697
+ Added@babel/code-frame@7.0.0-beta.54(transitive)
+ Added@babel/generator@7.0.0-beta.54(transitive)
+ Added@babel/helper-function-name@7.0.0-beta.54(transitive)
+ Added@babel/helper-get-function-arity@7.0.0-beta.54(transitive)
+ Added@babel/helper-split-export-declaration@7.0.0-beta.54(transitive)
+ Added@babel/helpers@7.0.0-beta.54(transitive)
+ Added@babel/highlight@7.0.0-beta.54(transitive)
+ Added@babel/parser@7.0.0-beta.54(transitive)
+ Added@babel/template@7.0.0-beta.54(transitive)
+ Added@babel/traverse@7.0.0-beta.54(transitive)
+ Added@babel/types@7.0.0-beta.54(transitive)
- Removedmicromatch@^2.3.11
- Removed@babel/code-frame@7.0.0-beta.53(transitive)
- Removed@babel/generator@7.0.0-beta.53(transitive)
- Removed@babel/helper-function-name@7.0.0-beta.53(transitive)
- Removed@babel/helper-get-function-arity@7.0.0-beta.53(transitive)
- Removed@babel/helper-split-export-declaration@7.0.0-beta.53(transitive)
- Removed@babel/helpers@7.0.0-beta.53(transitive)
- Removed@babel/highlight@7.0.0-beta.53(transitive)
- Removed@babel/parser@7.0.0-beta.53(transitive)
- Removed@babel/template@7.0.0-beta.53(transitive)
- Removed@babel/traverse@7.0.0-beta.53(transitive)
- Removed@babel/types@7.0.0-beta.53(transitive)
- Removedarr-diff@2.0.0(transitive)
- Removedarr-flatten@1.1.0(transitive)
- Removedarray-unique@0.2.1(transitive)
- Removedbraces@1.8.5(transitive)
- Removedexpand-brackets@0.1.5(transitive)
- Removedexpand-range@1.8.2(transitive)
- Removedextglob@0.3.2(transitive)
- Removedfilename-regex@2.0.1(transitive)
- Removedfill-range@2.2.4(transitive)
- Removedfor-in@1.0.2(transitive)
- Removedfor-own@0.1.5(transitive)
- Removedglob-base@0.3.0(transitive)
- Removedglob-parent@2.0.0(transitive)
- Removedinvariant@2.2.4(transitive)
- Removedis-buffer@1.1.6(transitive)
- Removedis-dotfile@1.0.3(transitive)
- Removedis-equal-shallow@0.1.3(transitive)
- Removedis-extendable@0.1.1(transitive)
- Removedis-extglob@1.0.0(transitive)
- Removedis-glob@2.0.1(transitive)
- Removedis-number@2.1.04.0.0(transitive)
- Removedis-posix-bracket@0.1.1(transitive)
- Removedis-primitive@2.0.0(transitive)
- Removedisarray@1.0.0(transitive)
- Removedisobject@2.1.0(transitive)
- Removedkind-of@3.2.26.0.3(transitive)
- Removedloose-envify@1.4.0(transitive)
- Removedmath-random@1.0.4(transitive)
- Removedmicromatch@2.3.11(transitive)
- Removednormalize-path@2.1.1(transitive)
- Removedobject.omit@2.0.1(transitive)
- Removedparse-glob@3.0.4(transitive)
- Removedpreserve@0.2.0(transitive)
- Removedrandomatic@3.1.1(transitive)
- Removedregex-cache@0.4.4(transitive)
- Removedremove-trailing-separator@1.1.0(transitive)
- Removedrepeat-element@1.1.4(transitive)
- Removedrepeat-string@1.6.1(transitive)
Updated@babel/helpers@7.0.0-beta.54
Updated@babel/parser@7.0.0-beta.54
Updated@babel/types@7.0.0-beta.54