aboutsummaryrefslogtreecommitdiff
path: root/node_modules/jest-pnp-resolver
diff options
context:
space:
mode:
authorJoel Kronqvist <joel.h.kronqvist@gmail.com>2022-03-05 19:02:27 +0200
committerJoel Kronqvist <joel.h.kronqvist@gmail.com>2022-03-05 19:02:27 +0200
commit5d309ff52cd399a6b71968a6b9a70c8ac0b98981 (patch)
tree360f7eb50f956e2367ef38fa1fc6ac7ac5258042 /node_modules/jest-pnp-resolver
parentb500a50f1b97d93c98b36ed9a980f8188d648147 (diff)
downloadLYLLRuoka-5d309ff52cd399a6b71968a6b9a70c8ac0b98981.tar.gz
LYLLRuoka-5d309ff52cd399a6b71968a6b9a70c8ac0b98981.zip
Added node_modules for the updating to work properly.
Diffstat (limited to 'node_modules/jest-pnp-resolver')
-rw-r--r--node_modules/jest-pnp-resolver/README.md34
-rw-r--r--node_modules/jest-pnp-resolver/createRequire.js25
-rw-r--r--node_modules/jest-pnp-resolver/getDefaultResolver.js13
-rw-r--r--node_modules/jest-pnp-resolver/index.d.ts10
-rw-r--r--node_modules/jest-pnp-resolver/index.js49
-rw-r--r--node_modules/jest-pnp-resolver/package.json31
6 files changed, 162 insertions, 0 deletions
diff --git a/node_modules/jest-pnp-resolver/README.md b/node_modules/jest-pnp-resolver/README.md
new file mode 100644
index 0000000..20bf42a
--- /dev/null
+++ b/node_modules/jest-pnp-resolver/README.md
@@ -0,0 +1,34 @@
+# <img src="https://github.com/facebook/jest/blob/master/website/static/img/jest.png" height="40" align="right" /> [Plug'n'Play](https://github.com/yarnpkg/rfcs/pull/101) resolver for Jest
+
+[![npm version](https://img.shields.io/npm/v/jest-pnp-resolver.svg)](https://www.npmjs.com/package/jest-pnp-resolver)
+[![node version](https://img.shields.io/node/v/jest-pnp-resolver.svg)](https://www.npmjs.com/package/jest-pnp-resolver)
+
+*This plugin is also available for Rollup ([rollup-plugin-pnp-resolve](https://github.com/arcanis/rollup-plugin-pnp-resolve)), TypeScript ([ts-pnp](https://github.com/arcanis/ts-pnp)), and Webpack ([pnp-webpack-plugin](https://github.com/arcanis/pnp-webpack-plugin))*
+
+## Installation
+
+```
+yarn add -D jest-pnp-resolver
+```
+
+## Usage
+
+As of `jest@^24.4.0` you don't need to manually add this package anymore. The default resolver will already use PnP.
+
+Simply add the resolver to your configuration. For example, a minimal `jest.config.js` would be as such:
+
+```js
+module.exports = {
+ resolver: require.resolve(`jest-pnp-resolver`)
+};
+```
+
+## License (MIT)
+
+> **Copyright © 2016 Maël Nison**
+>
+> 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.
diff --git a/node_modules/jest-pnp-resolver/createRequire.js b/node_modules/jest-pnp-resolver/createRequire.js
new file mode 100644
index 0000000..7da60d6
--- /dev/null
+++ b/node_modules/jest-pnp-resolver/createRequire.js
@@ -0,0 +1,25 @@
+const nativeModule = require(`module`);
+
+module.exports = (filename) => {
+ // Added in Node v12.2.0
+ if (nativeModule.createRequire) {
+ return nativeModule.createRequire(filename);
+ }
+
+ // Added in Node v10.12.0 and deprecated since Node v12.2.0
+ if (nativeModule.createRequireFromPath) {
+ return nativeModule.createRequireFromPath(filename);
+ }
+
+ // Polyfill
+ return _createRequire(filename);
+};
+
+// Polyfill
+function _createRequire (filename) {
+ const mod = new nativeModule.Module(filename, null)
+ mod.filename = filename
+ mod.paths = nativeModule.Module._nodeModulePaths(path.dirname(filename))
+ mod._compile(`module.exports = require;`, filename)
+ return mod.exports
+}
diff --git a/node_modules/jest-pnp-resolver/getDefaultResolver.js b/node_modules/jest-pnp-resolver/getDefaultResolver.js
new file mode 100644
index 0000000..ab90dbc
--- /dev/null
+++ b/node_modules/jest-pnp-resolver/getDefaultResolver.js
@@ -0,0 +1,13 @@
+let defaultResolver;
+
+module.exports = () => {
+ if (!defaultResolver) {
+ try {
+ defaultResolver = require(`jest-resolve/build/defaultResolver`).default;
+ } catch (error) {
+ defaultResolver = require(`jest-resolve/build/default_resolver`).default;
+ }
+ }
+
+ return defaultResolver;
+};
diff --git a/node_modules/jest-pnp-resolver/index.d.ts b/node_modules/jest-pnp-resolver/index.d.ts
new file mode 100644
index 0000000..1acbbac
--- /dev/null
+++ b/node_modules/jest-pnp-resolver/index.d.ts
@@ -0,0 +1,10 @@
+type JestResolverOptions = {
+ basedir: string;
+ defaultResolver: (request: string, opts: any) => string,
+ extensions?: Array<string>,
+};
+
+export default function resolve(
+ request: string,
+ options: JestResolverOptions,
+): string;
diff --git a/node_modules/jest-pnp-resolver/index.js b/node_modules/jest-pnp-resolver/index.js
new file mode 100644
index 0000000..a61a577
--- /dev/null
+++ b/node_modules/jest-pnp-resolver/index.js
@@ -0,0 +1,49 @@
+let globalPnpApi;
+try {
+ globalPnpApi = require(`pnpapi`);
+} catch {
+ // Just ignore if we don't have a global PnP instance - perhaps
+ // we'll eventually find one at runtime due to multi-tree
+}
+
+const createRequire = require(`./createRequire`);
+const getDefaultResolver = require(`./getDefaultResolver`);
+
+module.exports = (request, options) => {
+ const {basedir, defaultResolver, extensions} = options;
+
+ if (process.versions.pnp) {
+ let pnpApi = globalPnpApi;
+
+ // While technically it would be more correct to run this code
+ // everytime (since they file being run *may* belong to a
+ // different dependency tree than the one owning Jest), in
+ // practice this doesn't happen anywhere else than on the Jest
+ // repository itself (in the test env). So in order to preserve
+ // the performances, we can afford a slight incoherence here.
+ if (!pnpApi) {
+ try {
+ const baseReq = createRequire(`${basedir}/internal.js`);
+ pnpApi = baseReq(`pnpapi`);
+ } catch {
+ // The file isn't part of a PnP dependency tree, so we can
+ // just use the default Jest resolver.
+ }
+ }
+
+ if (pnpApi) {
+ const resolution = pnpApi.resolveRequest(request, `${basedir}/`, {extensions});
+
+ // When the request is a native module, Jest expects to get the string back unmodified, but pnp returns null instead.
+ if (resolution === null)
+ return request;
+
+ return resolution;
+ }
+ }
+
+ if (!defaultResolver)
+ defaultResolver = getDefaultResolver();
+
+ return defaultResolver(request, {...options, allowPnp: false});
+};
diff --git a/node_modules/jest-pnp-resolver/package.json b/node_modules/jest-pnp-resolver/package.json
new file mode 100644
index 0000000..d0e9a6f
--- /dev/null
+++ b/node_modules/jest-pnp-resolver/package.json
@@ -0,0 +1,31 @@
+{
+ "name": "jest-pnp-resolver",
+ "version": "1.2.2",
+ "description": "plug'n'play resolver for Webpack",
+ "license": "MIT",
+ "engines": {
+ "node": ">=6"
+ },
+ "homepage": "https://github.com/arcanis/jest-pnp-resolver",
+ "bugs": {
+ "url": "https://github.com/arcanis/jest-pnp-resolver/issues"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/arcanis/jest-pnp-resolver.git"
+ },
+ "keywords": [
+ "jest",
+ "yarn",
+ "plugnplay",
+ "pnp"
+ ],
+ "peerDependencies": {
+ "jest-resolve": "*"
+ },
+ "peerDependenciesMeta": {
+ "jest-resolve": {
+ "optional": true
+ }
+ }
+}