@jest/transform
Advanced tools
Comparing version 29.3.1 to 29.4.0
@@ -93,2 +93,3 @@ /** | ||
private _buildCacheKeyFromFileInfo; | ||
private _buildTransformCacheKey; | ||
private _getCacheKey; | ||
@@ -99,2 +100,3 @@ private _getCacheKeyAsync; | ||
private _getFileCachePathAsync; | ||
private _getTransformPatternAndPath; | ||
private _getTransformPath; | ||
@@ -214,3 +216,3 @@ loadTransformers(): Promise<void>; | ||
TransformerConfig = unknown, | ||
> = (transformerConfig?: TransformerConfig) => X; | ||
> = (transformerConfig?: TransformerConfig) => X | Promise<X>; | ||
@@ -217,0 +219,0 @@ /** |
@@ -212,2 +212,5 @@ 'use strict'; | ||
} | ||
_buildTransformCacheKey(pattern, filepath) { | ||
return pattern + filepath; | ||
} | ||
_getCacheKey(fileData, filename, options) { | ||
@@ -294,10 +297,11 @@ const configString = this._cache.configString; | ||
} | ||
_getTransformPath(filename) { | ||
const transformRegExp = this._cache.transformRegExp; | ||
if (!transformRegExp) { | ||
_getTransformPatternAndPath(filename) { | ||
const transformEntry = this._cache.transformRegExp; | ||
if (transformEntry == null) { | ||
return undefined; | ||
} | ||
for (let i = 0; i < transformRegExp.length; i++) { | ||
if (transformRegExp[i][0].test(filename)) { | ||
return transformRegExp[i][1]; | ||
for (let i = 0; i < transformEntry.length; i++) { | ||
const [transformRegExp, transformPath] = transformEntry[i]; | ||
if (transformRegExp.test(filename)) { | ||
return [transformRegExp.source, transformPath]; | ||
} | ||
@@ -307,6 +311,13 @@ } | ||
} | ||
_getTransformPath(filename) { | ||
const transformInfo = this._getTransformPatternAndPath(filename); | ||
if (!Array.isArray(transformInfo)) { | ||
return undefined; | ||
} | ||
return transformInfo[1]; | ||
} | ||
async loadTransformers() { | ||
await Promise.all( | ||
this._config.transform.map( | ||
async ([, transformPath, transformerConfig]) => { | ||
async ([transformPattern, transformPath, transformerConfig], i) => { | ||
let transformer = await (0, _jestUtil().requireOrImportModule)( | ||
@@ -323,3 +334,5 @@ transformPath | ||
if (isTransformerFactory(transformer)) { | ||
transformer = transformer.createTransformer(transformerConfig); | ||
transformer = await transformer.createTransformer( | ||
transformerConfig | ||
); | ||
} | ||
@@ -340,3 +353,8 @@ if ( | ||
}; | ||
this._transformCache.set(transformPath, res); | ||
const transformCacheKey = this._buildTransformCacheKey( | ||
this._cache.transformRegExp?.[i]?.[0].source ?? | ||
new RegExp(transformPattern).source, | ||
transformPath | ||
); | ||
this._transformCache.set(transformCacheKey, res); | ||
} | ||
@@ -356,9 +374,14 @@ ) | ||
} | ||
const transformPath = this._getTransformPath(filename); | ||
if (transformPath == null) { | ||
const transformPatternAndPath = this._getTransformPatternAndPath(filename); | ||
if (!Array.isArray(transformPatternAndPath)) { | ||
return null; | ||
} | ||
const cached = this._transformCache.get(transformPath); | ||
if (cached != null) { | ||
return cached; | ||
const [transformPattern, transformPath] = transformPatternAndPath; | ||
const transformCacheKey = this._buildTransformCacheKey( | ||
transformPattern, | ||
transformPath | ||
); | ||
const transformer = this._transformCache.get(transformCacheKey); | ||
if (transformer !== undefined) { | ||
return transformer; | ||
} | ||
@@ -365,0 +388,0 @@ throw new Error( |
{ | ||
"name": "@jest/transform", | ||
"version": "29.3.1", | ||
"version": "29.4.0", | ||
"repository": { | ||
@@ -21,3 +21,3 @@ "type": "git", | ||
"@babel/core": "^7.11.6", | ||
"@jest/types": "^29.3.1", | ||
"@jest/types": "^29.4.0", | ||
"@jridgewell/trace-mapping": "^0.3.15", | ||
@@ -29,14 +29,14 @@ "babel-plugin-istanbul": "^6.1.1", | ||
"graceful-fs": "^4.2.9", | ||
"jest-haste-map": "^29.3.1", | ||
"jest-haste-map": "^29.4.0", | ||
"jest-regex-util": "^29.2.0", | ||
"jest-util": "^29.3.1", | ||
"jest-util": "^29.4.0", | ||
"micromatch": "^4.0.4", | ||
"pirates": "^4.0.4", | ||
"slash": "^3.0.0", | ||
"write-file-atomic": "^4.0.1" | ||
"write-file-atomic": "^5.0.0" | ||
}, | ||
"devDependencies": { | ||
"@jest/test-utils": "^29.3.1", | ||
"@jest/test-utils": "^29.4.0", | ||
"@types/babel__core": "^7.1.14", | ||
"@types/convert-source-map": "^1.5.1", | ||
"@types/convert-source-map": "^2.0.0", | ||
"@types/graceful-fs": "^4.1.3", | ||
@@ -53,3 +53,3 @@ "@types/micromatch": "^4.0.1", | ||
}, | ||
"gitHead": "05deb8393c4ad71e19be2567b704dfd3a2ab5fc9" | ||
"gitHead": "4bc0e8acaf990e6618a7bed1dca67760c20bb12a" | ||
} |
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
59200
10
1565
+ Addedsignal-exit@4.1.0(transitive)
+ Addedwrite-file-atomic@5.0.1(transitive)
- Removedsignal-exit@3.0.7(transitive)
- Removedwrite-file-atomic@4.0.2(transitive)
Updated@jest/types@^29.4.0
Updatedjest-haste-map@^29.4.0
Updatedjest-util@^29.4.0
Updatedwrite-file-atomic@^5.0.0