Updating NPM dependencies
This commit is contained in:
14
node_modules/@jest/transform/build/ScriptTransformer.d.ts
generated
vendored
14
node_modules/@jest/transform/build/ScriptTransformer.d.ts
generated
vendored
@@ -4,10 +4,9 @@
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import { Config } from '@jest/types';
|
||||
import { Options, TransformResult } from './types';
|
||||
import type { Config } from '@jest/types';
|
||||
import type { Options, TransformResult } from './types';
|
||||
export default class ScriptTransformer {
|
||||
static EVAL_RESULT_VARIABLE: 'Object.<anonymous>';
|
||||
private _cache;
|
||||
private _config;
|
||||
private _transformCache;
|
||||
@@ -18,13 +17,8 @@ export default class ScriptTransformer {
|
||||
private _getTransformPath;
|
||||
private _getTransformer;
|
||||
private _instrumentFile;
|
||||
private _getRealPath;
|
||||
preloadTransformer(filepath: Config.Path): void;
|
||||
transformSource(filepath: Config.Path, content: string, instrument: boolean): {
|
||||
code: string;
|
||||
mapCoverage: boolean;
|
||||
sourceMapPath: string | null;
|
||||
};
|
||||
transformSource(filepath: Config.Path, content: string, instrument: boolean, supportsDynamicImport?: boolean, supportsStaticESM?: boolean): TransformResult;
|
||||
private _transformAndBuildScript;
|
||||
transform(filename: Config.Path, options: Options, fileSource?: string): TransformResult;
|
||||
transformJson(filename: Config.Path, options: Options, fileSource: string): string;
|
||||
@@ -36,4 +30,4 @@ export default class ScriptTransformer {
|
||||
private _shouldTransform;
|
||||
shouldTransform(filename: Config.Path): boolean;
|
||||
}
|
||||
//# sourceMappingURL=ScriptTransformer.d.ts.map
|
||||
export declare function createTranspilingRequire(config: Config.ProjectConfig): <TModuleType = unknown>(resolverPath: string, applyInteropRequireDefault?: boolean) => TModuleType;
|
||||
|
||||
1
node_modules/@jest/transform/build/ScriptTransformer.d.ts.map
generated
vendored
1
node_modules/@jest/transform/build/ScriptTransformer.d.ts.map
generated
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"ScriptTransformer.d.ts","sourceRoot":"","sources":["../src/ScriptTransformer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAanC,OAAO,EACL,OAAO,EAGP,eAAe,EAChB,MAAM,SAAS,CAAC;AAoCjB,MAAM,CAAC,OAAO,OAAO,iBAAiB;IACpC,MAAM,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;IAClD,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,OAAO,CAAuB;IACtC,OAAO,CAAC,eAAe,CAAgC;IACvD,OAAO,CAAC,qBAAqB,CAA4B;gBAE7C,MAAM,EAAE,MAAM,CAAC,aAAa;IAqBxC,OAAO,CAAC,YAAY;IAgCpB,OAAO,CAAC,iBAAiB;IAyBzB,OAAO,CAAC,iBAAiB;IAkBzB,OAAO,CAAC,eAAe;IA4BvB,OAAO,CAAC,eAAe;IAmCvB,OAAO,CAAC,YAAY;IAUpB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,GAAG,IAAI;IAI/C,eAAe,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO;;;;;IAwF3E,OAAO,CAAC,wBAAwB;IA+DhC,SAAS,CACP,QAAQ,EAAE,MAAM,CAAC,IAAI,EACrB,OAAO,EAAE,OAAO,EAChB,UAAU,CAAC,EAAE,MAAM,GAClB,eAAe;IA2BlB,aAAa,CACX,QAAQ,EAAE,MAAM,CAAC,IAAI,EACrB,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,GACjB,MAAM;IAkBT,yBAAyB,CAAC,UAAU,GAAG,OAAO,EAC5C,UAAU,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,GACtC,UAAU;IACb,yBAAyB,CAAC,UAAU,GAAG,OAAO,EAC5C,UAAU,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,GAC/C,OAAO,CAAC,UAAU,CAAC;IAsDtB;;OAEG;IAEH,OAAO,CAAC,gBAAgB;IAIxB,eAAe,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,GAAG,OAAO;CAQhD"}
|
||||
621
node_modules/@jest/transform/build/ScriptTransformer.js
generated
vendored
621
node_modules/@jest/transform/build/ScriptTransformer.js
generated
vendored
@@ -3,52 +3,23 @@
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.createTranspilingRequire = createTranspilingRequire;
|
||||
exports.default = void 0;
|
||||
|
||||
function _crypto() {
|
||||
const data = _interopRequireDefault(require('crypto'));
|
||||
const data = require('crypto');
|
||||
|
||||
_crypto = function _crypto() {
|
||||
_crypto = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require('path'));
|
||||
function path() {
|
||||
const data = _interopRequireWildcard(require('path'));
|
||||
|
||||
_path = function _path() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _vm() {
|
||||
const data = _interopRequireDefault(require('vm'));
|
||||
|
||||
_vm = function _vm() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
|
||||
_jestUtil = function _jestUtil() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _gracefulFs() {
|
||||
const data = _interopRequireDefault(require('graceful-fs'));
|
||||
|
||||
_gracefulFs = function _gracefulFs() {
|
||||
path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -58,7 +29,7 @@ function _gracefulFs() {
|
||||
function _core() {
|
||||
const data = require('@babel/core');
|
||||
|
||||
_core = function _core() {
|
||||
_core = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -68,7 +39,7 @@ function _core() {
|
||||
function _babelPluginIstanbul() {
|
||||
const data = _interopRequireDefault(require('babel-plugin-istanbul'));
|
||||
|
||||
_babelPluginIstanbul = function _babelPluginIstanbul() {
|
||||
_babelPluginIstanbul = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -76,19 +47,9 @@ function _babelPluginIstanbul() {
|
||||
}
|
||||
|
||||
function _convertSourceMap() {
|
||||
const data = _interopRequireDefault(require('convert-source-map'));
|
||||
const data = require('convert-source-map');
|
||||
|
||||
_convertSourceMap = function _convertSourceMap() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _jestHasteMap() {
|
||||
const data = _interopRequireDefault(require('jest-haste-map'));
|
||||
|
||||
_jestHasteMap = function _jestHasteMap() {
|
||||
_convertSourceMap = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -98,37 +59,17 @@ function _jestHasteMap() {
|
||||
function _fastJsonStableStringify() {
|
||||
const data = _interopRequireDefault(require('fast-json-stable-stringify'));
|
||||
|
||||
_fastJsonStableStringify = function _fastJsonStableStringify() {
|
||||
_fastJsonStableStringify = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _slash() {
|
||||
const data = _interopRequireDefault(require('slash'));
|
||||
function fs() {
|
||||
const data = _interopRequireWildcard(require('graceful-fs'));
|
||||
|
||||
_slash = function _slash() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _writeFileAtomic() {
|
||||
const data = _interopRequireDefault(require('write-file-atomic'));
|
||||
|
||||
_writeFileAtomic = function _writeFileAtomic() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _realpathNative() {
|
||||
const data = require('realpath-native');
|
||||
|
||||
_realpathNative = function _realpathNative() {
|
||||
fs = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -138,23 +79,105 @@ function _realpathNative() {
|
||||
function _pirates() {
|
||||
const data = require('pirates');
|
||||
|
||||
_pirates = function _pirates() {
|
||||
_pirates = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _shouldInstrument = _interopRequireDefault(require('./shouldInstrument'));
|
||||
function _slash() {
|
||||
const data = _interopRequireDefault(require('slash'));
|
||||
|
||||
_slash = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _writeFileAtomic() {
|
||||
const data = require('write-file-atomic');
|
||||
|
||||
_writeFileAtomic = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _jestHasteMap() {
|
||||
const data = _interopRequireDefault(require('jest-haste-map'));
|
||||
|
||||
_jestHasteMap = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
|
||||
_jestUtil = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _enhanceUnexpectedTokenMessage = _interopRequireDefault(
|
||||
require('./enhanceUnexpectedTokenMessage')
|
||||
);
|
||||
|
||||
var _shouldInstrument = _interopRequireDefault(require('./shouldInstrument'));
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
function _getRequireWildcardCache() {
|
||||
if (typeof WeakMap !== 'function') return null;
|
||||
var cache = new WeakMap();
|
||||
_getRequireWildcardCache = function () {
|
||||
return cache;
|
||||
};
|
||||
return cache;
|
||||
}
|
||||
|
||||
function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
||||
return {default: obj};
|
||||
}
|
||||
var cache = _getRequireWildcardCache();
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {};
|
||||
var hasPropertyDescriptor =
|
||||
Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for (var key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = hasPropertyDescriptor
|
||||
? Object.getOwnPropertyDescriptor(obj, key)
|
||||
: null;
|
||||
if (desc && (desc.get || desc.set)) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
if (cache) {
|
||||
cache.set(obj, newObj);
|
||||
}
|
||||
return newObj;
|
||||
}
|
||||
|
||||
function _defineProperty(obj, key, value) {
|
||||
if (key in obj) {
|
||||
Object.defineProperty(obj, key, {
|
||||
@@ -169,61 +192,22 @@ function _defineProperty(obj, key, value) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
||||
try {
|
||||
var info = gen[key](arg);
|
||||
var value = info.value;
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
if (info.done) {
|
||||
resolve(value);
|
||||
} else {
|
||||
Promise.resolve(value).then(_next, _throw);
|
||||
}
|
||||
}
|
||||
|
||||
function _asyncToGenerator(fn) {
|
||||
return function() {
|
||||
var self = this,
|
||||
args = arguments;
|
||||
return new Promise(function(resolve, reject) {
|
||||
var gen = fn.apply(self, args);
|
||||
function _next(value) {
|
||||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, 'next', value);
|
||||
}
|
||||
function _throw(err) {
|
||||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, 'throw', err);
|
||||
}
|
||||
_next(undefined);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
// Use `require` to avoid TS rootDir
|
||||
const _require = require('../package.json'),
|
||||
VERSION = _require.version; // This data structure is used to avoid recalculating some data every time that
|
||||
const {version: VERSION} = require('../package.json');
|
||||
|
||||
// This data structure is used to avoid recalculating some data every time that
|
||||
// we need to transform a file. Since ScriptTransformer is instantiated for each
|
||||
// file we need to keep this object in the local scope of this module.
|
||||
|
||||
const projectCaches = new WeakMap(); // To reset the cache for specific changesets (rather than package version).
|
||||
const projectCaches = new Map(); // To reset the cache for specific changesets (rather than package version).
|
||||
|
||||
const CACHE_VERSION = '1';
|
||||
|
||||
function waitForPromiseWithCleanup(_x, _x2) {
|
||||
return _waitForPromiseWithCleanup.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _waitForPromiseWithCleanup() {
|
||||
_waitForPromiseWithCleanup = _asyncToGenerator(function*(promise, cleanup) {
|
||||
try {
|
||||
yield promise;
|
||||
} finally {
|
||||
cleanup();
|
||||
}
|
||||
});
|
||||
return _waitForPromiseWithCleanup.apply(this, arguments);
|
||||
async function waitForPromiseWithCleanup(promise, cleanup) {
|
||||
try {
|
||||
await promise;
|
||||
} finally {
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
class ScriptTransformer {
|
||||
@@ -239,41 +223,48 @@ class ScriptTransformer {
|
||||
this._config = config;
|
||||
this._transformCache = new Map();
|
||||
this._transformConfigCache = new Map();
|
||||
let projectCache = projectCaches.get(config);
|
||||
const configString = (0, _fastJsonStableStringify().default)(this._config);
|
||||
let projectCache = projectCaches.get(configString);
|
||||
|
||||
if (!projectCache) {
|
||||
projectCache = {
|
||||
configString: (0, _fastJsonStableStringify().default)(this._config),
|
||||
configString,
|
||||
ignorePatternsRegExp: calcIgnorePatternRegExp(this._config),
|
||||
transformRegExp: calcTransformRegExp(this._config),
|
||||
transformedFiles: new Map()
|
||||
};
|
||||
projectCaches.set(config, projectCache);
|
||||
projectCaches.set(configString, projectCache);
|
||||
}
|
||||
|
||||
this._cache = projectCache;
|
||||
}
|
||||
|
||||
_getCacheKey(fileData, filename, instrument) {
|
||||
_getCacheKey(
|
||||
fileData,
|
||||
filename,
|
||||
instrument,
|
||||
supportsDynamicImport,
|
||||
supportsStaticESM
|
||||
) {
|
||||
const configString = this._cache.configString;
|
||||
|
||||
const transformer = this._getTransformer(filename);
|
||||
|
||||
if (transformer && typeof transformer.getCacheKey === 'function') {
|
||||
return _crypto()
|
||||
.default.createHash('md5')
|
||||
return (0, _crypto().createHash)('md5')
|
||||
.update(
|
||||
transformer.getCacheKey(fileData, filename, configString, {
|
||||
config: this._config,
|
||||
instrument,
|
||||
rootDir: this._config.rootDir
|
||||
rootDir: this._config.rootDir,
|
||||
supportsDynamicImport,
|
||||
supportsStaticESM
|
||||
})
|
||||
)
|
||||
.update(CACHE_VERSION)
|
||||
.digest('hex');
|
||||
} else {
|
||||
return _crypto()
|
||||
.default.createHash('md5')
|
||||
return (0, _crypto().createHash)('md5')
|
||||
.update(fileData)
|
||||
.update(configString)
|
||||
.update(instrument ? 'instrument' : '')
|
||||
@@ -283,27 +274,34 @@ class ScriptTransformer {
|
||||
}
|
||||
}
|
||||
|
||||
_getFileCachePath(filename, content, instrument) {
|
||||
_getFileCachePath(
|
||||
filename,
|
||||
content,
|
||||
instrument,
|
||||
supportsDynamicImport,
|
||||
supportsStaticESM
|
||||
) {
|
||||
const baseCacheDir = _jestHasteMap().default.getCacheFilePath(
|
||||
this._config.cacheDirectory,
|
||||
'jest-transform-cache-' + this._config.name,
|
||||
VERSION
|
||||
);
|
||||
|
||||
const cacheKey = this._getCacheKey(content, filename, instrument); // Create sub folders based on the cacheKey to avoid creating one
|
||||
const cacheKey = this._getCacheKey(
|
||||
content,
|
||||
filename,
|
||||
instrument,
|
||||
supportsDynamicImport,
|
||||
supportsStaticESM
|
||||
); // Create sub folders based on the cacheKey to avoid creating one
|
||||
// directory with many files.
|
||||
|
||||
const cacheDir = _path().default.join(
|
||||
baseCacheDir,
|
||||
cacheKey[0] + cacheKey[1]
|
||||
);
|
||||
|
||||
const cacheFilenamePrefix = _path()
|
||||
.default.basename(filename, _path().default.extname(filename))
|
||||
const cacheDir = path().join(baseCacheDir, cacheKey[0] + cacheKey[1]);
|
||||
const cacheFilenamePrefix = path()
|
||||
.basename(filename, path().extname(filename))
|
||||
.replace(/\W/g, '');
|
||||
|
||||
const cachePath = (0, _slash().default)(
|
||||
_path().default.join(cacheDir, cacheFilenamePrefix + '_' + cacheKey)
|
||||
path().join(cacheDir, cacheFilenamePrefix + '_' + cacheKey)
|
||||
);
|
||||
(0, _jestUtil().createDirectory)(cacheDir);
|
||||
return cachePath;
|
||||
@@ -330,48 +328,61 @@ class ScriptTransformer {
|
||||
}
|
||||
|
||||
_getTransformer(filename) {
|
||||
let transform = null;
|
||||
|
||||
if (!this._config.transform || !this._config.transform.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const transformPath = this._getTransformPath(filename);
|
||||
|
||||
if (transformPath) {
|
||||
const transformer = this._transformCache.get(transformPath);
|
||||
|
||||
if (transformer != null) {
|
||||
return transformer;
|
||||
}
|
||||
|
||||
transform = require(transformPath);
|
||||
|
||||
const transformerConfig = this._transformConfigCache.get(transformPath);
|
||||
|
||||
if (typeof transform.createTransformer === 'function') {
|
||||
transform = transform.createTransformer(transformerConfig);
|
||||
}
|
||||
|
||||
if (typeof transform.process !== 'function') {
|
||||
throw new TypeError(
|
||||
'Jest: a transform must export a `process` function.'
|
||||
);
|
||||
}
|
||||
|
||||
this._transformCache.set(transformPath, transform);
|
||||
if (!transformPath) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const transformer = this._transformCache.get(transformPath);
|
||||
|
||||
if (transformer) {
|
||||
return transformer;
|
||||
}
|
||||
|
||||
let transform = require(transformPath);
|
||||
|
||||
if (!transform) {
|
||||
throw new TypeError('Jest: a transform must export something.');
|
||||
}
|
||||
|
||||
const transformerConfig = this._transformConfigCache.get(transformPath);
|
||||
|
||||
if (typeof transform.createTransformer === 'function') {
|
||||
transform = transform.createTransformer(transformerConfig);
|
||||
}
|
||||
|
||||
if (typeof transform.process !== 'function') {
|
||||
throw new TypeError(
|
||||
'Jest: a transform must export a `process` function.'
|
||||
);
|
||||
}
|
||||
|
||||
this._transformCache.set(transformPath, transform);
|
||||
|
||||
return transform;
|
||||
}
|
||||
|
||||
_instrumentFile(filename, content) {
|
||||
const result = (0, _core().transformSync)(content, {
|
||||
_instrumentFile(
|
||||
filename,
|
||||
input,
|
||||
supportsDynamicImport,
|
||||
supportsStaticESM,
|
||||
canMapToInput
|
||||
) {
|
||||
const inputCode = typeof input === 'string' ? input : input.code;
|
||||
const inputMap = typeof input === 'string' ? null : input.map;
|
||||
const result = (0, _core().transformSync)(inputCode, {
|
||||
auxiliaryCommentBefore: ' istanbul ignore next ',
|
||||
babelrc: false,
|
||||
caller: {
|
||||
name: '@jest/transform',
|
||||
supportsStaticESM: false
|
||||
supportsDynamicImport,
|
||||
supportsStaticESM
|
||||
},
|
||||
configFile: false,
|
||||
filename,
|
||||
@@ -383,42 +394,45 @@ class ScriptTransformer {
|
||||
// files outside `cwd` will not be instrumented
|
||||
cwd: this._config.rootDir,
|
||||
exclude: [],
|
||||
extension: false,
|
||||
inputSourceMap: inputMap,
|
||||
useInlineSourceMaps: false
|
||||
}
|
||||
]
|
||||
]
|
||||
],
|
||||
sourceMaps: canMapToInput ? 'both' : false
|
||||
});
|
||||
|
||||
if (result) {
|
||||
const code = result.code;
|
||||
|
||||
if (code) {
|
||||
return code;
|
||||
}
|
||||
if (result && result.code) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
_getRealPath(filepath) {
|
||||
try {
|
||||
return (0, _realpathNative().sync)(filepath) || filepath;
|
||||
} catch (err) {
|
||||
return filepath;
|
||||
}
|
||||
return input;
|
||||
} // We don't want to expose transformers to the outside - this function is just
|
||||
// to warm up `this._transformCache`
|
||||
|
||||
preloadTransformer(filepath) {
|
||||
this._getTransformer(filepath);
|
||||
}
|
||||
} // TODO: replace third argument with TransformOptions in Jest 26
|
||||
|
||||
transformSource(filepath, content, instrument) {
|
||||
const filename = this._getRealPath(filepath);
|
||||
transformSource(
|
||||
filepath,
|
||||
content,
|
||||
instrument,
|
||||
supportsDynamicImport = false,
|
||||
supportsStaticESM = false
|
||||
) {
|
||||
const filename = (0, _jestUtil().tryRealpath)(filepath);
|
||||
|
||||
const transform = this._getTransformer(filename);
|
||||
|
||||
const cacheFilePath = this._getFileCachePath(filename, content, instrument);
|
||||
const cacheFilePath = this._getFileCachePath(
|
||||
filename,
|
||||
content,
|
||||
instrument,
|
||||
supportsDynamicImport,
|
||||
supportsStaticESM
|
||||
);
|
||||
|
||||
let sourceMapPath = cacheFilePath + '.map'; // Ignore cache if `config.cache` is set (--no-cache)
|
||||
|
||||
@@ -427,10 +441,7 @@ class ScriptTransformer {
|
||||
// logic and will handle it based on `config.collectCoverage` option
|
||||
|
||||
const transformWillInstrument =
|
||||
shouldCallTransform && transform && transform.canInstrument; // If we handle the coverage instrumentation, we should try to map code
|
||||
// coverage against original source with any provided source map
|
||||
|
||||
const mapCoverage = instrument && !transformWillInstrument;
|
||||
shouldCallTransform && transform && transform.canInstrument;
|
||||
|
||||
if (code) {
|
||||
// This is broken: we return the code, and a path for the source map
|
||||
@@ -439,7 +450,7 @@ class ScriptTransformer {
|
||||
// two separate processes write concurrently to the same cache files.
|
||||
return {
|
||||
code,
|
||||
mapCoverage,
|
||||
originalCode: content,
|
||||
sourceMapPath
|
||||
};
|
||||
}
|
||||
@@ -451,7 +462,9 @@ class ScriptTransformer {
|
||||
|
||||
if (transform && shouldCallTransform) {
|
||||
const processed = transform.process(content, filename, this._config, {
|
||||
instrument
|
||||
instrument,
|
||||
supportsDynamicImport,
|
||||
supportsStaticESM
|
||||
});
|
||||
|
||||
if (typeof processed === 'string') {
|
||||
@@ -467,28 +480,60 @@ class ScriptTransformer {
|
||||
}
|
||||
|
||||
if (!transformed.map) {
|
||||
//Could be a potential freeze here.
|
||||
//See: https://github.com/facebook/jest/pull/5177#discussion_r158883570
|
||||
const inlineSourceMap = _convertSourceMap().default.fromSource(
|
||||
transformed.code
|
||||
);
|
||||
try {
|
||||
//Could be a potential freeze here.
|
||||
//See: https://github.com/facebook/jest/pull/5177#discussion_r158883570
|
||||
const inlineSourceMap = (0, _convertSourceMap().fromSource)(
|
||||
transformed.code
|
||||
);
|
||||
|
||||
if (inlineSourceMap) {
|
||||
transformed.map = inlineSourceMap.toJSON();
|
||||
if (inlineSourceMap) {
|
||||
transformed.map = inlineSourceMap.toObject();
|
||||
}
|
||||
} catch {
|
||||
const transformPath = this._getTransformPath(filename);
|
||||
|
||||
console.warn(
|
||||
`jest-transform: The source map produced for the file ${filename} ` +
|
||||
`by ${transformPath} was invalid. Proceeding without source ` +
|
||||
'mapping for that file.'
|
||||
);
|
||||
}
|
||||
}
|
||||
} // Apply instrumentation to the code if necessary, keeping the instrumented code and new map
|
||||
|
||||
let map = transformed.map;
|
||||
|
||||
if (!transformWillInstrument && instrument) {
|
||||
code = this._instrumentFile(filename, transformed.code);
|
||||
/**
|
||||
* We can map the original source code to the instrumented code ONLY if
|
||||
* - the process of transforming the code produced a source map e.g. ts-jest
|
||||
* - we did not transform the source code
|
||||
*
|
||||
* Otherwise we cannot make any statements about how the instrumented code corresponds to the original code,
|
||||
* and we should NOT emit any source maps
|
||||
*
|
||||
*/
|
||||
const shouldEmitSourceMaps =
|
||||
(transform != null && map != null) || transform == null;
|
||||
|
||||
const instrumented = this._instrumentFile(
|
||||
filename,
|
||||
transformed,
|
||||
supportsDynamicImport,
|
||||
supportsStaticESM,
|
||||
shouldEmitSourceMaps
|
||||
);
|
||||
|
||||
code =
|
||||
typeof instrumented === 'string' ? instrumented : instrumented.code;
|
||||
map = typeof instrumented === 'string' ? null : instrumented.map;
|
||||
} else {
|
||||
code = transformed.code;
|
||||
}
|
||||
|
||||
if (transformed.map) {
|
||||
if (map) {
|
||||
const sourceMapContent =
|
||||
typeof transformed.map === 'string'
|
||||
? transformed.map
|
||||
: JSON.stringify(transformed.map);
|
||||
typeof map === 'string' ? map : JSON.stringify(map);
|
||||
writeCacheFile(sourceMapPath, sourceMapContent);
|
||||
} else {
|
||||
sourceMapPath = null;
|
||||
@@ -497,63 +542,48 @@ class ScriptTransformer {
|
||||
writeCodeCacheFile(cacheFilePath, code);
|
||||
return {
|
||||
code,
|
||||
mapCoverage,
|
||||
originalCode: content,
|
||||
sourceMapPath
|
||||
};
|
||||
}
|
||||
|
||||
_transformAndBuildScript(filename, options, instrument, fileSource) {
|
||||
const isInternalModule = !!(options && options.isInternalModule);
|
||||
const isCoreModule = !!(options && options.isCoreModule);
|
||||
const {
|
||||
isCoreModule,
|
||||
isInternalModule,
|
||||
supportsDynamicImport,
|
||||
supportsStaticESM
|
||||
} = options;
|
||||
const content = stripShebang(
|
||||
fileSource || _gracefulFs().default.readFileSync(filename, 'utf8')
|
||||
fileSource || fs().readFileSync(filename, 'utf8')
|
||||
);
|
||||
let wrappedCode;
|
||||
let code = content;
|
||||
let sourceMapPath = null;
|
||||
let mapCoverage = false;
|
||||
const willTransform =
|
||||
!isInternalModule &&
|
||||
!isCoreModule &&
|
||||
(this.shouldTransform(filename) || instrument);
|
||||
|
||||
try {
|
||||
const extraGlobals = (options && options.extraGlobals) || [];
|
||||
|
||||
if (willTransform) {
|
||||
const transformedSource = this.transformSource(
|
||||
filename,
|
||||
content,
|
||||
instrument
|
||||
instrument,
|
||||
supportsDynamicImport,
|
||||
supportsStaticESM
|
||||
);
|
||||
wrappedCode = wrap(transformedSource.code, ...extraGlobals);
|
||||
code = transformedSource.code;
|
||||
sourceMapPath = transformedSource.sourceMapPath;
|
||||
mapCoverage = transformedSource.mapCoverage;
|
||||
} else {
|
||||
wrappedCode = wrap(content, ...extraGlobals);
|
||||
}
|
||||
|
||||
return {
|
||||
mapCoverage,
|
||||
script: new (_vm()).default.Script(wrappedCode, {
|
||||
displayErrors: true,
|
||||
filename: isCoreModule ? 'jest-nodejs-core-' + filename : filename
|
||||
}),
|
||||
code,
|
||||
originalCode: content,
|
||||
sourceMapPath
|
||||
};
|
||||
} catch (e) {
|
||||
if (e.codeFrame) {
|
||||
e.stack = e.message + '\n' + e.codeFrame;
|
||||
}
|
||||
|
||||
if (
|
||||
e instanceof SyntaxError &&
|
||||
e.message.includes('Unexpected token') &&
|
||||
!e.message.includes(' expected')
|
||||
) {
|
||||
throw (0, _enhanceUnexpectedTokenMessage.default)(e);
|
||||
}
|
||||
|
||||
throw e;
|
||||
throw (0, _enhanceUnexpectedTokenMessage.default)(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -562,11 +592,9 @@ class ScriptTransformer {
|
||||
let instrument = false;
|
||||
|
||||
if (!options.isCoreModule) {
|
||||
instrument = (0, _shouldInstrument.default)(
|
||||
filename,
|
||||
options,
|
||||
this._config
|
||||
);
|
||||
instrument =
|
||||
options.coverageProvider === 'babel' &&
|
||||
(0, _shouldInstrument.default)(filename, options, this._config);
|
||||
scriptCacheKey = getScriptCacheKey(filename, instrument);
|
||||
|
||||
const result = this._cache.transformedFiles.get(scriptCacheKey);
|
||||
@@ -591,19 +619,23 @@ class ScriptTransformer {
|
||||
}
|
||||
|
||||
transformJson(filename, options, fileSource) {
|
||||
const isInternalModule = options.isInternalModule;
|
||||
const isCoreModule = options.isCoreModule;
|
||||
const {
|
||||
isCoreModule,
|
||||
isInternalModule,
|
||||
supportsDynamicImport,
|
||||
supportsStaticESM
|
||||
} = options;
|
||||
const willTransform =
|
||||
!isInternalModule && !isCoreModule && this.shouldTransform(filename);
|
||||
|
||||
if (willTransform) {
|
||||
const _this$transformSource = this.transformSource(
|
||||
filename,
|
||||
fileSource,
|
||||
false
|
||||
),
|
||||
transformedJsonSource = _this$transformSource.code;
|
||||
|
||||
const {code: transformedJsonSource} = this.transformSource(
|
||||
filename,
|
||||
fileSource,
|
||||
false,
|
||||
supportsDynamicImport,
|
||||
supportsStaticESM
|
||||
);
|
||||
return transformedJsonSource;
|
||||
}
|
||||
|
||||
@@ -619,13 +651,17 @@ class ScriptTransformer {
|
||||
(code, filename) => {
|
||||
try {
|
||||
transforming = true;
|
||||
return this.transformSource(filename, code, false).code || code;
|
||||
return (
|
||||
// we might wanna do `supportsDynamicImport` at some point
|
||||
this.transformSource(filename, code, false, false, false).code ||
|
||||
code
|
||||
);
|
||||
} finally {
|
||||
transforming = false;
|
||||
}
|
||||
},
|
||||
{
|
||||
exts: [_path().default.extname(moduleName)],
|
||||
exts: this._config.moduleFileExtensions.map(ext => `.${ext}`),
|
||||
ignoreNodeModules: false,
|
||||
matcher: filename => {
|
||||
if (transforming) {
|
||||
@@ -662,7 +698,7 @@ class ScriptTransformer {
|
||||
/**
|
||||
* @deprecated use `this.shouldTransform` instead
|
||||
*/
|
||||
// @ts-ignore: Unused and private - remove in Jest 25
|
||||
// @ts-expect-error: Unused and private - remove in Jest 25
|
||||
|
||||
_shouldTransform(filename) {
|
||||
return this.shouldTransform(filename);
|
||||
@@ -675,16 +711,29 @@ class ScriptTransformer {
|
||||
!!this._config.transform && !!this._config.transform.length && !isIgnored
|
||||
);
|
||||
}
|
||||
}
|
||||
} // TODO: do we need to define the generics twice?
|
||||
|
||||
exports.default = ScriptTransformer;
|
||||
|
||||
_defineProperty(ScriptTransformer, 'EVAL_RESULT_VARIABLE', void 0);
|
||||
function createTranspilingRequire(config) {
|
||||
const transformer = new ScriptTransformer(config);
|
||||
return function requireAndTranspileModule(
|
||||
resolverPath,
|
||||
applyInteropRequireDefault = false
|
||||
) {
|
||||
const transpiledModule = transformer.requireAndTranspileModule(
|
||||
resolverPath
|
||||
);
|
||||
return applyInteropRequireDefault
|
||||
? (0, _jestUtil().interopRequireDefault)(transpiledModule).default
|
||||
: transpiledModule;
|
||||
};
|
||||
}
|
||||
|
||||
const removeFile = path => {
|
||||
try {
|
||||
_gracefulFs().default.unlinkSync(path);
|
||||
} catch (e) {}
|
||||
fs().unlinkSync(path);
|
||||
} catch {}
|
||||
};
|
||||
|
||||
const stripShebang = content => {
|
||||
@@ -705,11 +754,7 @@ const stripShebang = content => {
|
||||
*/
|
||||
|
||||
function writeCodeCacheFile(cachePath, code) {
|
||||
const checksum = _crypto()
|
||||
.default.createHash('md5')
|
||||
.update(code)
|
||||
.digest('hex');
|
||||
|
||||
const checksum = (0, _crypto().createHash)('md5').update(code).digest('hex');
|
||||
writeCacheFile(cachePath, checksum + '\n' + code);
|
||||
}
|
||||
/**
|
||||
@@ -727,11 +772,7 @@ function readCodeCacheFile(cachePath) {
|
||||
}
|
||||
|
||||
const code = content.substr(33);
|
||||
|
||||
const checksum = _crypto()
|
||||
.default.createHash('md5')
|
||||
.update(code)
|
||||
.digest('hex');
|
||||
const checksum = (0, _crypto().createHash)('md5').update(code).digest('hex');
|
||||
|
||||
if (checksum === content.substr(0, 32)) {
|
||||
return code;
|
||||
@@ -748,8 +789,9 @@ function readCodeCacheFile(cachePath) {
|
||||
|
||||
const writeCacheFile = (cachePath, fileData) => {
|
||||
try {
|
||||
_writeFileAtomic().default.sync(cachePath, fileData, {
|
||||
encoding: 'utf8'
|
||||
(0, _writeFileAtomic().sync)(cachePath, fileData, {
|
||||
encoding: 'utf8',
|
||||
fsync: false
|
||||
});
|
||||
} catch (e) {
|
||||
if (cacheWriteErrorSafeToIgnore(e, cachePath)) {
|
||||
@@ -775,17 +817,17 @@ const writeCacheFile = (cachePath, fileData) => {
|
||||
const cacheWriteErrorSafeToIgnore = (e, cachePath) =>
|
||||
process.platform === 'win32' &&
|
||||
e.code === 'EPERM' &&
|
||||
_gracefulFs().default.existsSync(cachePath);
|
||||
fs().existsSync(cachePath);
|
||||
|
||||
const readCacheFile = cachePath => {
|
||||
if (!_gracefulFs().default.existsSync(cachePath)) {
|
||||
if (!fs().existsSync(cachePath)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let fileData;
|
||||
|
||||
try {
|
||||
fileData = _gracefulFs().default.readFileSync(cachePath, 'utf8');
|
||||
fileData = fs().readFileSync(cachePath, 'utf8');
|
||||
} catch (e) {
|
||||
e.message =
|
||||
'jest: failed to read cache file: ' +
|
||||
@@ -806,8 +848,7 @@ const readCacheFile = cachePath => {
|
||||
};
|
||||
|
||||
const getScriptCacheKey = (filename, instrument) => {
|
||||
const mtime = _gracefulFs().default.statSync(filename).mtime;
|
||||
|
||||
const mtime = fs().statSync(filename).mtime;
|
||||
return filename + '_' + mtime.getTime() + (instrument ? '_instrumented' : '');
|
||||
};
|
||||
|
||||
@@ -839,25 +880,3 @@ const calcTransformRegExp = config => {
|
||||
|
||||
return transformRegexp;
|
||||
};
|
||||
|
||||
const wrap = (content, ...extras) => {
|
||||
const globals = new Set([
|
||||
'module',
|
||||
'exports',
|
||||
'require',
|
||||
'__dirname',
|
||||
'__filename',
|
||||
'global',
|
||||
'jest',
|
||||
...extras
|
||||
]);
|
||||
return (
|
||||
'({"' +
|
||||
ScriptTransformer.EVAL_RESULT_VARIABLE +
|
||||
`":function(${Array.from(globals).join(',')}){` +
|
||||
content +
|
||||
'\n}});'
|
||||
);
|
||||
}; // TODO: Can this be added to the static property?
|
||||
|
||||
ScriptTransformer.EVAL_RESULT_VARIABLE = 'Object.<anonymous>';
|
||||
|
||||
8
node_modules/@jest/transform/build/enhanceUnexpectedTokenMessage.d.ts
generated
vendored
8
node_modules/@jest/transform/build/enhanceUnexpectedTokenMessage.d.ts
generated
vendored
@@ -4,5 +4,9 @@
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
export default function enhanceUnexpectedTokenMessage(e: Error): Error;
|
||||
//# sourceMappingURL=enhanceUnexpectedTokenMessage.d.ts.map
|
||||
interface ErrorWithCodeFrame extends Error {
|
||||
codeFrame?: string;
|
||||
}
|
||||
export default function handlePotentialSyntaxError(e: ErrorWithCodeFrame): ErrorWithCodeFrame;
|
||||
export declare function enhanceUnexpectedTokenMessage(e: Error): Error;
|
||||
export {};
|
||||
|
||||
1
node_modules/@jest/transform/build/enhanceUnexpectedTokenMessage.d.ts.map
generated
vendored
1
node_modules/@jest/transform/build/enhanceUnexpectedTokenMessage.d.ts.map
generated
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"enhanceUnexpectedTokenMessage.d.ts","sourceRoot":"","sources":["../src/enhanceUnexpectedTokenMessage.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,MAAM,CAAC,OAAO,UAAU,6BAA6B,CAAC,CAAC,EAAE,KAAK,SA2B7D"}
|
||||
26
node_modules/@jest/transform/build/enhanceUnexpectedTokenMessage.js
generated
vendored
26
node_modules/@jest/transform/build/enhanceUnexpectedTokenMessage.js
generated
vendored
@@ -3,12 +3,13 @@
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = enhanceUnexpectedTokenMessage;
|
||||
exports.default = handlePotentialSyntaxError;
|
||||
exports.enhanceUnexpectedTokenMessage = enhanceUnexpectedTokenMessage;
|
||||
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
|
||||
_chalk = function _chalk() {
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -27,6 +28,24 @@ function _interopRequireDefault(obj) {
|
||||
*/
|
||||
const DOT = ' \u2022 ';
|
||||
|
||||
function handlePotentialSyntaxError(e) {
|
||||
if (e.codeFrame) {
|
||||
e.stack = e.message + '\n' + e.codeFrame;
|
||||
}
|
||||
|
||||
if (
|
||||
// `instanceof` might come from the wrong context
|
||||
e.name === 'SyntaxError' &&
|
||||
(e.message.includes('Unexpected token') ||
|
||||
e.message.includes('Cannot use import')) &&
|
||||
!e.message.includes(' expected')
|
||||
) {
|
||||
throw enhanceUnexpectedTokenMessage(e);
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
function enhanceUnexpectedTokenMessage(e) {
|
||||
e.stack =
|
||||
`${_chalk().default.bold.red('Jest encountered an unexpected token')}
|
||||
@@ -36,6 +55,9 @@ This usually means that you are trying to import a file which Jest cannot parse,
|
||||
By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".
|
||||
|
||||
Here's what you can do:
|
||||
${DOT}If you are trying to use ECMAScript Modules, see ${_chalk().default.underline(
|
||||
'https://jestjs.io/docs/en/ecmascript-modules'
|
||||
)} for how to enable it.
|
||||
${DOT}To have some of your "node_modules" files transformed, you can specify a custom ${_chalk().default.bold(
|
||||
'"transformIgnorePatterns"'
|
||||
)} in your config.
|
||||
|
||||
6
node_modules/@jest/transform/build/index.d.ts
generated
vendored
6
node_modules/@jest/transform/build/index.d.ts
generated
vendored
@@ -4,7 +4,7 @@
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
export { default as ScriptTransformer } from './ScriptTransformer';
|
||||
export { default as ScriptTransformer, createTranspilingRequire, } from './ScriptTransformer';
|
||||
export { default as shouldInstrument } from './shouldInstrument';
|
||||
export { Transformer, ShouldInstrumentOptions, Options as TransformationOptions, } from './types';
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
export type { CacheKeyOptions, CallerTransformOptions, Transformer, ShouldInstrumentOptions, Options as TransformationOptions, TransformOptions, TransformResult, TransformedSource, } from './types';
|
||||
export { default as handlePotentialSyntaxError } from './enhanceUnexpectedTokenMessage';
|
||||
|
||||
1
node_modules/@jest/transform/build/index.d.ts.map
generated
vendored
1
node_modules/@jest/transform/build/index.d.ts.map
generated
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,OAAO,IAAI,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAC,OAAO,IAAI,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EACL,WAAW,EACX,uBAAuB,EACvB,OAAO,IAAI,qBAAqB,GACjC,MAAM,SAAS,CAAC"}
|
||||
78
node_modules/@jest/transform/build/index.js
generated
vendored
78
node_modules/@jest/transform/build/index.js
generated
vendored
@@ -5,41 +5,81 @@ Object.defineProperty(exports, '__esModule', {
|
||||
});
|
||||
Object.defineProperty(exports, 'ScriptTransformer', {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
get: function () {
|
||||
return _ScriptTransformer.default;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'createTranspilingRequire', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _ScriptTransformer.createTranspilingRequire;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'shouldInstrument', {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
get: function () {
|
||||
return _shouldInstrument.default;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'Transformer', {
|
||||
Object.defineProperty(exports, 'handlePotentialSyntaxError', {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _types.Transformer;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'ShouldInstrumentOptions', {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _types.ShouldInstrumentOptions;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'TransformationOptions', {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _types.Options;
|
||||
get: function () {
|
||||
return _enhanceUnexpectedTokenMessage.default;
|
||||
}
|
||||
});
|
||||
|
||||
var _ScriptTransformer = _interopRequireDefault(require('./ScriptTransformer'));
|
||||
var _ScriptTransformer = _interopRequireWildcard(
|
||||
require('./ScriptTransformer')
|
||||
);
|
||||
|
||||
var _shouldInstrument = _interopRequireDefault(require('./shouldInstrument'));
|
||||
|
||||
var _types = require('./types');
|
||||
var _enhanceUnexpectedTokenMessage = _interopRequireDefault(
|
||||
require('./enhanceUnexpectedTokenMessage')
|
||||
);
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
function _getRequireWildcardCache() {
|
||||
if (typeof WeakMap !== 'function') return null;
|
||||
var cache = new WeakMap();
|
||||
_getRequireWildcardCache = function () {
|
||||
return cache;
|
||||
};
|
||||
return cache;
|
||||
}
|
||||
|
||||
function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
||||
return {default: obj};
|
||||
}
|
||||
var cache = _getRequireWildcardCache();
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {};
|
||||
var hasPropertyDescriptor =
|
||||
Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for (var key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = hasPropertyDescriptor
|
||||
? Object.getOwnPropertyDescriptor(obj, key)
|
||||
: null;
|
||||
if (desc && (desc.get || desc.set)) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
if (cache) {
|
||||
cache.set(obj, newObj);
|
||||
}
|
||||
return newObj;
|
||||
}
|
||||
|
||||
5
node_modules/@jest/transform/build/shouldInstrument.d.ts
generated
vendored
5
node_modules/@jest/transform/build/shouldInstrument.d.ts
generated
vendored
@@ -4,7 +4,6 @@
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import { Config } from '@jest/types';
|
||||
import { ShouldInstrumentOptions } from './types';
|
||||
import type { Config } from '@jest/types';
|
||||
import type { ShouldInstrumentOptions } from './types';
|
||||
export default function shouldInstrument(filename: Config.Path, options: ShouldInstrumentOptions, config: Config.ProjectConfig): boolean;
|
||||
//# sourceMappingURL=shouldInstrument.d.ts.map
|
||||
1
node_modules/@jest/transform/build/shouldInstrument.d.ts.map
generated
vendored
1
node_modules/@jest/transform/build/shouldInstrument.d.ts.map
generated
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"shouldInstrument.d.ts","sourceRoot":"","sources":["../src/shouldInstrument.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAInC,OAAO,EAAC,uBAAuB,EAAC,MAAM,SAAS,CAAC;AAMhD,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACtC,QAAQ,EAAE,MAAM,CAAC,IAAI,EACrB,OAAO,EAAE,uBAAuB,EAChC,MAAM,EAAE,MAAM,CAAC,aAAa,GAC3B,OAAO,CA4ET"}
|
||||
130
node_modules/@jest/transform/build/shouldInstrument.js
generated
vendored
130
node_modules/@jest/transform/build/shouldInstrument.js
generated
vendored
@@ -5,30 +5,10 @@ Object.defineProperty(exports, '__esModule', {
|
||||
});
|
||||
exports.default = shouldInstrument;
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require('path'));
|
||||
function path() {
|
||||
const data = _interopRequireWildcard(require('path'));
|
||||
|
||||
_path = function _path() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _jestRegexUtil() {
|
||||
const data = require('jest-regex-util');
|
||||
|
||||
_jestRegexUtil = function _jestRegexUtil() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
|
||||
_jestUtil = function _jestUtil() {
|
||||
path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -38,7 +18,27 @@ function _jestUtil() {
|
||||
function _micromatch() {
|
||||
const data = _interopRequireDefault(require('micromatch'));
|
||||
|
||||
_micromatch = function _micromatch() {
|
||||
_micromatch = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _jestRegexUtil() {
|
||||
const data = require('jest-regex-util');
|
||||
|
||||
_jestRegexUtil = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
|
||||
_jestUtil = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -49,6 +49,48 @@ function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
function _getRequireWildcardCache() {
|
||||
if (typeof WeakMap !== 'function') return null;
|
||||
var cache = new WeakMap();
|
||||
_getRequireWildcardCache = function () {
|
||||
return cache;
|
||||
};
|
||||
return cache;
|
||||
}
|
||||
|
||||
function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
||||
return {default: obj};
|
||||
}
|
||||
var cache = _getRequireWildcardCache();
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {};
|
||||
var hasPropertyDescriptor =
|
||||
Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for (var key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = hasPropertyDescriptor
|
||||
? Object.getOwnPropertyDescriptor(obj, key)
|
||||
: null;
|
||||
if (desc && (desc.get || desc.set)) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
if (cache) {
|
||||
cache.set(obj, newObj);
|
||||
}
|
||||
return newObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
@@ -57,9 +99,21 @@ function _interopRequireDefault(obj) {
|
||||
*/
|
||||
const MOCKS_PATTERN = new RegExp(
|
||||
(0, _jestRegexUtil().escapePathForRegex)(
|
||||
_path().default.sep + '__mocks__' + _path().default.sep
|
||||
path().sep + '__mocks__' + path().sep
|
||||
)
|
||||
);
|
||||
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) {
|
||||
if (!options.collectCoverage) {
|
||||
@@ -74,16 +128,17 @@ function shouldInstrument(filename, options, config) {
|
||||
}
|
||||
|
||||
if (
|
||||
!config.testPathIgnorePatterns.some(pattern => !!filename.match(pattern))
|
||||
!config.testPathIgnorePatterns.some(pattern =>
|
||||
getRegex(pattern).test(filename)
|
||||
)
|
||||
) {
|
||||
if (config.testRegex.some(regex => new RegExp(regex).test(filename))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
_micromatch().default.some(
|
||||
(0, _jestUtil().replacePathSepForGlob)(filename),
|
||||
config.testMatch
|
||||
(0, _jestUtil().globsToMatcher)(config.testMatch)(
|
||||
(0, _jestUtil().replacePathSepForGlob)(filename)
|
||||
)
|
||||
) {
|
||||
return false;
|
||||
@@ -102,12 +157,11 @@ function shouldInstrument(filename, options, config) {
|
||||
if (
|
||||
// still cover if `only` is specified
|
||||
!options.collectCoverageOnlyFrom &&
|
||||
options.collectCoverageFrom &&
|
||||
!_micromatch().default.some(
|
||||
options.collectCoverageFrom.length &&
|
||||
!(0, _jestUtil().globsToMatcher)(options.collectCoverageFrom)(
|
||||
(0, _jestUtil().replacePathSepForGlob)(
|
||||
_path().default.relative(config.rootDir, filename)
|
||||
),
|
||||
options.collectCoverageFrom
|
||||
path().relative(config.rootDir, filename)
|
||||
)
|
||||
)
|
||||
) {
|
||||
return false;
|
||||
@@ -140,7 +194,13 @@ function shouldInstrument(filename, options, config) {
|
||||
}
|
||||
|
||||
if (options.changedFiles && !options.changedFiles.has(filename)) {
|
||||
return false;
|
||||
if (!options.sourcesRelatedToTestsInChangedFiles) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!options.sourcesRelatedToTestsInChangedFiles.has(filename)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
48
node_modules/@jest/transform/build/types.d.ts
generated
vendored
48
node_modules/@jest/transform/build/types.d.ts
generated
vendored
@@ -4,43 +4,41 @@
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
/// <reference types="node" />
|
||||
import { Script } from 'vm';
|
||||
import { RawSourceMap } from 'source-map';
|
||||
import { Config } from '@jest/types';
|
||||
export declare type ShouldInstrumentOptions = Pick<Config.GlobalConfig, 'collectCoverage' | 'collectCoverageFrom' | 'collectCoverageOnlyFrom'> & {
|
||||
changedFiles: Set<Config.Path> | undefined;
|
||||
import type { RawSourceMap } from 'source-map';
|
||||
import type { Config, TransformTypes } from '@jest/types';
|
||||
export declare type ShouldInstrumentOptions = Pick<Config.GlobalConfig, 'collectCoverage' | 'collectCoverageFrom' | 'collectCoverageOnlyFrom' | 'coverageProvider'> & {
|
||||
changedFiles?: Set<Config.Path>;
|
||||
sourcesRelatedToTestsInChangedFiles?: Set<Config.Path>;
|
||||
};
|
||||
export declare type Options = ShouldInstrumentOptions & Pick<Config.GlobalConfig, 'extraGlobals'> & {
|
||||
isCoreModule?: boolean;
|
||||
isInternalModule?: boolean;
|
||||
};
|
||||
declare type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
||||
export declare type Options = ShouldInstrumentOptions & Partial<{
|
||||
isCoreModule: boolean;
|
||||
isInternalModule: boolean;
|
||||
}> & CallerTransformOptions;
|
||||
interface FixedRawSourceMap extends Omit<RawSourceMap, 'version'> {
|
||||
version: number;
|
||||
}
|
||||
export declare type TransformedSource = {
|
||||
code: string;
|
||||
map?: FixedRawSourceMap | string | null;
|
||||
};
|
||||
export declare type TransformResult = {
|
||||
script: Script;
|
||||
mapCoverage: boolean;
|
||||
sourceMapPath: string | null;
|
||||
};
|
||||
export declare type TransformOptions = {
|
||||
} | string;
|
||||
export declare type TransformResult = TransformTypes.TransformResult;
|
||||
export interface CallerTransformOptions {
|
||||
supportsDynamicImport?: boolean;
|
||||
supportsExportNamespaceFrom?: boolean;
|
||||
supportsStaticESM?: boolean;
|
||||
supportsTopLevelAwait?: boolean;
|
||||
}
|
||||
export interface TransformOptions extends CallerTransformOptions {
|
||||
instrument: boolean;
|
||||
};
|
||||
export declare type CacheKeyOptions = {
|
||||
}
|
||||
export interface CacheKeyOptions extends TransformOptions {
|
||||
config: Config.ProjectConfig;
|
||||
instrument: boolean;
|
||||
rootDir: string;
|
||||
};
|
||||
}
|
||||
export interface Transformer {
|
||||
canInstrument?: boolean;
|
||||
createTransformer?: (options?: any) => Transformer;
|
||||
getCacheKey: (fileData: string, filePath: Config.Path, configStr: string, options: CacheKeyOptions) => string;
|
||||
process: (sourceText: string, sourcePath: Config.Path, config: Config.ProjectConfig, options?: TransformOptions) => string | TransformedSource;
|
||||
getCacheKey?: (fileData: string, filePath: Config.Path, configStr: string, options: CacheKeyOptions) => string;
|
||||
process: (sourceText: string, sourcePath: Config.Path, config: Config.ProjectConfig, options?: TransformOptions) => TransformedSource;
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=types.d.ts.map
|
||||
1
node_modules/@jest/transform/build/types.d.ts.map
generated
vendored
1
node_modules/@jest/transform/build/types.d.ts.map
generated
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAO,EAAC,MAAM,EAAC,MAAM,IAAI,CAAC;AAC1B,OAAO,EAAC,YAAY,EAAC,MAAM,YAAY,CAAC;AACxC,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAEnC,oBAAY,uBAAuB,GAAG,IAAI,CACxC,MAAM,CAAC,YAAY,EACnB,iBAAiB,GAAG,qBAAqB,GAAG,yBAAyB,CACtE,GAAG;IACF,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;CAC5C,CAAC;AAEF,oBAAY,OAAO,GAAG,uBAAuB,GAC3C,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,cAAc,CAAC,GAAG;IAC1C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAGJ,aAAK,IAAI,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAI/D,UAAU,iBAAkB,SAAQ,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC;IAC/D,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,oBAAY,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CAAC;CACzC,CAAC;AAEF,oBAAY,eAAe,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,OAAO,CAAC;IACrB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,CAAC;AAEF,oBAAY,gBAAgB,GAAG;IAC7B,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,oBAAY,eAAe,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAC,aAAa,CAAC;IAC7B,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,iBAAiB,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,GAAG,KAAK,WAAW,CAAC;IAEnD,WAAW,EAAE,CACX,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,CAAC,IAAI,EACrB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,eAAe,KACrB,MAAM,CAAC;IAEZ,OAAO,EAAE,CACP,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,CAAC,IAAI,EACvB,MAAM,EAAE,MAAM,CAAC,aAAa,EAC5B,OAAO,CAAC,EAAE,gBAAgB,KACvB,MAAM,GAAG,iBAAiB,CAAC;CACjC"}
|
||||
Reference in New Issue
Block a user