@jest/transform
Advanced tools
Comparing version 26.0.1 to 26.1.0
@@ -330,4 +330,2 @@ 'use strict'; | ||
_getTransformer(filename) { | ||
let transform = null; | ||
if (!this._config.transform || !this._config.transform.length) { | ||
@@ -339,30 +337,32 @@ return null; | ||
if (transformPath) { | ||
const transformer = this._transformCache.get(transformPath); | ||
if (!transformPath) { | ||
return null; | ||
} | ||
if (transformer != null) { | ||
return transformer; | ||
} | ||
const transformer = this._transformCache.get(transformPath); | ||
transform = require(transformPath); | ||
if (transformer) { | ||
return transformer; | ||
} | ||
if (!transform) { | ||
throw new TypeError('Jest: a transform must export something.'); | ||
} | ||
let transform = require(transformPath); | ||
const transformerConfig = this._transformConfigCache.get(transformPath); | ||
if (!transform) { | ||
throw new TypeError('Jest: a transform must export something.'); | ||
} | ||
if (typeof transform.createTransformer === 'function') { | ||
transform = transform.createTransformer(transformerConfig); | ||
} | ||
const transformerConfig = this._transformConfigCache.get(transformPath); | ||
if (typeof transform.process !== 'function') { | ||
throw new TypeError( | ||
'Jest: a transform must export a `process` function.' | ||
); | ||
} | ||
if (typeof transform.createTransformer === 'function') { | ||
transform = transform.createTransformer(transformerConfig); | ||
} | ||
this._transformCache.set(transformPath, transform); | ||
if (typeof transform.process !== 'function') { | ||
throw new TypeError( | ||
'Jest: a transform must export a `process` function.' | ||
); | ||
} | ||
this._transformCache.set(transformPath, transform); | ||
return transform; | ||
@@ -702,3 +702,3 @@ } | ||
*/ | ||
// @ts-ignore: Unused and private - remove in Jest 25 | ||
// @ts-expect-error: Unused and private - remove in Jest 25 | ||
@@ -705,0 +705,0 @@ _shouldTransform(filename) { |
@@ -105,3 +105,15 @@ 'use strict'; | ||
); | ||
const cachedRegexes = new Map(); | ||
const getRegex = regexStr => { | ||
if (!cachedRegexes.has(regexStr)) { | ||
cachedRegexes.set(regexStr, new RegExp(regexStr)); | ||
} | ||
const regex = cachedRegexes.get(regexStr); // prevent stateful regexes from breaking, just in case | ||
regex.lastIndex = 0; | ||
return regex; | ||
}; | ||
function shouldInstrument(filename, options, config) { | ||
@@ -120,3 +132,5 @@ if (!options.collectCoverage) { | ||
if ( | ||
!config.testPathIgnorePatterns.some(pattern => !!filename.match(pattern)) | ||
!config.testPathIgnorePatterns.some(pattern => | ||
getRegex(pattern).test(filename) | ||
) | ||
) { | ||
@@ -128,6 +142,5 @@ if (config.testRegex.some(regex => new RegExp(regex).test(filename))) { | ||
if ( | ||
(0, _micromatch().default)( | ||
[(0, _jestUtil().replacePathSepForGlob)(filename)], | ||
config.testMatch | ||
).length | ||
(0, _jestUtil().globsToMatcher)(config.testMatch)( | ||
(0, _jestUtil().replacePathSepForGlob)(filename) | ||
) | ||
) { | ||
@@ -151,10 +164,7 @@ return false; | ||
options.collectCoverageFrom.length && | ||
(0, _micromatch().default)( | ||
[ | ||
(0, _jestUtil().replacePathSepForGlob)( | ||
path().relative(config.rootDir, filename) | ||
) | ||
], | ||
options.collectCoverageFrom | ||
).length === 0 | ||
!(0, _jestUtil().globsToMatcher)(options.collectCoverageFrom)( | ||
(0, _jestUtil().replacePathSepForGlob)( | ||
path().relative(config.rootDir, filename) | ||
) | ||
) | ||
) { | ||
@@ -161,0 +171,0 @@ return false; |
{ | ||
"name": "@jest/transform", | ||
"version": "26.0.1", | ||
"version": "26.1.0", | ||
"repository": { | ||
@@ -14,3 +14,3 @@ "type": "git", | ||
"@babel/core": "^7.1.0", | ||
"@jest/types": "^26.0.1", | ||
"@jest/types": "^26.1.0", | ||
"babel-plugin-istanbul": "^6.0.0", | ||
@@ -21,5 +21,5 @@ "chalk": "^4.0.0", | ||
"graceful-fs": "^4.2.4", | ||
"jest-haste-map": "^26.0.1", | ||
"jest-haste-map": "^26.1.0", | ||
"jest-regex-util": "^26.0.0", | ||
"jest-util": "^26.0.1", | ||
"jest-util": "^26.1.0", | ||
"micromatch": "^4.0.2", | ||
@@ -47,3 +47,3 @@ "pirates": "^4.0.1", | ||
}, | ||
"gitHead": "40b8e1e157c9981dda5a68d73fff647e80fc9f5c" | ||
"gitHead": "817d8b6aca845dd4fcfd7f8316293e69f3a116c5" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38392
1149
Updated@jest/types@^26.1.0
Updatedjest-haste-map@^26.1.0
Updatedjest-util@^26.1.0