diff --git a/.circleci/config.yml b/.circleci/config.yml index 94894e5dc858..de2c2fbafcc8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -87,6 +87,20 @@ jobs: - store_test_results: path: reports/junit + test-node-13: + working_directory: ~/jest + docker: + - image: circleci/node:13 + steps: + - checkout + - restore-cache: *restore-cache + - run: *install + - save-cache: *save-cache + - run: + command: yarn test-ci-partial + - store_test_results: + path: reports/junit + test-browser: working_directory: ~/jest docker: @@ -120,7 +134,8 @@ workflows: - lint-and-typecheck - test-node-8 - test-node-10 - - test-node-12 # current + - test-node-12 + - test-node-13 # current - test-jest-circus - test-browser - test-or-deploy-website: diff --git a/.yarn/releases/yarn-1.19.1.js b/.yarn/releases/yarn-1.19.1.js index 3907b87325d0..9b78da7a773b 100755 --- a/.yarn/releases/yarn-1.19.1.js +++ b/.yarn/releases/yarn-1.19.1.js @@ -106035,7 +106035,7 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -/* babel-plugin-inline-import './generate-pnp-map-api.tpl.js' */const pnpApi = '#!$$SHEBANG\n\n/* eslint-disable max-len, flowtype/require-valid-file-annotation, flowtype/require-return-type */\n/* global packageInformationStores, $$BLACKLIST, $$SETUP_STATIC_TABLES */\n\n// Used for the resolveUnqualified part of the resolution (ie resolving folder/index.js & file extensions)\n// Deconstructed so that they aren\'t affected by any fs monkeypatching occuring later during the execution\nconst {statSync, lstatSync, readlinkSync, readFileSync, existsSync, realpathSync} = require(\'fs\');\n\nconst Module = require(\'module\');\nconst path = require(\'path\');\nconst StringDecoder = require(\'string_decoder\');\n\nconst ignorePattern = $$BLACKLIST ? new RegExp($$BLACKLIST) : null;\n\nconst pnpFile = path.resolve(__dirname, __filename);\nconst builtinModules = new Set(Module.builtinModules || Object.keys(process.binding(\'natives\')));\n\nconst topLevelLocator = {name: null, reference: null};\nconst blacklistedLocator = {name: NaN, reference: NaN};\n\n// Used for compatibility purposes - cf setupCompatibilityLayer\nconst patchedModules = [];\nconst fallbackLocators = [topLevelLocator];\n\n// Matches backslashes of Windows paths\nconst backwardSlashRegExp = /\\\\/g;\n\n// Matches if the path must point to a directory (ie ends with /)\nconst isDirRegExp = /\\/$/;\n\n// Matches if the path starts with a valid path qualifier (./, ../, /)\n// eslint-disable-next-line no-unused-vars\nconst isStrictRegExp = /^\\.{0,2}\\//;\n\n// Splits a require request into its components, or return null if the request is a file path\nconst pathRegExp = /^(?![a-zA-Z]:[\\\\\\/]|\\\\\\\\|\\.{0,2}(?:\\/|$))((?:@[^\\/]+\\/)?[^\\/]+)\\/?(.*|)$/;\n\n// Keep a reference around ("module" is a common name in this context, so better rename it to something more significant)\nconst pnpModule = module;\n\n/**\n * Used to disable the resolution hooks (for when we want to fallback to the previous resolution - we then need\n * a way to "reset" the environment temporarily)\n */\n\nlet enableNativeHooks = true;\n\n/**\n * Simple helper function that assign an error code to an error, so that it can more easily be caught and used\n * by third-parties.\n */\n\nfunction makeError(code, message, data = {}) {\n const error = new Error(message);\n return Object.assign(error, {code, data});\n}\n\n/**\n * Ensures that the returned locator isn\'t a blacklisted one.\n *\n * Blacklisted packages are packages that cannot be used because their dependencies cannot be deduced. This only\n * happens with peer dependencies, which effectively have different sets of dependencies depending on their parents.\n *\n * In order to deambiguate those different sets of dependencies, the Yarn implementation of PnP will generate a\n * symlink for each combination of // it will find, and will\n * blacklist the target of those symlinks. By doing this, we ensure that files loaded through a specific path\n * will always have the same set of dependencies, provided the symlinks are correctly preserved.\n *\n * Unfortunately, some tools do not preserve them, and when it happens PnP isn\'t able anymore to deduce the set of\n * dependencies based on the path of the file that makes the require calls. But since we\'ve blacklisted those paths,\n * we\'re able to print a more helpful error message that points out that a third-party package is doing something\n * incompatible!\n */\n\n// eslint-disable-next-line no-unused-vars\nfunction blacklistCheck(locator) {\n if (locator === blacklistedLocator) {\n throw makeError(\n `BLACKLISTED`,\n [\n `A package has been resolved through a blacklisted path - this is usually caused by one of your tools calling`,\n `"realpath" on the return value of "require.resolve". Since the returned values use symlinks to disambiguate`,\n `peer dependencies, they must be passed untransformed to "require".`,\n ].join(` `)\n );\n }\n\n return locator;\n}\n\n$$SETUP_STATIC_TABLES();\n\n/**\n * Returns the module that should be used to resolve require calls. It\'s usually the direct parent, except if we\'re\n * inside an eval expression.\n */\n\nfunction getIssuerModule(parent) {\n let issuer = parent;\n\n while (issuer && (issuer.id === \'[eval]\' || issuer.id === \'\' || !issuer.filename)) {\n issuer = issuer.parent;\n }\n\n return issuer;\n}\n\n/**\n * Returns information about a package in a safe way (will throw if they cannot be retrieved)\n */\n\nfunction getPackageInformationSafe(packageLocator) {\n const packageInformation = exports.getPackageInformation(packageLocator);\n\n if (!packageInformation) {\n throw makeError(\n `INTERNAL`,\n `Couldn\'t find a matching entry in the dependency tree for the specified parent (this is probably an internal error)`\n );\n }\n\n return packageInformation;\n}\n\n/**\n * Implements the node resolution for folder access and extension selection\n */\n\nfunction applyNodeExtensionResolution(unqualifiedPath, {extensions}) {\n // We use this "infinite while" so that we can restart the process as long as we hit package folders\n while (true) {\n let stat;\n\n try {\n stat = statSync(unqualifiedPath);\n } catch (error) {}\n\n // If the file exists and is a file, we can stop right there\n\n if (stat && !stat.isDirectory()) {\n // If the very last component of the resolved path is a symlink to a file, we then resolve it to a file. We only\n // do this first the last component, and not the rest of the path! This allows us to support the case of bin\n // symlinks, where a symlink in "/xyz/pkg-name/.bin/bin-name" will point somewhere else (like "/xyz/pkg-name/index.js").\n // In such a case, we want relative requires to be resolved relative to "/xyz/pkg-name/" rather than "/xyz/pkg-name/.bin/".\n //\n // Also note that the reason we must use readlink on the last component (instead of realpath on the whole path)\n // is that we must preserve the other symlinks, in particular those used by pnp to deambiguate packages using\n // peer dependencies. For example, "/xyz/.pnp/local/pnp-01234569/.bin/bin-name" should see its relative requires\n // be resolved relative to "/xyz/.pnp/local/pnp-0123456789/" rather than "/xyz/pkg-with-peers/", because otherwise\n // we would lose the information that would tell us what are the dependencies of pkg-with-peers relative to its\n // ancestors.\n\n if (lstatSync(unqualifiedPath).isSymbolicLink()) {\n unqualifiedPath = path.normalize(path.resolve(path.dirname(unqualifiedPath), readlinkSync(unqualifiedPath)));\n }\n\n return unqualifiedPath;\n }\n\n // If the file is a directory, we must check if it contains a package.json with a "main" entry\n\n if (stat && stat.isDirectory()) {\n let pkgJson;\n\n try {\n pkgJson = JSON.parse(readFileSync(`${unqualifiedPath}/package.json`, \'utf-8\'));\n } catch (error) {}\n\n let nextUnqualifiedPath;\n\n if (pkgJson && pkgJson.main) {\n nextUnqualifiedPath = path.resolve(unqualifiedPath, pkgJson.main);\n }\n\n // If the "main" field changed the path, we start again from this new location\n\n if (nextUnqualifiedPath && nextUnqualifiedPath !== unqualifiedPath) {\n const resolution = applyNodeExtensionResolution(nextUnqualifiedPath, {extensions});\n\n if (resolution !== null) {\n return resolution;\n }\n }\n }\n\n // Otherwise we check if we find a file that match one of the supported extensions\n\n const qualifiedPath = extensions\n .map(extension => {\n return `${unqualifiedPath}${extension}`;\n })\n .find(candidateFile => {\n return existsSync(candidateFile);\n });\n\n if (qualifiedPath) {\n return qualifiedPath;\n }\n\n // Otherwise, we check if the path is a folder - in such a case, we try to use its index\n\n if (stat && stat.isDirectory()) {\n const indexPath = extensions\n .map(extension => {\n return `${unqualifiedPath}/index${extension}`;\n })\n .find(candidateFile => {\n return existsSync(candidateFile);\n });\n\n if (indexPath) {\n return indexPath;\n }\n }\n\n // Otherwise there\'s nothing else we can do :(\n\n return null;\n }\n}\n\n/**\n * This function creates fake modules that can be used with the _resolveFilename function.\n * Ideally it would be nice to be able to avoid this, since it causes useless allocations\n * and cannot be cached efficiently (we recompute the nodeModulePaths every time).\n *\n * Fortunately, this should only affect the fallback, and there hopefully shouldn\'t be a\n * lot of them.\n */\n\nfunction makeFakeModule(path) {\n const fakeModule = new Module(path, false);\n fakeModule.filename = path;\n fakeModule.paths = Module._nodeModulePaths(path);\n return fakeModule;\n}\n\n/**\n * Normalize path to posix format.\n */\n\nfunction normalizePath(fsPath) {\n fsPath = path.normalize(fsPath);\n\n if (process.platform === \'win32\') {\n fsPath = fsPath.replace(backwardSlashRegExp, \'/\');\n }\n\n return fsPath;\n}\n\n/**\n * Forward the resolution to the next resolver (usually the native one)\n */\n\nfunction callNativeResolution(request, issuer) {\n if (issuer.endsWith(\'/\')) {\n issuer += \'internal.js\';\n }\n\n try {\n enableNativeHooks = false;\n\n // Since we would need to create a fake module anyway (to call _resolveLookupPath that\n // would give us the paths to give to _resolveFilename), we can as well not use\n // the {paths} option at all, since it internally makes _resolveFilename create another\n // fake module anyway.\n return Module._resolveFilename(request, makeFakeModule(issuer), false);\n } finally {\n enableNativeHooks = true;\n }\n}\n\n/**\n * This key indicates which version of the standard is implemented by this resolver. The `std` key is the\n * Plug\'n\'Play standard, and any other key are third-party extensions. Third-party extensions are not allowed\n * to override the standard, and can only offer new methods.\n *\n * If an new version of the Plug\'n\'Play standard is released and some extensions conflict with newly added\n * functions, they\'ll just have to fix the conflicts and bump their own version number.\n */\n\nexports.VERSIONS = {std: 1};\n\n/**\n * Useful when used together with getPackageInformation to fetch information about the top-level package.\n */\n\nexports.topLevel = {name: null, reference: null};\n\n/**\n * Gets the package information for a given locator. Returns null if they cannot be retrieved.\n */\n\nexports.getPackageInformation = function getPackageInformation({name, reference}) {\n const packageInformationStore = packageInformationStores.get(name);\n\n if (!packageInformationStore) {\n return null;\n }\n\n const packageInformation = packageInformationStore.get(reference);\n\n if (!packageInformation) {\n return null;\n }\n\n return packageInformation;\n};\n\n/**\n * Transforms a request (what\'s typically passed as argument to the require function) into an unqualified path.\n * This path is called "unqualified" because it only changes the package name to the package location on the disk,\n * which means that the end result still cannot be directly accessed (for example, it doesn\'t try to resolve the\n * file extension, or to resolve directories to their "index.js" content). Use the "resolveUnqualified" function\n * to convert them to fully-qualified paths, or just use "resolveRequest" that do both operations in one go.\n *\n * Note that it is extremely important that the `issuer` path ends with a forward slash if the issuer is to be\n * treated as a folder (ie. "/tmp/foo/" rather than "/tmp/foo" if "foo" is a directory). Otherwise relative\n * imports won\'t be computed correctly (they\'ll get resolved relative to "/tmp/" instead of "/tmp/foo/").\n */\n\nexports.resolveToUnqualified = function resolveToUnqualified(request, issuer, {considerBuiltins = true} = {}) {\n // The \'pnpapi\' request is reserved and will always return the path to the PnP file, from everywhere\n\n if (request === `pnpapi`) {\n return pnpFile;\n }\n\n // Bailout if the request is a native module\n\n if (considerBuiltins && builtinModules.has(request)) {\n return null;\n }\n\n // We allow disabling the pnp resolution for some subpaths. This is because some projects, often legacy,\n // contain multiple levels of dependencies (ie. a yarn.lock inside a subfolder of a yarn.lock). This is\n // typically solved using workspaces, but not all of them have been converted already.\n\n if (ignorePattern && ignorePattern.test(normalizePath(issuer))) {\n const result = callNativeResolution(request, issuer);\n\n if (result === false) {\n throw makeError(\n `BUILTIN_NODE_RESOLUTION_FAIL`,\n `The builtin node resolution algorithm was unable to resolve the module referenced by "${request}" and requested from "${issuer}" (it didn\'t go through the pnp resolver because the issuer was explicitely ignored by the regexp "$$BLACKLIST")`,\n {\n request,\n issuer,\n }\n );\n }\n\n return result;\n }\n\n let unqualifiedPath;\n\n // If the request is a relative or absolute path, we just return it normalized\n\n const dependencyNameMatch = request.match(pathRegExp);\n\n if (!dependencyNameMatch) {\n if (path.isAbsolute(request)) {\n unqualifiedPath = path.normalize(request);\n } else if (issuer.match(isDirRegExp)) {\n unqualifiedPath = path.normalize(path.resolve(issuer, request));\n } else {\n unqualifiedPath = path.normalize(path.resolve(path.dirname(issuer), request));\n }\n }\n\n // Things are more hairy if it\'s a package require - we then need to figure out which package is needed, and in\n // particular the exact version for the given location on the dependency tree\n\n if (dependencyNameMatch) {\n const [, dependencyName, subPath] = dependencyNameMatch;\n\n const issuerLocator = exports.findPackageLocator(issuer);\n\n // If the issuer file doesn\'t seem to be owned by a package managed through pnp, then we resort to using the next\n // resolution algorithm in the chain, usually the native Node resolution one\n\n if (!issuerLocator) {\n const result = callNativeResolution(request, issuer);\n\n if (result === false) {\n throw makeError(\n `BUILTIN_NODE_RESOLUTION_FAIL`,\n `The builtin node resolution algorithm was unable to resolve the module referenced by "${request}" and requested from "${issuer}" (it didn\'t go through the pnp resolver because the issuer doesn\'t seem to be part of the Yarn-managed dependency tree)`,\n {\n request,\n issuer,\n }\n );\n }\n\n return result;\n }\n\n const issuerInformation = getPackageInformationSafe(issuerLocator);\n\n // We obtain the dependency reference in regard to the package that request it\n\n let dependencyReference = issuerInformation.packageDependencies.get(dependencyName);\n\n // If we can\'t find it, we check if we can potentially load it from the packages that have been defined as potential fallbacks.\n // It\'s a bit of a hack, but it improves compatibility with the existing Node ecosystem. Hopefully we should eventually be able\n // to kill this logic and become stricter once pnp gets enough traction and the affected packages fix themselves.\n\n if (issuerLocator !== topLevelLocator) {\n for (let t = 0, T = fallbackLocators.length; dependencyReference === undefined && t < T; ++t) {\n const fallbackInformation = getPackageInformationSafe(fallbackLocators[t]);\n dependencyReference = fallbackInformation.packageDependencies.get(dependencyName);\n }\n }\n\n // If we can\'t find the path, and if the package making the request is the top-level, we can offer nicer error messages\n\n if (!dependencyReference) {\n if (dependencyReference === null) {\n if (issuerLocator === topLevelLocator) {\n throw makeError(\n `MISSING_PEER_DEPENDENCY`,\n `You seem to be requiring a peer dependency ("${dependencyName}"), but it is not installed (which might be because you\'re the top-level package)`,\n {request, issuer, dependencyName}\n );\n } else {\n throw makeError(\n `MISSING_PEER_DEPENDENCY`,\n `Package "${issuerLocator.name}@${issuerLocator.reference}" is trying to access a peer dependency ("${dependencyName}") that should be provided by its direct ancestor but isn\'t`,\n {request, issuer, issuerLocator: Object.assign({}, issuerLocator), dependencyName}\n );\n }\n } else {\n if (issuerLocator === topLevelLocator) {\n throw makeError(\n `UNDECLARED_DEPENDENCY`,\n `You cannot require a package ("${dependencyName}") that is not declared in your dependencies (via "${issuer}")`,\n {request, issuer, dependencyName}\n );\n } else {\n const candidates = Array.from(issuerInformation.packageDependencies.keys());\n throw makeError(\n `UNDECLARED_DEPENDENCY`,\n `Package "${issuerLocator.name}@${issuerLocator.reference}" (via "${issuer}") is trying to require the package "${dependencyName}" (via "${request}") without it being listed in its dependencies (${candidates.join(\n `, `\n )})`,\n {request, issuer, issuerLocator: Object.assign({}, issuerLocator), dependencyName, candidates}\n );\n }\n }\n }\n\n // We need to check that the package exists on the filesystem, because it might not have been installed\n\n const dependencyLocator = {name: dependencyName, reference: dependencyReference};\n const dependencyInformation = exports.getPackageInformation(dependencyLocator);\n const dependencyLocation = path.resolve(__dirname, dependencyInformation.packageLocation);\n\n if (!dependencyLocation) {\n throw makeError(\n `MISSING_DEPENDENCY`,\n `Package "${dependencyLocator.name}@${dependencyLocator.reference}" is a valid dependency, but hasn\'t been installed and thus cannot be required (it might be caused if you install a partial tree, such as on production environments)`,\n {request, issuer, dependencyLocator: Object.assign({}, dependencyLocator)}\n );\n }\n\n // Now that we know which package we should resolve to, we only have to find out the file location\n\n if (subPath) {\n unqualifiedPath = path.resolve(dependencyLocation, subPath);\n } else {\n unqualifiedPath = dependencyLocation;\n }\n }\n\n return path.normalize(unqualifiedPath);\n};\n\n/**\n * Transforms an unqualified path into a qualified path by using the Node resolution algorithm (which automatically\n * appends ".js" / ".json", and transforms directory accesses into "index.js").\n */\n\nexports.resolveUnqualified = function resolveUnqualified(\n unqualifiedPath,\n {extensions = Object.keys(Module._extensions)} = {}\n) {\n const qualifiedPath = applyNodeExtensionResolution(unqualifiedPath, {extensions});\n\n if (qualifiedPath) {\n return path.normalize(qualifiedPath);\n } else {\n throw makeError(\n `QUALIFIED_PATH_RESOLUTION_FAILED`,\n `Couldn\'t find a suitable Node resolution for unqualified path "${unqualifiedPath}"`,\n {unqualifiedPath}\n );\n }\n};\n\n/**\n * Transforms a request into a fully qualified path.\n *\n * Note that it is extremely important that the `issuer` path ends with a forward slash if the issuer is to be\n * treated as a folder (ie. "/tmp/foo/" rather than "/tmp/foo" if "foo" is a directory). Otherwise relative\n * imports won\'t be computed correctly (they\'ll get resolved relative to "/tmp/" instead of "/tmp/foo/").\n */\n\nexports.resolveRequest = function resolveRequest(request, issuer, {considerBuiltins, extensions} = {}) {\n let unqualifiedPath;\n\n try {\n unqualifiedPath = exports.resolveToUnqualified(request, issuer, {considerBuiltins});\n } catch (originalError) {\n // If we get a BUILTIN_NODE_RESOLUTION_FAIL error there, it means that we\'ve had to use the builtin node\n // resolution, which usually shouldn\'t happen. It might be because the user is trying to require something\n // from a path loaded through a symlink (which is not possible, because we need something normalized to\n // figure out which package is making the require call), so we try to make the same request using a fully\n // resolved issuer and throws a better and more actionable error if it works.\n if (originalError.code === `BUILTIN_NODE_RESOLUTION_FAIL`) {\n let realIssuer;\n\n try {\n realIssuer = realpathSync(issuer);\n } catch (error) {}\n\n if (realIssuer) {\n if (issuer.endsWith(`/`)) {\n realIssuer = realIssuer.replace(/\\/?$/, `/`);\n }\n\n try {\n exports.resolveToUnqualified(request, realIssuer, {considerBuiltins});\n } catch (error) {\n // If an error was thrown, the problem doesn\'t seem to come from a path not being normalized, so we\n // can just throw the original error which was legit.\n throw originalError;\n }\n\n // If we reach this stage, it means that resolveToUnqualified didn\'t fail when using the fully resolved\n // file path, which is very likely caused by a module being invoked through Node with a path not being\n // correctly normalized (ie you should use "node $(realpath script.js)" instead of "node script.js").\n throw makeError(\n `SYMLINKED_PATH_DETECTED`,\n `A pnp module ("${request}") has been required from what seems to be a symlinked path ("${issuer}"). This is not possible, you must ensure that your modules are invoked through their fully resolved path on the filesystem (in this case "${realIssuer}").`,\n {\n request,\n issuer,\n realIssuer,\n }\n );\n }\n }\n throw originalError;\n }\n\n if (unqualifiedPath === null) {\n return null;\n }\n\n try {\n return exports.resolveUnqualified(unqualifiedPath, {extensions});\n } catch (resolutionError) {\n if (resolutionError.code === \'QUALIFIED_PATH_RESOLUTION_FAILED\') {\n Object.assign(resolutionError.data, {request, issuer});\n }\n throw resolutionError;\n }\n};\n\n/**\n * Setups the hook into the Node environment.\n *\n * From this point on, any call to `require()` will go through the "resolveRequest" function, and the result will\n * be used as path of the file to load.\n */\n\nexports.setup = function setup() {\n // A small note: we don\'t replace the cache here (and instead use the native one). This is an effort to not\n // break code similar to "delete require.cache[require.resolve(FOO)]", where FOO is a package located outside\n // of the Yarn dependency tree. In this case, we defer the load to the native loader. If we were to replace the\n // cache by our own, the native loader would populate its own cache, which wouldn\'t be exposed anymore, so the\n // delete call would be broken.\n\n const originalModuleLoad = Module._load;\n\n Module._load = function(request, parent, isMain) {\n if (!enableNativeHooks) {\n return originalModuleLoad.call(Module, request, parent, isMain);\n }\n\n // Builtins are managed by the regular Node loader\n\n if (builtinModules.has(request)) {\n try {\n enableNativeHooks = false;\n return originalModuleLoad.call(Module, request, parent, isMain);\n } finally {\n enableNativeHooks = true;\n }\n }\n\n // The \'pnpapi\' name is reserved to return the PnP api currently in use by the program\n\n if (request === `pnpapi`) {\n return pnpModule.exports;\n }\n\n // Request `Module._resolveFilename` (ie. `resolveRequest`) to tell us which file we should load\n\n const modulePath = Module._resolveFilename(request, parent, isMain);\n\n // Check if the module has already been created for the given file\n\n const cacheEntry = Module._cache[modulePath];\n\n if (cacheEntry) {\n return cacheEntry.exports;\n }\n\n // Create a new module and store it into the cache\n\n const module = new Module(modulePath, parent);\n Module._cache[modulePath] = module;\n\n // The main module is exposed as global variable\n\n if (isMain) {\n process.mainModule = module;\n module.id = \'.\';\n }\n\n // Try to load the module, and remove it from the cache if it fails\n\n let hasThrown = true;\n\n try {\n module.load(modulePath);\n hasThrown = false;\n } finally {\n if (hasThrown) {\n delete Module._cache[modulePath];\n }\n }\n\n // Some modules might have to be patched for compatibility purposes\n\n for (const [filter, patchFn] of patchedModules) {\n if (filter.test(request)) {\n module.exports = patchFn(exports.findPackageLocator(parent.filename), module.exports);\n }\n }\n\n return module.exports;\n };\n\n const originalModuleResolveFilename = Module._resolveFilename;\n\n Module._resolveFilename = function(request, parent, isMain, options) {\n if (!enableNativeHooks) {\n return originalModuleResolveFilename.call(Module, request, parent, isMain, options);\n }\n\n let issuers;\n\n if (options) {\n const optionNames = new Set(Object.keys(options));\n optionNames.delete(\'paths\');\n\n if (optionNames.size > 0) {\n throw makeError(\n `UNSUPPORTED`,\n `Some options passed to require() aren\'t supported by PnP yet (${Array.from(optionNames).join(\', \')})`\n );\n }\n\n if (options.paths) {\n issuers = options.paths.map(entry => `${path.normalize(entry)}/`);\n }\n }\n\n if (!issuers) {\n const issuerModule = getIssuerModule(parent);\n const issuer = issuerModule ? issuerModule.filename : `${process.cwd()}/`;\n\n issuers = [issuer];\n }\n\n let firstError;\n\n for (const issuer of issuers) {\n let resolution;\n\n try {\n resolution = exports.resolveRequest(request, issuer);\n } catch (error) {\n firstError = firstError || error;\n continue;\n }\n\n return resolution !== null ? resolution : request;\n }\n\n throw firstError;\n };\n\n const originalFindPath = Module._findPath;\n\n Module._findPath = function(request, paths, isMain) {\n if (!enableNativeHooks) {\n return originalFindPath.call(Module, request, paths, isMain);\n }\n\n for (const path of paths) {\n let resolution;\n\n try {\n resolution = exports.resolveRequest(request, path);\n } catch (error) {\n continue;\n }\n\n if (resolution) {\n return resolution;\n }\n }\n\n return false;\n };\n\n process.versions.pnp = String(exports.VERSIONS.std);\n};\n\nexports.setupCompatibilityLayer = () => {\n // ESLint currently doesn\'t have any portable way for shared configs to specify their own\n // plugins that should be used (https://github.com/eslint/eslint/issues/10125). This will\n // likely get fixed at some point, but it\'ll take time and in the meantime we\'ll just add\n // additional fallback entries for common shared configs.\n\n for (const name of [`react-scripts`]) {\n const packageInformationStore = packageInformationStores.get(name);\n if (packageInformationStore) {\n for (const reference of packageInformationStore.keys()) {\n fallbackLocators.push({name, reference});\n }\n }\n }\n\n // Modern versions of `resolve` support a specific entry point that custom resolvers can use\n // to inject a specific resolution logic without having to patch the whole package.\n //\n // Cf: https://github.com/browserify/resolve/pull/174\n\n patchedModules.push([\n /^\\.\\/normalize-options\\.js$/,\n (issuer, normalizeOptions) => {\n if (!issuer || issuer.name !== \'resolve\') {\n return normalizeOptions;\n }\n\n return (request, opts) => {\n opts = opts || {};\n\n if (opts.forceNodeResolution) {\n return opts;\n }\n\n opts.preserveSymlinks = true;\n opts.paths = function(request, basedir, getNodeModulesDir, opts) {\n // Extract the name of the package being requested (1=full name, 2=scope name, 3=local name)\n const parts = request.match(/^((?:(@[^\\/]+)\\/)?([^\\/]+))/);\n\n // make sure that basedir ends with a slash\n if (basedir.charAt(basedir.length - 1) !== \'/\') {\n basedir = path.join(basedir, \'/\');\n }\n // This is guaranteed to return the path to the "package.json" file from the given package\n const manifestPath = exports.resolveToUnqualified(`${parts[1]}/package.json`, basedir);\n\n // The first dirname strips the package.json, the second strips the local named folder\n let nodeModules = path.dirname(path.dirname(manifestPath));\n\n // Strips the scope named folder if needed\n if (parts[2]) {\n nodeModules = path.dirname(nodeModules);\n }\n\n return [nodeModules];\n };\n\n return opts;\n };\n },\n ]);\n};\n\nif (module.parent && module.parent.id === \'internal/preload\') {\n exports.setupCompatibilityLayer();\n\n exports.setup();\n}\n\nif (process.mainModule === module) {\n exports.setupCompatibilityLayer();\n\n const reportError = (code, message, data) => {\n process.stdout.write(`${JSON.stringify([{code, message, data}, null])}\\n`);\n };\n\n const reportSuccess = resolution => {\n process.stdout.write(`${JSON.stringify([null, resolution])}\\n`);\n };\n\n const processResolution = (request, issuer) => {\n try {\n reportSuccess(exports.resolveRequest(request, issuer));\n } catch (error) {\n reportError(error.code, error.message, error.data);\n }\n };\n\n const processRequest = data => {\n try {\n const [request, issuer] = JSON.parse(data);\n processResolution(request, issuer);\n } catch (error) {\n reportError(`INVALID_JSON`, error.message, error.data);\n }\n };\n\n if (process.argv.length > 2) {\n if (process.argv.length !== 4) {\n process.stderr.write(`Usage: ${process.argv[0]} ${process.argv[1]} \\n`);\n process.exitCode = 64; /* EX_USAGE */\n } else {\n processResolution(process.argv[2], process.argv[3]);\n }\n } else {\n let buffer = \'\';\n const decoder = new StringDecoder.StringDecoder();\n\n process.stdin.on(\'data\', chunk => {\n buffer += decoder.write(chunk);\n\n do {\n const index = buffer.indexOf(\'\\n\');\n if (index === -1) {\n break;\n }\n\n const line = buffer.slice(0, index);\n buffer = buffer.slice(index + 1);\n\n processRequest(line);\n } while (true);\n });\n }\n}\n'; +/* babel-plugin-inline-import './generate-pnp-map-api.tpl.js' */const pnpApi = '#!$$SHEBANG\n\n/* eslint-disable max-len, flowtype/require-valid-file-annotation, flowtype/require-return-type */\n/* global packageInformationStores, $$BLACKLIST, $$SETUP_STATIC_TABLES */\n\n// Used for the resolveUnqualified part of the resolution (ie resolving folder/index.js & file extensions)\n// Deconstructed so that they aren\'t affected by any fs monkeypatching occuring later during the execution\nconst {statSync, lstatSync, readlinkSync, readFileSync, existsSync, realpathSync} = require(\'fs\');\n\nconst Module = require(\'module\');\nconst path = require(\'path\');\nconst StringDecoder = require(\'string_decoder\');\n\nconst ignorePattern = $$BLACKLIST ? new RegExp($$BLACKLIST) : null;\n\nconst pnpFile = path.resolve(__dirname, __filename);\nconst builtinModules = new Set(Module.builtinModules || Object.keys(process.binding(\'natives\')));\n\nconst topLevelLocator = {name: null, reference: null};\nconst blacklistedLocator = {name: NaN, reference: NaN};\n\n// Used for compatibility purposes - cf setupCompatibilityLayer\nconst patchedModules = [];\nconst fallbackLocators = [topLevelLocator];\n\n// Matches backslashes of Windows paths\nconst backwardSlashRegExp = /\\\\/g;\n\n// Matches if the path must point to a directory (ie ends with /)\nconst isDirRegExp = /\\/$/;\n\n// Matches if the path starts with a valid path qualifier (./, ../, /)\n// eslint-disable-next-line no-unused-vars\nconst isStrictRegExp = /^\\.{0,2}\\//;\n\n// Splits a require request into its components, or return null if the request is a file path\nconst pathRegExp = /^(?![a-zA-Z]:[\\\\\\/]|\\\\\\\\|\\.{0,2}(?:\\/|$))((?:@[^\\/]+\\/)?[^\\/]+)\\/?(.*|)$/;\n\n// Keep a reference around ("module" is a common name in this context, so better rename it to something more significant)\nconst pnpModule = module;\n\n/**\n * Used to disable the resolution hooks (for when we want to fallback to the previous resolution - we then need\n * a way to "reset" the environment temporarily)\n */\n\nlet enableNativeHooks = true;\n\n/**\n * Simple helper function that assign an error code to an error, so that it can more easily be caught and used\n * by third-parties.\n */\n\nfunction makeError(code, message, data = {}) {\n const error = new Error(message);\n return Object.assign(error, {code, data});\n}\n\n/**\n * Ensures that the returned locator isn\'t a blacklisted one.\n *\n * Blacklisted packages are packages that cannot be used because their dependencies cannot be deduced. This only\n * happens with peer dependencies, which effectively have different sets of dependencies depending on their parents.\n *\n * In order to deambiguate those different sets of dependencies, the Yarn implementation of PnP will generate a\n * symlink for each combination of // it will find, and will\n * blacklist the target of those symlinks. By doing this, we ensure that files loaded through a specific path\n * will always have the same set of dependencies, provided the symlinks are correctly preserved.\n *\n * Unfortunately, some tools do not preserve them, and when it happens PnP isn\'t able anymore to deduce the set of\n * dependencies based on the path of the file that makes the require calls. But since we\'ve blacklisted those paths,\n * we\'re able to print a more helpful error message that points out that a third-party package is doing something\n * incompatible!\n */\n\n// eslint-disable-next-line no-unused-vars\nfunction blacklistCheck(locator) {\n if (locator === blacklistedLocator) {\n throw makeError(\n `BLACKLISTED`,\n [\n `A package has been resolved through a blacklisted path - this is usually caused by one of your tools calling`,\n `"realpath" on the return value of "require.resolve". Since the returned values use symlinks to disambiguate`,\n `peer dependencies, they must be passed untransformed to "require".`,\n ].join(` `)\n );\n }\n\n return locator;\n}\n\n$$SETUP_STATIC_TABLES();\n\n/**\n * Returns the module that should be used to resolve require calls. It\'s usually the direct parent, except if we\'re\n * inside an eval expression.\n */\n\nfunction getIssuerModule(parent) {\n let issuer = parent;\n\n while (issuer && (issuer.id === \'[eval]\' || issuer.id === \'\' || !issuer.filename)) {\n issuer = issuer.parent;\n }\n\n return issuer;\n}\n\n/**\n * Returns information about a package in a safe way (will throw if they cannot be retrieved)\n */\n\nfunction getPackageInformationSafe(packageLocator) {\n const packageInformation = exports.getPackageInformation(packageLocator);\n\n if (!packageInformation) {\n throw makeError(\n `INTERNAL`,\n `Couldn\'t find a matching entry in the dependency tree for the specified parent (this is probably an internal error)`\n );\n }\n\n return packageInformation;\n}\n\n/**\n * Implements the node resolution for folder access and extension selection\n */\n\nfunction applyNodeExtensionResolution(unqualifiedPath, {extensions}) {\n // We use this "infinite while" so that we can restart the process as long as we hit package folders\n while (true) {\n let stat;\n\n try {\n stat = statSync(unqualifiedPath);\n } catch (error) {}\n\n // If the file exists and is a file, we can stop right there\n\n if (stat && !stat.isDirectory()) {\n // If the very last component of the resolved path is a symlink to a file, we then resolve it to a file. We only\n // do this first the last component, and not the rest of the path! This allows us to support the case of bin\n // symlinks, where a symlink in "/xyz/pkg-name/.bin/bin-name" will point somewhere else (like "/xyz/pkg-name/index.js").\n // In such a case, we want relative requires to be resolved relative to "/xyz/pkg-name/" rather than "/xyz/pkg-name/.bin/".\n //\n // Also note that the reason we must use readlink on the last component (instead of realpath on the whole path)\n // is that we must preserve the other symlinks, in particular those used by pnp to deambiguate packages using\n // peer dependencies. For example, "/xyz/.pnp/local/pnp-01234569/.bin/bin-name" should see its relative requires\n // be resolved relative to "/xyz/.pnp/local/pnp-0123456789/" rather than "/xyz/pkg-with-peers/", because otherwise\n // we would lose the information that would tell us what are the dependencies of pkg-with-peers relative to its\n // ancestors.\n\n if (lstatSync(unqualifiedPath).isSymbolicLink()) {\n unqualifiedPath = path.normalize(path.resolve(path.dirname(unqualifiedPath), readlinkSync(unqualifiedPath)));\n }\n\n return unqualifiedPath;\n }\n\n // If the file is a directory, we must check if it contains a package.json with a "main" entry\n\n if (stat && stat.isDirectory()) {\n let pkgJson;\n\n try {\n pkgJson = JSON.parse(readFileSync(`${unqualifiedPath}/package.json`, \'utf-8\'));\n } catch (error) {}\n\n let nextUnqualifiedPath;\n\n if (pkgJson && pkgJson.main) {\n nextUnqualifiedPath = path.resolve(unqualifiedPath, pkgJson.main);\n }\n\n // If the "main" field changed the path, we start again from this new location\n\n if (nextUnqualifiedPath && nextUnqualifiedPath !== unqualifiedPath) {\n const resolution = applyNodeExtensionResolution(nextUnqualifiedPath, {extensions});\n\n if (resolution !== null) {\n return resolution;\n }\n }\n }\n\n // Otherwise we check if we find a file that match one of the supported extensions\n\n const qualifiedPath = extensions\n .map(extension => {\n return `${unqualifiedPath}${extension}`;\n })\n .find(candidateFile => {\n return existsSync(candidateFile);\n });\n\n if (qualifiedPath) {\n return qualifiedPath;\n }\n\n // Otherwise, we check if the path is a folder - in such a case, we try to use its index\n\n if (stat && stat.isDirectory()) {\n const indexPath = extensions\n .map(extension => {\n return `${unqualifiedPath}/index${extension}`;\n })\n .find(candidateFile => {\n return existsSync(candidateFile);\n });\n\n if (indexPath) {\n return indexPath;\n }\n }\n\n // Otherwise there\'s nothing else we can do :(\n\n return null;\n }\n}\n\n/**\n * This function creates fake modules that can be used with the _resolveFilename function.\n * Ideally it would be nice to be able to avoid this, since it causes useless allocations\n * and cannot be cached efficiently (we recompute the nodeModulePaths every time).\n *\n * Fortunately, this should only affect the fallback, and there hopefully shouldn\'t be a\n * lot of them.\n */\n\nfunction makeFakeModule(path) {\n const fakeModule = new Module(path, false);\n fakeModule.filename = path;\n fakeModule.paths = Module._nodeModulePaths(path);\n return fakeModule;\n}\n\n/**\n * Normalize path to posix format.\n */\n\nfunction normalizePath(fsPath) {\n fsPath = path.normalize(fsPath);\n\n if (process.platform === \'win32\') {\n fsPath = fsPath.replace(backwardSlashRegExp, \'/\');\n }\n\n return fsPath;\n}\n\n/**\n * Forward the resolution to the next resolver (usually the native one)\n */\n\nfunction callNativeResolution(request, issuer) {\n if (issuer.endsWith(\'/\')) {\n issuer += \'internal.js\';\n }\n\n try {\n enableNativeHooks = false;\n\n // Since we would need to create a fake module anyway (to call _resolveLookupPath that\n // would give us the paths to give to _resolveFilename), we can as well not use\n // the {paths} option at all, since it internally makes _resolveFilename create another\n // fake module anyway.\n return Module._resolveFilename(request, makeFakeModule(issuer), false);\n } finally {\n enableNativeHooks = true;\n }\n}\n\n/**\n * This key indicates which version of the standard is implemented by this resolver. The `std` key is the\n * Plug\'n\'Play standard, and any other key are third-party extensions. Third-party extensions are not allowed\n * to override the standard, and can only offer new methods.\n *\n * If an new version of the Plug\'n\'Play standard is released and some extensions conflict with newly added\n * functions, they\'ll just have to fix the conflicts and bump their own version number.\n */\n\nexports.VERSIONS = {std: 1};\n\n/**\n * Useful when used together with getPackageInformation to fetch information about the top-level package.\n */\n\nexports.topLevel = {name: null, reference: null};\n\n/**\n * Gets the package information for a given locator. Returns null if they cannot be retrieved.\n */\n\nexports.getPackageInformation = function getPackageInformation({name, reference}) {\n const packageInformationStore = packageInformationStores.get(name);\n\n if (!packageInformationStore) {\n return null;\n }\n\n const packageInformation = packageInformationStore.get(reference);\n\n if (!packageInformation) {\n return null;\n }\n\n return packageInformation;\n};\n\n/**\n * Transforms a request (what\'s typically passed as argument to the require function) into an unqualified path.\n * This path is called "unqualified" because it only changes the package name to the package location on the disk,\n * which means that the end result still cannot be directly accessed (for example, it doesn\'t try to resolve the\n * file extension, or to resolve directories to their "index.js" content). Use the "resolveUnqualified" function\n * to convert them to fully-qualified paths, or just use "resolveRequest" that do both operations in one go.\n *\n * Note that it is extremely important that the `issuer` path ends with a forward slash if the issuer is to be\n * treated as a folder (ie. "/tmp/foo/" rather than "/tmp/foo" if "foo" is a directory). Otherwise relative\n * imports won\'t be computed correctly (they\'ll get resolved relative to "/tmp/" instead of "/tmp/foo/").\n */\n\nexports.resolveToUnqualified = function resolveToUnqualified(request, issuer, {considerBuiltins = true} = {}) {\n // The \'pnpapi\' request is reserved and will always return the path to the PnP file, from everywhere\n\n if (request === `pnpapi`) {\n return pnpFile;\n }\n\n // Bailout if the request is a native module\n\n if (considerBuiltins && builtinModules.has(request)) {\n return null;\n }\n\n // We allow disabling the pnp resolution for some subpaths. This is because some projects, often legacy,\n // contain multiple levels of dependencies (ie. a yarn.lock inside a subfolder of a yarn.lock). This is\n // typically solved using workspaces, but not all of them have been converted already.\n\n if (ignorePattern && ignorePattern.test(normalizePath(issuer))) {\n const result = callNativeResolution(request, issuer);\n\n if (result === false) {\n throw makeError(\n `BUILTIN_NODE_RESOLUTION_FAIL`,\n `The builtin node resolution algorithm was unable to resolve the module referenced by "${request}" and requested from "${issuer}" (it didn\'t go through the pnp resolver because the issuer was explicitely ignored by the regexp "$$BLACKLIST")`,\n {\n request,\n issuer,\n }\n );\n }\n\n return result;\n }\n\n let unqualifiedPath;\n\n // If the request is a relative or absolute path, we just return it normalized\n\n const dependencyNameMatch = request.match(pathRegExp);\n\n if (!dependencyNameMatch) {\n if (path.isAbsolute(request)) {\n unqualifiedPath = path.normalize(request);\n } else if (issuer.match(isDirRegExp)) {\n unqualifiedPath = path.normalize(path.resolve(issuer, request));\n } else {\n unqualifiedPath = path.normalize(path.resolve(path.dirname(issuer), request));\n }\n }\n\n // Things are more hairy if it\'s a package require - we then need to figure out which package is needed, and in\n // particular the exact version for the given location on the dependency tree\n\n if (dependencyNameMatch) {\n const [, dependencyName, subPath] = dependencyNameMatch;\n\n const issuerLocator = exports.findPackageLocator(issuer);\n\n // If the issuer file doesn\'t seem to be owned by a package managed through pnp, then we resort to using the next\n // resolution algorithm in the chain, usually the native Node resolution one\n\n if (!issuerLocator) {\n const result = callNativeResolution(request, issuer);\n\n if (result === false) {\n throw makeError(\n `BUILTIN_NODE_RESOLUTION_FAIL`,\n `The builtin node resolution algorithm was unable to resolve the module referenced by "${request}" and requested from "${issuer}" (it didn\'t go through the pnp resolver because the issuer doesn\'t seem to be part of the Yarn-managed dependency tree)`,\n {\n request,\n issuer,\n }\n );\n }\n\n return result;\n }\n\n const issuerInformation = getPackageInformationSafe(issuerLocator);\n\n // We obtain the dependency reference in regard to the package that request it\n\n let dependencyReference = issuerInformation.packageDependencies.get(dependencyName);\n\n // If we can\'t find it, we check if we can potentially load it from the packages that have been defined as potential fallbacks.\n // It\'s a bit of a hack, but it improves compatibility with the existing Node ecosystem. Hopefully we should eventually be able\n // to kill this logic and become stricter once pnp gets enough traction and the affected packages fix themselves.\n\n if (issuerLocator !== topLevelLocator) {\n for (let t = 0, T = fallbackLocators.length; dependencyReference === undefined && t < T; ++t) {\n const fallbackInformation = getPackageInformationSafe(fallbackLocators[t]);\n dependencyReference = fallbackInformation.packageDependencies.get(dependencyName);\n }\n }\n\n // If we can\'t find the path, and if the package making the request is the top-level, we can offer nicer error messages\n\n if (!dependencyReference) {\n if (dependencyReference === null) {\n if (issuerLocator === topLevelLocator) {\n throw makeError(\n `MISSING_PEER_DEPENDENCY`,\n `You seem to be requiring a peer dependency ("${dependencyName}"), but it is not installed (which might be because you\'re the top-level package)`,\n {request, issuer, dependencyName}\n );\n } else {\n throw makeError(\n `MISSING_PEER_DEPENDENCY`,\n `Package "${issuerLocator.name}@${issuerLocator.reference}" is trying to access a peer dependency ("${dependencyName}") that should be provided by its direct ancestor but isn\'t`,\n {request, issuer, issuerLocator: Object.assign({}, issuerLocator), dependencyName}\n );\n }\n } else {\n if (issuerLocator === topLevelLocator) {\n throw makeError(\n `UNDECLARED_DEPENDENCY`,\n `You cannot require a package ("${dependencyName}") that is not declared in your dependencies (via "${issuer}")`,\n {request, issuer, dependencyName}\n );\n } else {\n const candidates = Array.from(issuerInformation.packageDependencies.keys());\n throw makeError(\n `UNDECLARED_DEPENDENCY`,\n `Package "${issuerLocator.name}@${issuerLocator.reference}" (via "${issuer}") is trying to require the package "${dependencyName}" (via "${request}") without it being listed in its dependencies (${candidates.join(\n `, `\n )})`,\n {request, issuer, issuerLocator: Object.assign({}, issuerLocator), dependencyName, candidates}\n );\n }\n }\n }\n\n // We need to check that the package exists on the filesystem, because it might not have been installed\n\n const dependencyLocator = {name: dependencyName, reference: dependencyReference};\n const dependencyInformation = exports.getPackageInformation(dependencyLocator);\n const dependencyLocation = path.resolve(__dirname, dependencyInformation.packageLocation);\n\n if (!dependencyLocation) {\n throw makeError(\n `MISSING_DEPENDENCY`,\n `Package "${dependencyLocator.name}@${dependencyLocator.reference}" is a valid dependency, but hasn\'t been installed and thus cannot be required (it might be caused if you install a partial tree, such as on production environments)`,\n {request, issuer, dependencyLocator: Object.assign({}, dependencyLocator)}\n );\n }\n\n // Now that we know which package we should resolve to, we only have to find out the file location\n\n if (subPath) {\n unqualifiedPath = path.resolve(dependencyLocation, subPath);\n } else {\n unqualifiedPath = dependencyLocation;\n }\n }\n\n return path.normalize(unqualifiedPath);\n};\n\n/**\n * Transforms an unqualified path into a qualified path by using the Node resolution algorithm (which automatically\n * appends ".js" / ".json", and transforms directory accesses into "index.js").\n */\n\nexports.resolveUnqualified = function resolveUnqualified(\n unqualifiedPath,\n {extensions = Object.keys(Module._extensions)} = {}\n) {\n const qualifiedPath = applyNodeExtensionResolution(unqualifiedPath, {extensions});\n\n if (qualifiedPath) {\n return path.normalize(qualifiedPath);\n } else {\n throw makeError(\n `QUALIFIED_PATH_RESOLUTION_FAILED`,\n `Couldn\'t find a suitable Node resolution for unqualified path "${unqualifiedPath}"`,\n {unqualifiedPath}\n );\n }\n};\n\n/**\n * Transforms a request into a fully qualified path.\n *\n * Note that it is extremely important that the `issuer` path ends with a forward slash if the issuer is to be\n * treated as a folder (ie. "/tmp/foo/" rather than "/tmp/foo" if "foo" is a directory). Otherwise relative\n * imports won\'t be computed correctly (they\'ll get resolved relative to "/tmp/" instead of "/tmp/foo/").\n */\n\nexports.resolveRequest = function resolveRequest(request, issuer, {considerBuiltins, extensions} = {}) {\n let unqualifiedPath;\n\n try {\n unqualifiedPath = exports.resolveToUnqualified(request, issuer, {considerBuiltins});\n } catch (originalError) {\n // If we get a BUILTIN_NODE_RESOLUTION_FAIL error there, it means that we\'ve had to use the builtin node\n // resolution, which usually shouldn\'t happen. It might be because the user is trying to require something\n // from a path loaded through a symlink (which is not possible, because we need something normalized to\n // figure out which package is making the require call), so we try to make the same request using a fully\n // resolved issuer and throws a better and more actionable error if it works.\n if (originalError.code === `BUILTIN_NODE_RESOLUTION_FAIL`) {\n let realIssuer;\n\n try {\n realIssuer = realpathSync(issuer);\n } catch (error) {}\n\n if (realIssuer) {\n if (issuer.endsWith(`/`)) {\n realIssuer = realIssuer.replace(/\\/?$/, `/`);\n }\n\n try {\n exports.resolveToUnqualified(request, realIssuer, {considerBuiltins});\n } catch (error) {\n // If an error was thrown, the problem doesn\'t seem to come from a path not being normalized, so we\n // can just throw the original error which was legit.\n throw originalError;\n }\n\n // If we reach this stage, it means that resolveToUnqualified didn\'t fail when using the fully resolved\n // file path, which is very likely caused by a module being invoked through Node with a path not being\n // correctly normalized (ie you should use "node $(realpath script.js)" instead of "node script.js").\n throw makeError(\n `SYMLINKED_PATH_DETECTED`,\n `A pnp module ("${request}") has been required from what seems to be a symlinked path ("${issuer}"). This is not possible, you must ensure that your modules are invoked through their fully resolved path on the filesystem (in this case "${realIssuer}").`,\n {\n request,\n issuer,\n realIssuer,\n }\n );\n }\n }\n throw originalError;\n }\n\n if (unqualifiedPath === null) {\n return null;\n }\n\n try {\n return exports.resolveUnqualified(unqualifiedPath, {extensions});\n } catch (resolutionError) {\n if (resolutionError.code === \'QUALIFIED_PATH_RESOLUTION_FAILED\') {\n Object.assign(resolutionError.data, {request, issuer});\n }\n throw resolutionError;\n }\n};\n\n/**\n * Setups the hook into the Node environment.\n *\n * From this point on, any call to `require()` will go through the "resolveRequest" function, and the result will\n * be used as path of the file to load.\n */\n\nexports.setup = function setup() {\n // A small note: we don\'t replace the cache here (and instead use the native one). This is an effort to not\n // break code similar to "delete require.cache[require.resolve(FOO)]", where FOO is a package located outside\n // of the Yarn dependency tree. In this case, we defer the load to the native loader. If we were to replace the\n // cache by our own, the native loader would populate its own cache, which wouldn\'t be exposed anymore, so the\n // delete call would be broken.\n\n const originalModuleLoad = Module._load;\n\n Module._load = function(request, parent, isMain) {\n if (!enableNativeHooks) {\n return originalModuleLoad.call(Module, request, parent, isMain);\n }\n\n // Builtins are managed by the regular Node loader\n\n if (builtinModules.has(request)) {\n try {\n enableNativeHooks = false;\n return originalModuleLoad.call(Module, request, parent, isMain);\n } finally {\n enableNativeHooks = true;\n }\n }\n\n // The \'pnpapi\' name is reserved to return the PnP api currently in use by the program\n\n if (request === `pnpapi`) {\n return pnpModule.exports;\n }\n\n // Request `Module._resolveFilename` (ie. `resolveRequest`) to tell us which file we should load\n\n const modulePath = Module._resolveFilename(request, parent, isMain);\n\n // Check if the module has already been created for the given file\n\n const cacheEntry = Module._cache[modulePath];\n\n if (cacheEntry) {\n return cacheEntry.exports;\n }\n\n // Create a new module and store it into the cache\n\n const module = new Module(modulePath, parent);\n Module._cache[modulePath] = module;\n\n // The main module is exposed as global variable\n\n if (isMain) {\n process.mainModule = module;\n module.id = \'.\';\n }\n\n // Try to load the module, and remove it from the cache if it fails\n\n let hasThrown = true;\n\n try {\n module.load(modulePath);\n hasThrown = false;\n } finally {\n if (hasThrown) {\n delete Module._cache[modulePath];\n }\n }\n\n // Some modules might have to be patched for compatibility purposes\n\n for (const [filter, patchFn] of patchedModules) {\n if (filter.test(request)) {\n module.exports = patchFn(exports.findPackageLocator(parent.filename), module.exports);\n }\n }\n\n return module.exports;\n };\n\n const originalModuleResolveFilename = Module._resolveFilename;\n\n Module._resolveFilename = function(request, parent, isMain, options) {\n if (!enableNativeHooks) {\n return originalModuleResolveFilename.call(Module, request, parent, isMain, options);\n }\n\n let issuers;\n\n if (options) {\n const optionNames = new Set(Object.keys(options));\n optionNames.delete(\'paths\');\n\n if (optionNames.size > 0) {\n throw makeError(\n `UNSUPPORTED`,\n `Some options passed to require() aren\'t supported by PnP yet (${Array.from(optionNames).join(\', \')})`\n );\n }\n\n if (options.paths) {\n issuers = options.paths.map(entry => `${path.normalize(entry)}/`);\n }\n }\n\n if (!issuers) {\n const issuerModule = getIssuerModule(parent);\n const issuer = issuerModule ? issuerModule.filename : `${process.cwd()}/`;\n\n issuers = [issuer];\n }\n\n let firstError;\n\n for (const issuer of issuers) {\n let resolution;\n\n try {\n resolution = exports.resolveRequest(request, issuer);\n } catch (error) {\n firstError = firstError || error;\n continue;\n }\n\n return resolution !== null ? resolution : request;\n }\n\n throw firstError;\n };\n\n const originalFindPath = Module._findPath;\n\n Module._findPath = function(request, paths, isMain) {\n if (!enableNativeHooks) {\n return originalFindPath.call(Module, request, paths, isMain);\n }\n\n for (const path of (paths || [])) {\n let resolution;\n\n try {\n resolution = exports.resolveRequest(request, path);\n } catch (error) {\n continue;\n }\n\n if (resolution) {\n return resolution;\n }\n }\n\n return false;\n };\n\n process.versions.pnp = String(exports.VERSIONS.std);\n};\n\nexports.setupCompatibilityLayer = () => {\n // ESLint currently doesn\'t have any portable way for shared configs to specify their own\n // plugins that should be used (https://github.com/eslint/eslint/issues/10125). This will\n // likely get fixed at some point, but it\'ll take time and in the meantime we\'ll just add\n // additional fallback entries for common shared configs.\n\n for (const name of [`react-scripts`]) {\n const packageInformationStore = packageInformationStores.get(name);\n if (packageInformationStore) {\n for (const reference of packageInformationStore.keys()) {\n fallbackLocators.push({name, reference});\n }\n }\n }\n\n // Modern versions of `resolve` support a specific entry point that custom resolvers can use\n // to inject a specific resolution logic without having to patch the whole package.\n //\n // Cf: https://github.com/browserify/resolve/pull/174\n\n patchedModules.push([\n /^\\.\\/normalize-options\\.js$/,\n (issuer, normalizeOptions) => {\n if (!issuer || issuer.name !== \'resolve\') {\n return normalizeOptions;\n }\n\n return (request, opts) => {\n opts = opts || {};\n\n if (opts.forceNodeResolution) {\n return opts;\n }\n\n opts.preserveSymlinks = true;\n opts.paths = function(request, basedir, getNodeModulesDir, opts) {\n // Extract the name of the package being requested (1=full name, 2=scope name, 3=local name)\n const parts = request.match(/^((?:(@[^\\/]+)\\/)?([^\\/]+))/);\n\n // make sure that basedir ends with a slash\n if (basedir.charAt(basedir.length - 1) !== \'/\') {\n basedir = path.join(basedir, \'/\');\n }\n // This is guaranteed to return the path to the "package.json" file from the given package\n const manifestPath = exports.resolveToUnqualified(`${parts[1]}/package.json`, basedir);\n\n // The first dirname strips the package.json, the second strips the local named folder\n let nodeModules = path.dirname(path.dirname(manifestPath));\n\n // Strips the scope named folder if needed\n if (parts[2]) {\n nodeModules = path.dirname(nodeModules);\n }\n\n return [nodeModules];\n };\n\n return opts;\n };\n },\n ]);\n};\n\nif (module.parent && module.parent.id === \'internal/preload\') {\n exports.setupCompatibilityLayer();\n\n exports.setup();\n}\n\nif (process.mainModule === module) {\n exports.setupCompatibilityLayer();\n\n const reportError = (code, message, data) => {\n process.stdout.write(`${JSON.stringify([{code, message, data}, null])}\\n`);\n };\n\n const reportSuccess = resolution => {\n process.stdout.write(`${JSON.stringify([null, resolution])}\\n`);\n };\n\n const processResolution = (request, issuer) => {\n try {\n reportSuccess(exports.resolveRequest(request, issuer));\n } catch (error) {\n reportError(error.code, error.message, error.data);\n }\n };\n\n const processRequest = data => {\n try {\n const [request, issuer] = JSON.parse(data);\n processResolution(request, issuer);\n } catch (error) {\n reportError(`INVALID_JSON`, error.message, error.data);\n }\n };\n\n if (process.argv.length > 2) {\n if (process.argv.length !== 4) {\n process.stderr.write(`Usage: ${process.argv[0]} ${process.argv[1]} \\n`);\n process.exitCode = 64; /* EX_USAGE */\n } else {\n processResolution(process.argv[2], process.argv[3]);\n }\n } else {\n let buffer = \'\';\n const decoder = new StringDecoder.StringDecoder();\n\n process.stdin.on(\'data\', chunk => {\n buffer += decoder.write(chunk);\n\n do {\n const index = buffer.indexOf(\'\\n\');\n if (index === -1) {\n break;\n }\n\n const line = buffer.slice(0, index);\n buffer = buffer.slice(index + 1);\n\n processRequest(line);\n } while (true);\n });\n }\n}\n'; const crypto = __webpack_require__(11);