jest-haste-map
Advanced tools
Comparing version 28.0.0-alpha.4 to 28.0.0-alpha.5
@@ -163,4 +163,5 @@ /** | ||
static getStatic(config: Config.ProjectConfig): HasteMapStatic; | ||
static create(options: Options): HasteMap; | ||
static create(options: Options): Promise<HasteMap>; | ||
private constructor(); | ||
private setupCachePath; | ||
static getCacheFilePath( | ||
@@ -167,0 +168,0 @@ tmpdir: string, |
@@ -95,2 +95,12 @@ 'use strict'; | ||
function _jestUtil() { | ||
const data = require('jest-util'); | ||
_jestUtil = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _jestWorker() { | ||
@@ -320,3 +330,3 @@ const data = require('jest-worker'); | ||
static create(options) { | ||
static async create(options) { | ||
if (options.hasteMapModulePath) { | ||
@@ -328,3 +338,5 @@ const CustomHasteMap = require(options.hasteMapModulePath); | ||
return new HasteMap(options); | ||
const hasteMap = new HasteMap(options); | ||
await hasteMap.setupCachePath(options); | ||
return hasteMap; | ||
} | ||
@@ -386,2 +398,9 @@ | ||
this._cachePath = ''; | ||
this._buildPromise = null; | ||
this._watchers = []; | ||
this._worker = null; | ||
} | ||
async setupCachePath(options) { | ||
const rootDirHash = (0, _crypto().createHash)('md5') | ||
@@ -402,3 +421,6 @@ .update(options.rootDir) | ||
if (options.dependencyExtractor) { | ||
const dependencyExtractor = require(options.dependencyExtractor); | ||
const dependencyExtractor = await (0, _jestUtil().requireOrImportModule)( | ||
options.dependencyExtractor, | ||
false | ||
); | ||
@@ -427,5 +449,2 @@ if (dependencyExtractor.getCacheKey) { | ||
); | ||
this._buildPromise = null; | ||
this._watchers = []; | ||
this._worker = null; | ||
} | ||
@@ -432,0 +451,0 @@ |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.extract = extract; | ||
exports.extractor = void 0; | ||
@@ -84,18 +84,20 @@ var _isRegExpSupported = _interopRequireDefault(require('./isRegExpSupported')); | ||
); | ||
const extractor = { | ||
extract(code) { | ||
const dependencies = new Set(); | ||
function extract(code) { | ||
const dependencies = new Set(); | ||
const addDependency = (match, _, dep) => { | ||
dependencies.add(dep); | ||
return match; | ||
}; | ||
const addDependency = (match, _, dep) => { | ||
dependencies.add(dep); | ||
return match; | ||
}; | ||
code | ||
.replace(BLOCK_COMMENT_RE, '') | ||
.replace(LINE_COMMENT_RE, '') | ||
.replace(IMPORT_OR_EXPORT_RE, addDependency) | ||
.replace(REQUIRE_OR_DYNAMIC_IMPORT_RE, addDependency) | ||
.replace(JEST_EXTENSIONS_RE, addDependency); | ||
return dependencies; | ||
} | ||
code | ||
.replace(BLOCK_COMMENT_RE, '') | ||
.replace(LINE_COMMENT_RE, '') | ||
.replace(IMPORT_OR_EXPORT_RE, addDependency) | ||
.replace(REQUIRE_OR_DYNAMIC_IMPORT_RE, addDependency) | ||
.replace(JEST_EXTENSIONS_RE, addDependency); | ||
return dependencies; | ||
} | ||
}; | ||
exports.extractor = extractor; |
@@ -39,2 +39,12 @@ 'use strict'; | ||
function _jestUtil() { | ||
const data = require('jest-util'); | ||
_jestUtil = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
var _blacklist = _interopRequireDefault(require('./blacklist')); | ||
@@ -44,5 +54,3 @@ | ||
var dependencyExtractor = _interopRequireWildcard( | ||
require('./lib/dependencyExtractor') | ||
); | ||
var _dependencyExtractor = require('./lib/dependencyExtractor'); | ||
@@ -160,10 +168,14 @@ function _interopRequireDefault(obj) { | ||
const content = getContent(); | ||
const extractor = data.dependencyExtractor | ||
? await (0, _jestUtil().requireOrImportModule)( | ||
data.dependencyExtractor, | ||
false | ||
) | ||
: _dependencyExtractor.extractor; | ||
dependencies = Array.from( | ||
data.dependencyExtractor | ||
? require(data.dependencyExtractor).extract( | ||
content, | ||
filePath, | ||
dependencyExtractor.extract | ||
) | ||
: dependencyExtractor.extract(content) | ||
extractor.extract( | ||
content, | ||
filePath, | ||
_dependencyExtractor.extractor.extract | ||
) | ||
); | ||
@@ -170,0 +182,0 @@ } |
{ | ||
"name": "jest-haste-map", | ||
"version": "28.0.0-alpha.4", | ||
"version": "28.0.0-alpha.5", | ||
"repository": { | ||
@@ -20,3 +20,3 @@ "type": "git", | ||
"dependencies": { | ||
"@jest/types": "^28.0.0-alpha.4", | ||
"@jest/types": "^28.0.0-alpha.5", | ||
"@types/graceful-fs": "^4.1.2", | ||
@@ -28,4 +28,4 @@ "@types/node": "*", | ||
"jest-regex-util": "^28.0.0-alpha.3", | ||
"jest-util": "^28.0.0-alpha.4", | ||
"jest-worker": "^28.0.0-alpha.4", | ||
"jest-util": "^28.0.0-alpha.5", | ||
"jest-worker": "^28.0.0-alpha.5", | ||
"micromatch": "^4.0.4", | ||
@@ -35,3 +35,3 @@ "walker": "^1.0.7" | ||
"devDependencies": { | ||
"@jest/test-utils": "^28.0.0-alpha.4", | ||
"@jest/test-utils": "^28.0.0-alpha.5", | ||
"@types/fb-watchman": "^2.0.0", | ||
@@ -50,3 +50,3 @@ "@types/micromatch": "^4.0.1", | ||
}, | ||
"gitHead": "c13dab19491ba6b57c2d703e7d7c4b20189e1e17" | ||
"gitHead": "46fb19b2628bd87676c10730ba19592c30b05478" | ||
} |
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
127499
4107
8
Updated@jest/types@^28.0.0-alpha.5
Updatedjest-util@^28.0.0-alpha.5
Updatedjest-worker@^28.0.0-alpha.5