Add node modules and compiled JavaScript from main (#57)

Co-authored-by: Oliver King <oking3@uncc.edu>
This commit is contained in:
github-actions[bot] 2022-06-21 12:18:30 -04:00 committed by GitHub
parent d893f27da9
commit 7f7e5ba5ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6750 changed files with 1745644 additions and 10860 deletions

21
node_modules/jest-resolve/LICENSE generated vendored Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) Facebook, Inc. and its affiliates.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -0,0 +1,18 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import type { Config } from '@jest/types';
export default class ModuleNotFoundError extends Error {
code: string;
hint?: string;
requireStack?: Array<Config.Path>;
siblingWithSimilarExtensionFound?: boolean;
moduleName?: string;
private _originalMessage?;
constructor(message: string, moduleName?: string);
buildMessage(rootDir: Config.Path): void;
static duckType(error: ModuleNotFoundError): ModuleNotFoundError;
}

147
node_modules/jest-resolve/build/ModuleNotFoundError.js generated vendored Normal file
View file

@ -0,0 +1,147 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = void 0;
function path() {
const data = _interopRequireWildcard(require('path'));
path = function () {
return data;
};
return data;
}
function _slash() {
const data = _interopRequireDefault(require('slash'));
_slash = function () {
return data;
};
return data;
}
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, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
class ModuleNotFoundError extends Error {
constructor(message, moduleName) {
super(message);
_defineProperty(this, 'code', 'MODULE_NOT_FOUND');
_defineProperty(this, 'hint', void 0);
_defineProperty(this, 'requireStack', void 0);
_defineProperty(this, 'siblingWithSimilarExtensionFound', void 0);
_defineProperty(this, 'moduleName', void 0);
_defineProperty(this, '_originalMessage', void 0);
this._originalMessage = message;
this.moduleName = moduleName;
}
buildMessage(rootDir) {
var _this$requireStack;
if (!this._originalMessage) {
this._originalMessage = this.message || '';
}
let message = this._originalMessage;
if (
((_this$requireStack = this.requireStack) === null ||
_this$requireStack === void 0
? void 0
: _this$requireStack.length) &&
this.requireStack.length > 1
) {
message += `
Require stack:
${this.requireStack
.map(p => p.replace(`${rootDir}${path().sep}`, ''))
.map(_slash().default)
.join('\n ')}
`;
}
if (this.hint) {
message += this.hint;
}
this.message = message;
}
static duckType(error) {
error.buildMessage = ModuleNotFoundError.prototype.buildMessage;
return error;
}
}
exports.default = ModuleNotFoundError;

29
node_modules/jest-resolve/build/defaultResolver.d.ts generated vendored Normal file
View file

@ -0,0 +1,29 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { Opts as ResolveOpts } from 'resolve';
import type { Config } from '@jest/types';
declare type ResolverOptions = {
allowPnp?: boolean;
basedir: Config.Path;
browser?: boolean;
defaultResolver: typeof defaultResolver;
extensions?: Array<string>;
moduleDirectory?: Array<string>;
paths?: Array<Config.Path>;
rootDir?: Config.Path;
packageFilter?: ResolveOpts['packageFilter'];
};
declare global {
namespace NodeJS {
interface ProcessVersions {
pnp?: unknown;
}
}
}
export default function defaultResolver(path: Config.Path, options: ResolverOptions): Config.Path;
export declare function clearDefaultResolverCache(): void;
export {};

201
node_modules/jest-resolve/build/defaultResolver.js generated vendored Normal file
View file

@ -0,0 +1,201 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = defaultResolver;
exports.clearDefaultResolverCache = clearDefaultResolverCache;
function fs() {
const data = _interopRequireWildcard(require('graceful-fs'));
fs = function () {
return data;
};
return data;
}
function _resolve() {
const data = require('resolve');
_resolve = function () {
return data;
};
return data;
}
function _jestPnpResolver() {
const data = _interopRequireDefault(require('jest-pnp-resolver'));
_jestPnpResolver = function () {
return data;
};
return data;
}
function _jestUtil() {
const data = require('jest-util');
_jestUtil = function () {
return data;
};
return data;
}
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.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
function defaultResolver(path, options) {
if (process.versions.pnp && options.allowPnp !== false) {
return (0, _jestPnpResolver().default)(path, options);
}
const result = (0, _resolve().sync)(path, {
basedir: options.basedir,
extensions: options.extensions,
isDirectory,
isFile,
moduleDirectory: options.moduleDirectory,
packageFilter: options.packageFilter,
paths: options.paths,
preserveSymlinks: false,
realpathSync
}); // Dereference symlinks to ensure we don't create a separate
// module instance depending on how it was referenced.
return realpathSync(result);
}
function clearDefaultResolverCache() {
checkedPaths.clear();
checkedRealpathPaths.clear();
}
var IPathType;
(function (IPathType) {
IPathType[(IPathType['FILE'] = 1)] = 'FILE';
IPathType[(IPathType['DIRECTORY'] = 2)] = 'DIRECTORY';
IPathType[(IPathType['OTHER'] = 3)] = 'OTHER';
})(IPathType || (IPathType = {}));
const checkedPaths = new Map();
function statSyncCached(path) {
const result = checkedPaths.get(path);
if (result !== undefined) {
return result;
}
let stat;
try {
stat = fs().statSync(path);
} catch (e) {
if (!(e && (e.code === 'ENOENT' || e.code === 'ENOTDIR'))) {
throw e;
}
}
if (stat) {
if (stat.isFile() || stat.isFIFO()) {
checkedPaths.set(path, IPathType.FILE);
return IPathType.FILE;
} else if (stat.isDirectory()) {
checkedPaths.set(path, IPathType.DIRECTORY);
return IPathType.DIRECTORY;
}
}
checkedPaths.set(path, IPathType.OTHER);
return IPathType.OTHER;
}
const checkedRealpathPaths = new Map();
function realpathCached(path) {
let result = checkedRealpathPaths.get(path);
if (result !== undefined) {
return result;
}
result = (0, _jestUtil().tryRealpath)(path);
checkedRealpathPaths.set(path, result);
if (path !== result) {
// also cache the result in case it's ever referenced directly - no reason to `realpath` that as well
checkedRealpathPaths.set(result, result);
}
return result;
}
/*
* helper functions
*/
function isFile(file) {
return statSyncCached(file) === IPathType.FILE;
}
function isDirectory(dir) {
return statSyncCached(dir) === IPathType.DIRECTORY;
}
function realpathSync(file) {
return realpathCached(file);
}

60
node_modules/jest-resolve/build/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,60 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import type { Config } from '@jest/types';
import type { ModuleMap } from 'jest-haste-map';
import type { ResolverConfig } from './types';
import ModuleNotFoundError from './ModuleNotFoundError';
import shouldLoadAsEsm from './shouldLoadAsEsm';
declare type FindNodeModuleConfig = {
basedir: Config.Path;
browser?: boolean;
extensions?: Array<string>;
moduleDirectory?: Array<string>;
paths?: Array<Config.Path>;
resolver?: Config.Path | null;
rootDir?: Config.Path;
throwIfNotFound?: boolean;
};
declare type BooleanObject = Record<string, boolean>;
declare namespace Resolver {
type ResolveModuleConfig = {
skipNodeResolution?: boolean;
paths?: Array<Config.Path>;
};
type ResolverType = Resolver;
}
declare class Resolver {
private readonly _options;
private readonly _moduleMap;
private readonly _moduleIDCache;
private readonly _moduleNameCache;
private readonly _modulePathCache;
private readonly _supportsNativePlatform;
constructor(moduleMap: ModuleMap, options: ResolverConfig);
static ModuleNotFoundError: typeof ModuleNotFoundError;
static tryCastModuleNotFoundError(error: unknown): ModuleNotFoundError | null;
static clearDefaultResolverCache(): void;
static findNodeModule(path: Config.Path, options: FindNodeModuleConfig): Config.Path | null;
static unstable_shouldLoadAsEsm: typeof shouldLoadAsEsm;
resolveModuleFromDirIfExists(dirname: Config.Path, moduleName: string, options?: Resolver.ResolveModuleConfig): Config.Path | null;
resolveModule(from: Config.Path, moduleName: string, options?: Resolver.ResolveModuleConfig): Config.Path;
private _isAliasModule;
isCoreModule(moduleName: string): boolean;
getModule(name: string): Config.Path | null;
getModulePath(from: Config.Path, moduleName: string): Config.Path;
getPackage(name: string): Config.Path | null;
getMockModule(from: Config.Path, name: string): Config.Path | null;
getModulePaths(from: Config.Path): Array<Config.Path>;
getModuleID(virtualMocks: BooleanObject, from: Config.Path, _moduleName?: string): string;
private _getModuleType;
private _getAbsolutePath;
private _getMockPath;
private _getVirtualMockPath;
private _isModuleResolved;
resolveStubModuleName(from: Config.Path, moduleName: string): Config.Path | null;
}
export = Resolver;

570
node_modules/jest-resolve/build/index.js generated vendored Normal file
View file

@ -0,0 +1,570 @@
'use strict';
function path() {
const data = _interopRequireWildcard(require('path'));
path = function () {
return data;
};
return data;
}
function _jestUtil() {
const data = require('jest-util');
_jestUtil = function () {
return data;
};
return data;
}
function _slash() {
const data = _interopRequireDefault(require('slash'));
_slash = function () {
return data;
};
return data;
}
function _chalk() {
const data = _interopRequireDefault(require('chalk'));
_chalk = function () {
return data;
};
return data;
}
var _nodeModulesPaths = _interopRequireDefault(require('./nodeModulesPaths'));
var _isBuiltinModule = _interopRequireDefault(require('./isBuiltinModule'));
var _defaultResolver = _interopRequireWildcard(require('./defaultResolver'));
var _ModuleNotFoundError = _interopRequireDefault(
require('./ModuleNotFoundError')
);
var _shouldLoadAsEsm = _interopRequireWildcard(require('./shouldLoadAsEsm'));
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, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
const NATIVE_PLATFORM = 'native'; // We might be inside a symlink.
const resolvedCwd = (0, _jestUtil().tryRealpath)(process.cwd());
const {NODE_PATH} = process.env;
const nodePaths = NODE_PATH
? NODE_PATH.split(path().delimiter)
.filter(Boolean) // The resolver expects absolute paths.
.map(p => path().resolve(resolvedCwd, p))
: undefined;
/* eslint-disable-next-line no-redeclare */
class Resolver {
constructor(moduleMap, options) {
_defineProperty(this, '_options', void 0);
_defineProperty(this, '_moduleMap', void 0);
_defineProperty(this, '_moduleIDCache', void 0);
_defineProperty(this, '_moduleNameCache', void 0);
_defineProperty(this, '_modulePathCache', void 0);
_defineProperty(this, '_supportsNativePlatform', void 0);
this._options = {
defaultPlatform: options.defaultPlatform,
extensions: options.extensions,
hasCoreModules:
options.hasCoreModules === undefined ? true : options.hasCoreModules,
moduleDirectories: options.moduleDirectories || ['node_modules'],
moduleNameMapper: options.moduleNameMapper,
modulePaths: options.modulePaths,
platforms: options.platforms,
resolver: options.resolver,
rootDir: options.rootDir
};
this._supportsNativePlatform = options.platforms
? options.platforms.includes(NATIVE_PLATFORM)
: false;
this._moduleMap = moduleMap;
this._moduleIDCache = new Map();
this._moduleNameCache = new Map();
this._modulePathCache = new Map();
}
static tryCastModuleNotFoundError(error) {
if (error instanceof _ModuleNotFoundError.default) {
return error;
}
const casted = error;
if (casted.code === 'MODULE_NOT_FOUND') {
return _ModuleNotFoundError.default.duckType(casted);
}
return null;
}
static clearDefaultResolverCache() {
(0, _defaultResolver.clearDefaultResolverCache)();
(0, _shouldLoadAsEsm.clearCachedLookups)();
}
static findNodeModule(path, options) {
const resolver = options.resolver
? require(options.resolver)
: _defaultResolver.default;
const paths = options.paths;
try {
return resolver(path, {
basedir: options.basedir,
browser: options.browser,
defaultResolver: _defaultResolver.default,
extensions: options.extensions,
moduleDirectory: options.moduleDirectory,
paths: paths ? (nodePaths || []).concat(paths) : nodePaths,
rootDir: options.rootDir
});
} catch (e) {
if (options.throwIfNotFound) {
throw e;
}
}
return null;
} // unstable as it should be replaced by https://github.com/nodejs/modules/issues/393, and we don't want people to use it
resolveModuleFromDirIfExists(dirname, moduleName, options) {
const paths = (options && options.paths) || this._options.modulePaths;
const moduleDirectory = this._options.moduleDirectories;
const key = dirname + path().delimiter + moduleName;
const defaultPlatform = this._options.defaultPlatform;
const extensions = this._options.extensions.slice();
let module;
if (this._supportsNativePlatform) {
extensions.unshift(
...this._options.extensions.map(ext => '.' + NATIVE_PLATFORM + ext)
);
}
if (defaultPlatform) {
extensions.unshift(
...this._options.extensions.map(ext => '.' + defaultPlatform + ext)
);
} // 1. If we have already resolved this module for this directory name,
// return a value from the cache.
const cacheResult = this._moduleNameCache.get(key);
if (cacheResult) {
return cacheResult;
} // 2. Check if the module is a haste module.
module = this.getModule(moduleName);
if (module) {
this._moduleNameCache.set(key, module);
return module;
} // 3. Check if the module is a node module and resolve it based on
// the node module resolution algorithm. If skipNodeResolution is given we
// ignore all modules that look like node modules (ie. are not relative
// requires). This enables us to speed up resolution when we build a
// dependency graph because we don't have to look at modules that may not
// exist and aren't mocked.
const skipResolution =
options && options.skipNodeResolution && !moduleName.includes(path().sep);
const resolveNodeModule = (name, throwIfNotFound = false) =>
Resolver.findNodeModule(name, {
basedir: dirname,
extensions,
moduleDirectory,
paths,
resolver: this._options.resolver,
rootDir: this._options.rootDir,
throwIfNotFound
});
if (!skipResolution) {
module = resolveNodeModule(moduleName, Boolean(process.versions.pnp));
if (module) {
this._moduleNameCache.set(key, module);
return module;
}
} // 4. Resolve "haste packages" which are `package.json` files outside of
// `node_modules` folders anywhere in the file system.
const parts = moduleName.split('/');
const hastePackage = this.getPackage(parts.shift());
if (hastePackage) {
try {
const module = path().join.apply(
path(),
[path().dirname(hastePackage)].concat(parts)
); // try resolving with custom resolver first to support extensions,
// then fallback to require.resolve
const resolvedModule =
resolveNodeModule(module) || require.resolve(module);
this._moduleNameCache.set(key, resolvedModule);
return resolvedModule;
} catch {}
}
return null;
}
resolveModule(from, moduleName, options) {
const dirname = path().dirname(from);
const module =
this.resolveStubModuleName(from, moduleName) ||
this.resolveModuleFromDirIfExists(dirname, moduleName, options);
if (module) return module; // 5. Throw an error if the module could not be found. `resolve.sync` only
// produces an error based on the dirname but we have the actual current
// module name available.
const relativePath =
(0, _slash().default)(path().relative(this._options.rootDir, from)) ||
'.';
throw new _ModuleNotFoundError.default(
`Cannot find module '${moduleName}' from '${relativePath}'`,
moduleName
);
}
_isAliasModule(moduleName) {
const moduleNameMapper = this._options.moduleNameMapper;
if (!moduleNameMapper) {
return false;
}
return moduleNameMapper.some(({regex}) => regex.test(moduleName));
}
isCoreModule(moduleName) {
return (
this._options.hasCoreModules &&
(0, _isBuiltinModule.default)(moduleName) &&
!this._isAliasModule(moduleName)
);
}
getModule(name) {
return this._moduleMap.getModule(
name,
this._options.defaultPlatform,
this._supportsNativePlatform
);
}
getModulePath(from, moduleName) {
if (moduleName[0] !== '.' || path().isAbsolute(moduleName)) {
return moduleName;
}
return path().normalize(path().dirname(from) + '/' + moduleName);
}
getPackage(name) {
return this._moduleMap.getPackage(
name,
this._options.defaultPlatform,
this._supportsNativePlatform
);
}
getMockModule(from, name) {
const mock = this._moduleMap.getMockModule(name);
if (mock) {
return mock;
} else {
const moduleName = this.resolveStubModuleName(from, name);
if (moduleName) {
return this.getModule(moduleName) || moduleName;
}
}
return null;
}
getModulePaths(from) {
const cachedModule = this._modulePathCache.get(from);
if (cachedModule) {
return cachedModule;
}
const moduleDirectory = this._options.moduleDirectories;
const paths = (0, _nodeModulesPaths.default)(from, {
moduleDirectory
});
if (paths[paths.length - 1] === undefined) {
// circumvent node-resolve bug that adds `undefined` as last item.
paths.pop();
}
this._modulePathCache.set(from, paths);
return paths;
}
getModuleID(virtualMocks, from, _moduleName) {
const moduleName = _moduleName || '';
const key = from + path().delimiter + moduleName;
const cachedModuleID = this._moduleIDCache.get(key);
if (cachedModuleID) {
return cachedModuleID;
}
const moduleType = this._getModuleType(moduleName);
const absolutePath = this._getAbsolutePath(virtualMocks, from, moduleName);
const mockPath = this._getMockPath(from, moduleName);
const sep = path().delimiter;
const id =
moduleType +
sep +
(absolutePath ? absolutePath + sep : '') +
(mockPath ? mockPath + sep : '');
this._moduleIDCache.set(key, id);
return id;
}
_getModuleType(moduleName) {
return this.isCoreModule(moduleName) ? 'node' : 'user';
}
_getAbsolutePath(virtualMocks, from, moduleName) {
if (this.isCoreModule(moduleName)) {
return moduleName;
}
return this._isModuleResolved(from, moduleName)
? this.getModule(moduleName)
: this._getVirtualMockPath(virtualMocks, from, moduleName);
}
_getMockPath(from, moduleName) {
return !this.isCoreModule(moduleName)
? this.getMockModule(from, moduleName)
: null;
}
_getVirtualMockPath(virtualMocks, from, moduleName) {
const virtualMockPath = this.getModulePath(from, moduleName);
return virtualMocks[virtualMockPath]
? virtualMockPath
: moduleName
? this.resolveModule(from, moduleName)
: from;
}
_isModuleResolved(from, moduleName) {
return !!(
this.getModule(moduleName) || this.getMockModule(from, moduleName)
);
}
resolveStubModuleName(from, moduleName) {
const dirname = path().dirname(from);
const paths = this._options.modulePaths;
const extensions = this._options.extensions.slice();
const moduleDirectory = this._options.moduleDirectories;
const moduleNameMapper = this._options.moduleNameMapper;
const resolver = this._options.resolver;
const defaultPlatform = this._options.defaultPlatform;
if (this._supportsNativePlatform) {
extensions.unshift(
...this._options.extensions.map(ext => '.' + NATIVE_PLATFORM + ext)
);
}
if (defaultPlatform) {
extensions.unshift(
...this._options.extensions.map(ext => '.' + defaultPlatform + ext)
);
}
if (moduleNameMapper) {
for (const {moduleName: mappedModuleName, regex} of moduleNameMapper) {
if (regex.test(moduleName)) {
// Note: once a moduleNameMapper matches the name, it must result
// in a module, or else an error is thrown.
const matches = moduleName.match(regex);
const mapModuleName = matches
? moduleName =>
moduleName.replace(
/\$([0-9]+)/g,
(_, index) => matches[parseInt(index, 10)]
)
: moduleName => moduleName;
const possibleModuleNames = Array.isArray(mappedModuleName)
? mappedModuleName
: [mappedModuleName];
let module = null;
for (const possibleModuleName of possibleModuleNames) {
const updatedName = mapModuleName(possibleModuleName);
module =
this.getModule(updatedName) ||
Resolver.findNodeModule(updatedName, {
basedir: dirname,
extensions,
moduleDirectory,
paths,
resolver,
rootDir: this._options.rootDir
});
if (module) {
break;
}
}
if (!module) {
throw createNoMappedModuleFoundError(
moduleName,
mapModuleName,
mappedModuleName,
regex,
resolver
);
}
return module;
}
}
}
return null;
}
}
_defineProperty(Resolver, 'ModuleNotFoundError', _ModuleNotFoundError.default);
_defineProperty(Resolver, 'unstable_shouldLoadAsEsm', _shouldLoadAsEsm.default);
const createNoMappedModuleFoundError = (
moduleName,
mapModuleName,
mappedModuleName,
regex,
resolver
) => {
const mappedAs = Array.isArray(mappedModuleName)
? JSON.stringify(mappedModuleName.map(mapModuleName), null, 2)
: mappedModuleName;
const original = Array.isArray(mappedModuleName)
? JSON.stringify(mappedModuleName, null, 6) // using 6 because of misalignment when nested below
.slice(0, -1) + ' ]' /// align last bracket correctly as well
: mappedModuleName;
const error = new Error(
_chalk().default.red(`${_chalk().default.bold('Configuration error')}:
Could not locate module ${_chalk().default.bold(moduleName)} mapped as:
${_chalk().default.bold(mappedAs)}.
Please check your configuration for these entries:
{
"moduleNameMapper": {
"${regex.toString()}": "${_chalk().default.bold(original)}"
},
"resolver": ${_chalk().default.bold(String(resolver))}
}`)
);
error.name = '';
return error;
};
module.exports = Resolver;

7
node_modules/jest-resolve/build/isBuiltinModule.d.ts generated vendored Normal file
View file

@ -0,0 +1,7 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* 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 isBuiltinModule(module: string): boolean;

39
node_modules/jest-resolve/build/isBuiltinModule.js generated vendored Normal file
View file

@ -0,0 +1,39 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = isBuiltinModule;
function _module() {
const data = _interopRequireDefault(require('module'));
_module = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
const EXPERIMENTAL_MODULES = ['worker_threads'];
const BUILTIN_MODULES = new Set(
_module().default.builtinModules
? _module().default.builtinModules.concat(EXPERIMENTAL_MODULES)
: Object.keys(process.binding('natives'))
.filter(module => !/^internal\//.test(module))
.concat(EXPERIMENTAL_MODULES)
);
function isBuiltinModule(module) {
return BUILTIN_MODULES.has(module);
}

15
node_modules/jest-resolve/build/nodeModulesPaths.d.ts generated vendored Normal file
View file

@ -0,0 +1,15 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* Adapted from: https://github.com/substack/node-resolve
*/
import type { Config } from '@jest/types';
declare type NodeModulesPathsOptions = {
moduleDirectory?: Array<string>;
paths?: Array<Config.Path>;
};
export default function nodeModulesPaths(basedir: Config.Path, options: NodeModulesPathsOptions): Array<Config.Path>;
export {};

128
node_modules/jest-resolve/build/nodeModulesPaths.js generated vendored Normal file
View file

@ -0,0 +1,128 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = nodeModulesPaths;
function path() {
const data = _interopRequireWildcard(require('path'));
path = function () {
return data;
};
return data;
}
function _jestUtil() {
const data = require('jest-util');
_jestUtil = function () {
return data;
};
return data;
}
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.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* Adapted from: https://github.com/substack/node-resolve
*/
function nodeModulesPaths(basedir, options) {
const modules =
options && options.moduleDirectory
? Array.from(options.moduleDirectory)
: ['node_modules']; // ensure that `basedir` is an absolute path at this point,
// resolving against the process' current working directory
const basedirAbs = path().resolve(basedir);
let prefix = '/';
if (/^([A-Za-z]:)/.test(basedirAbs)) {
prefix = '';
} else if (/^\\\\/.test(basedirAbs)) {
prefix = '\\\\';
} // The node resolution algorithm (as implemented by NodeJS and TypeScript)
// traverses parents of the physical path, not the symlinked path
let physicalBasedir;
try {
physicalBasedir = (0, _jestUtil().tryRealpath)(basedirAbs);
} catch {
// realpath can throw, e.g. on mapped drives
physicalBasedir = basedirAbs;
}
const paths = [physicalBasedir];
let parsed = path().parse(physicalBasedir);
while (parsed.dir !== paths[paths.length - 1]) {
paths.push(parsed.dir);
parsed = path().parse(parsed.dir);
}
const dirs = paths
.reduce(
(dirs, aPath) =>
dirs.concat(
modules.map(moduleDir =>
path().isAbsolute(moduleDir)
? aPath === basedirAbs
? moduleDir
: ''
: path().join(prefix, aPath, moduleDir)
)
),
[]
)
.filter(dir => dir !== '');
return options.paths ? dirs.concat(options.paths) : dirs;
}

9
node_modules/jest-resolve/build/shouldLoadAsEsm.d.ts generated vendored Normal file
View file

@ -0,0 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import type { Config } from '@jest/types';
export declare function clearCachedLookups(): void;
export default function cachedShouldLoadAsEsm(path: Config.Path): boolean;

113
node_modules/jest-resolve/build/shouldLoadAsEsm.js generated vendored Normal file
View file

@ -0,0 +1,113 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.clearCachedLookups = clearCachedLookups;
exports.default = cachedShouldLoadAsEsm;
function _path() {
const data = require('path');
_path = function () {
return data;
};
return data;
}
function _vm() {
const data = require('vm');
_vm = function () {
return data;
};
return data;
}
function _readPkgUp() {
const data = _interopRequireDefault(require('read-pkg-up'));
_readPkgUp = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// @ts-expect-error: experimental, not added to the types
const runtimeSupportsVmModules = typeof _vm().SyntheticModule === 'function';
const cachedFileLookups = new Map();
const cachedDirLookups = new Map();
function clearCachedLookups() {
cachedFileLookups.clear();
cachedDirLookups.clear();
}
function cachedShouldLoadAsEsm(path) {
let cachedLookup = cachedFileLookups.get(path);
if (cachedLookup === undefined) {
cachedLookup = shouldLoadAsEsm(path);
cachedFileLookups.set(path, cachedLookup);
}
return cachedLookup;
} // this is a bad version of what https://github.com/nodejs/modules/issues/393 would provide
function shouldLoadAsEsm(path) {
if (!runtimeSupportsVmModules) {
return false;
}
const extension = (0, _path().extname)(path);
if (extension === '.mjs') {
return true;
}
if (extension === '.cjs') {
return false;
} // this isn't correct - we might wanna load any file as a module (using synthetic module)
// do we need an option to Jest so people can opt in to ESM for non-js?
if (extension !== '.js') {
return false;
}
const cwd = (0, _path().dirname)(path);
let cachedLookup = cachedDirLookups.get(cwd);
if (cachedLookup === undefined) {
cachedLookup = cachedPkgCheck(cwd);
cachedFileLookups.set(cwd, cachedLookup);
}
return cachedLookup;
}
function cachedPkgCheck(cwd) {
// TODO: can we cache lookups somehow?
const pkg = _readPkgUp().default.sync({
cwd,
normalize: false
});
if (!pkg) {
return false;
}
return pkg.packageJson.type === 'module';
}

23
node_modules/jest-resolve/build/types.d.ts generated vendored Normal file
View file

@ -0,0 +1,23 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import type { Config } from '@jest/types';
export declare type ResolverConfig = {
defaultPlatform?: string | null;
extensions: Array<string>;
hasCoreModules: boolean;
moduleDirectories: Array<string>;
moduleNameMapper?: Array<ModuleNameMapperConfig> | null;
modulePaths?: Array<Config.Path>;
platforms?: Array<string>;
resolver?: Config.Path | null;
rootDir: Config.Path;
};
declare type ModuleNameMapperConfig = {
regex: RegExp;
moduleName: string | Array<string>;
};
export {};

1
node_modules/jest-resolve/build/types.js generated vendored Normal file
View file

@ -0,0 +1 @@
'use strict';

34
node_modules/jest-resolve/package.json generated vendored Normal file
View file

@ -0,0 +1,34 @@
{
"name": "jest-resolve",
"version": "26.4.0",
"repository": {
"type": "git",
"url": "https://github.com/facebook/jest.git",
"directory": "packages/jest-resolve"
},
"license": "MIT",
"main": "build/index.js",
"types": "build/index.d.ts",
"dependencies": {
"@jest/types": "^26.3.0",
"chalk": "^4.0.0",
"graceful-fs": "^4.2.4",
"jest-pnp-resolver": "^1.2.2",
"jest-util": "^26.3.0",
"read-pkg-up": "^7.0.1",
"resolve": "^1.17.0",
"slash": "^3.0.0"
},
"devDependencies": {
"@types/graceful-fs": "^4.1.3",
"@types/resolve": "^1.17.0",
"jest-haste-map": "^26.3.0"
},
"engines": {
"node": ">= 10.14.2"
},
"publishConfig": {
"access": "public"
},
"gitHead": "0b1e41d1d93ce4d15646f4a39fd5a7ffae5f43c3"
}