diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json index d85f225c44..83c71696ac 100644 --- a/node_modules/.package-lock.json +++ b/node_modules/.package-lock.json @@ -1000,15 +1000,6 @@ "node": ">= 8" } }, - "node_modules/@nolyfill/is-core-module": { - "version": "1.0.39", - "resolved": "https://registry.npmjs.org/@nolyfill/is-core-module/-/is-core-module-1.0.39.tgz", - "integrity": "sha512-nn5ozdjYQpUCZlWGuxcJY/KpxkWQs4DcbMCmKojjyrYDEAGy4Ce19NN4v5MduafTwJlbKc99UA8YhSVqq9yPZA==", - "dev": true, - "engines": { - "node": ">=12.4.0" - } - }, "node_modules/@octokit/app": { "version": "15.1.4", "resolved": "https://registry.npmjs.org/@octokit/app/-/app-15.1.4.tgz", @@ -2486,6 +2477,19 @@ "dev": true, "license": "ISC" }, + "node_modules/@unrs/rspack-resolver-binding-darwin-arm64": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@unrs/rspack-resolver-binding-darwin-arm64/-/rspack-resolver-binding-darwin-arm64-1.1.2.tgz", + "integrity": "sha512-bQx2L40UF5XxsXwkD26PzuspqUbUswWVbmclmUC+c83Cv/EFrFJ1JaZj5Q5jyYglKGOtyIWY/hXTCdWRN9vT0Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ] + }, "node_modules/abort-controller": { "version": "3.0.0", "license": "MIT", @@ -3628,10 +3632,9 @@ } }, "node_modules/debug": { - "version": "4.3.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", - "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==", - "license": "MIT", + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", + "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", "dependencies": { "ms": "^2.1.3" }, @@ -3808,19 +3811,6 @@ "version": "8.0.0", "license": "MIT" }, - "node_modules/enhanced-resolve": { - "version": "5.17.1", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.17.1.tgz", - "integrity": "sha512-LMHl3dXhTcfv8gM4kEzIUeTQ+7fpdA0l2tUf34BddXPkz2A5xJ5L/Pchd5BL6rdccM9QGvu0sWZzK1Z1t4wwyg==", - "dev": true, - "dependencies": { - "graceful-fs": "^4.2.4", - "tapable": "^2.2.0" - }, - "engines": { - "node": ">=10.13.0" - } - }, "node_modules/es-abstract": { "version": "1.23.3", "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.23.3.tgz", @@ -4056,22 +4046,20 @@ } }, "node_modules/eslint-import-resolver-typescript": { - "version": "3.8.3", - "resolved": "https://registry.npmjs.org/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-3.8.3.tgz", - "integrity": "sha512-A0bu4Ks2QqDWNpeEgTQMPTngaMhuDu4yv6xpftBMAf+1ziXnpx+eSR1WRfoPTe2BAiAjHFZ7kSNx1fvr5g5pmQ==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-4.1.1.tgz", + "integrity": "sha512-91As8PwH6xjPwndAbvhTuZ3DUfdl4HttocWRyaLOd5T4uUo6km8EDO7Sve4jzH50V1wbgql2nOFbE3GGfARJag==", "dev": true, - "license": "ISC", "dependencies": { - "@nolyfill/is-core-module": "1.0.39", - "debug": "^4.3.7", - "enhanced-resolve": "^5.15.0", + "debug": "^4.4.0", "get-tsconfig": "^4.10.0", - "is-bun-module": "^1.0.2", - "stable-hash": "^0.0.4", + "is-bun-module": "^1.3.0", + "rspack-resolver": "^1.1.2", + "stable-hash": "^0.0.5", "tinyglobby": "^0.2.12" }, "engines": { - "node": "^14.18.0 || >=16.0.0" + "node": "^16.17.0 || >=18.6.0" }, "funding": { "url": "https://opencollective.com/unts/projects/eslint-import-resolver-ts" @@ -5498,9 +5486,9 @@ } }, "node_modules/is-bun-module": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-bun-module/-/is-bun-module-1.1.0.tgz", - "integrity": "sha512-4mTAVPlrXpaN3jtF0lsnPCMGnq4+qZjVIKq0HCpfcqf8OC1SM5oATCIAPM5V5FN05qp2NNnFndphmdZS9CV3hA==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/is-bun-module/-/is-bun-module-1.3.0.tgz", + "integrity": "sha512-DgXeu5UWI0IsMQundYb5UAOzm6G2eVnarJ0byP6Tm55iZNKceD59LNPA2L4VvsScTtHcw0yEkVwSf7PC+QoLSA==", "dev": true, "dependencies": { "semver": "^7.6.3" @@ -7080,6 +7068,28 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/rspack-resolver": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/rspack-resolver/-/rspack-resolver-1.1.2.tgz", + "integrity": "sha512-eHhz+9JWHFdbl/CVVqEP6kviLFZqw1s0MWxLdsGMtUKUspSO3SERptPohmrUIC9jT1bGV9Bd3+r8AmWbdfNAzQ==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/JounQin" + }, + "optionalDependencies": { + "@unrs/rspack-resolver-binding-darwin-arm64": "1.1.2", + "@unrs/rspack-resolver-binding-darwin-x64": "1.1.2", + "@unrs/rspack-resolver-binding-freebsd-x64": "1.1.2", + "@unrs/rspack-resolver-binding-linux-arm-gnueabihf": "1.1.2", + "@unrs/rspack-resolver-binding-linux-arm64-gnu": "1.1.2", + "@unrs/rspack-resolver-binding-linux-arm64-musl": "1.1.2", + "@unrs/rspack-resolver-binding-linux-x64-gnu": "1.1.2", + "@unrs/rspack-resolver-binding-linux-x64-musl": "1.1.2", + "@unrs/rspack-resolver-binding-wasm32-wasi": "1.1.2", + "@unrs/rspack-resolver-binding-win32-arm64-msvc": "1.1.2", + "@unrs/rspack-resolver-binding-win32-x64-msvc": "1.1.2" + } + }, "node_modules/run-parallel": { "version": "1.2.0", "funding": [ @@ -7340,11 +7350,10 @@ "license": "BSD-3-Clause" }, "node_modules/stable-hash": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/stable-hash/-/stable-hash-0.0.4.tgz", - "integrity": "sha512-LjdcbuBeLcdETCrPn9i8AYAZ1eCtu4ECAWtP7UleOiZ9LzVxRzzUZEoZ8zB24nhkQnDWyET0I+3sWokSDS3E7g==", - "dev": true, - "license": "MIT" + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/stable-hash/-/stable-hash-0.0.5.tgz", + "integrity": "sha512-+L3ccpzibovGXFK+Ap/f8LOS0ahMrHTf3xu7mMLSpEGU0EO9ucaysSylKo9eRDFNhWve/y275iPmIZ4z39a9iA==", + "dev": true }, "node_modules/stack-utils": { "version": "2.0.6", @@ -7648,15 +7657,6 @@ "dev": true, "license": "0BSD" }, - "node_modules/tapable": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", - "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==", - "dev": true, - "engines": { - "node": ">=6" - } - }, "node_modules/tar-stream": { "version": "3.1.7", "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-3.1.7.tgz", diff --git a/node_modules/@nolyfill/is-core-module/LICENSE b/node_modules/@nolyfill/is-core-module/LICENSE deleted file mode 100644 index f7be747d78..0000000000 --- a/node_modules/@nolyfill/is-core-module/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2023 Sukka - -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/@nolyfill/is-core-module/index.d.ts b/node_modules/@nolyfill/is-core-module/index.d.ts deleted file mode 100644 index 8c0bd0dd49..0000000000 --- a/node_modules/@nolyfill/is-core-module/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -declare const isCore: (x: string, _nodeVersion?: any) => boolean; - -export = isCore; diff --git a/node_modules/@nolyfill/is-core-module/index.js b/node_modules/@nolyfill/is-core-module/index.js deleted file mode 100644 index 24cbbc5375..0000000000 --- a/node_modules/@nolyfill/is-core-module/index.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";const e=require("module"),s=new Set(["assert/strict","node:assert/strict","diagnostics_channel","node:diagnostics_channel","dns/promises","node:dns/promises","fs/promises","node:fs/promises","inspector/promises","node:inspector/promises","path/posix","node:path/posix","path/win32","node:path/win32","readline/promises","node:readline/promises","node:sea","stream/consumers","node:stream/consumers","stream/promises","node:stream/promises","stream/web","node:stream/web","node:test/reporters","test/mock_loader","node:test/mock_loader","node:test","timers/promises","node:timers/promises","util/types","node:util/types","wasi","node:wasi"].concat(e.builtinModules,e.builtinModules.map(e=>"node:"+e)));module.exports=(e,o)=>s.has(e); \ No newline at end of file diff --git a/node_modules/@nolyfill/is-core-module/package.json b/node_modules/@nolyfill/is-core-module/package.json deleted file mode 100644 index 20f492c6ab..0000000000 --- a/node_modules/@nolyfill/is-core-module/package.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "@nolyfill/is-core-module", - "version": "1.0.39", - "repository": { - "type": "git", - "url": "https://github.com/SukkaW/nolyfill", - "directory": "packages/manual/is-core-module" - }, - "main": "./index.js", - "types": "./index.d.ts", - "files": [ - "**/*.js", - "*.d.ts", - "*.js" - ], - "exports": { - ".": "./index.js", - "./index.js": "./index.js", - "./package.json": "./package.json" - }, - "license": "MIT", - "devDependencies": { - "@rollup/plugin-commonjs": "^26.0.1", - "@rollup/plugin-node-resolve": "^15.2.3", - "@rollup/plugin-replace": "^5.0.7", - "ljharb-is-core-module": "npm:is-core-module@^2.15.0", - "resolve-pkg": "^2.0.0" - }, - "engines": { - "node": ">=12.4.0" - }, - "scripts": { - "build": "rollup -c rollup.config.ts --configPlugin swc3" - } -} \ No newline at end of file diff --git a/node_modules/@unrs/rspack-resolver-binding-darwin-arm64/README.md b/node_modules/@unrs/rspack-resolver-binding-darwin-arm64/README.md new file mode 100644 index 0000000000..897d586fcf --- /dev/null +++ b/node_modules/@unrs/rspack-resolver-binding-darwin-arm64/README.md @@ -0,0 +1,3 @@ +# `@unrs/rspack-resolver-binding-darwin-arm64` + +This is the **aarch64-apple-darwin** binary for `@unrs/rspack-resolver-binding` diff --git a/node_modules/@unrs/rspack-resolver-binding-darwin-arm64/package.json b/node_modules/@unrs/rspack-resolver-binding-darwin-arm64/package.json new file mode 100644 index 0000000000..a714734edd --- /dev/null +++ b/node_modules/@unrs/rspack-resolver-binding-darwin-arm64/package.json @@ -0,0 +1,25 @@ +{ + "name": "@unrs/rspack-resolver-binding-darwin-arm64", + "version": "1.1.2", + "cpu": [ + "arm64" + ], + "main": "resolver.darwin-arm64.node", + "files": [ + "resolver.darwin-arm64.node" + ], + "description": "Oxc Resolver Node API with PNP support", + "homepage": "https://github.com/unrs/rspack-resolver", + "license": "MIT", + "publishConfig": { + "registry": "https://registry.npmjs.org/", + "access": "public" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/unrs/rspack-resolver.git" + }, + "os": [ + "darwin" + ] +} \ No newline at end of file diff --git a/node_modules/@unrs/rspack-resolver-binding-darwin-arm64/resolver.darwin-arm64.node b/node_modules/@unrs/rspack-resolver-binding-darwin-arm64/resolver.darwin-arm64.node new file mode 100644 index 0000000000..99313a3f94 Binary files /dev/null and b/node_modules/@unrs/rspack-resolver-binding-darwin-arm64/resolver.darwin-arm64.node differ diff --git a/node_modules/debug/package.json b/node_modules/debug/package.json index 2f782eb9ae..60dfcf57ca 100644 --- a/node_modules/debug/package.json +++ b/node_modules/debug/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "4.3.7", + "version": "4.4.0", "repository": { "type": "git", "url": "git://github.com/debug-js/debug.git" @@ -56,5 +56,10 @@ "browser": "./src/browser.js", "engines": { "node": ">=6.0" + }, + "xo": { + "rules": { + "import/extensions": "off" + } } } diff --git a/node_modules/debug/src/browser.js b/node_modules/debug/src/browser.js index 8d808e5889..df8e179e8b 100644 --- a/node_modules/debug/src/browser.js +++ b/node_modules/debug/src/browser.js @@ -129,6 +129,7 @@ function useColors() { // Is webkit? http://stackoverflow.com/a/16459606/376773 // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 + // eslint-disable-next-line no-return-assign return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || // Is firebug? http://stackoverflow.com/a/398120/376773 (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || diff --git a/node_modules/debug/src/common.js b/node_modules/debug/src/common.js index e3291b20fa..528c7ecf41 100644 --- a/node_modules/debug/src/common.js +++ b/node_modules/debug/src/common.js @@ -166,24 +166,62 @@ function setup(env) { createDebug.names = []; createDebug.skips = []; - let i; - const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); - const len = split.length; - - for (i = 0; i < len; i++) { - if (!split[i]) { - // ignore empty strings - continue; + const split = (typeof namespaces === 'string' ? namespaces : '') + .trim() + .replace(' ', ',') + .split(',') + .filter(Boolean); + + for (const ns of split) { + if (ns[0] === '-') { + createDebug.skips.push(ns.slice(1)); + } else { + createDebug.names.push(ns); } + } + } - namespaces = split[i].replace(/\*/g, '.*?'); - - if (namespaces[0] === '-') { - createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$')); + /** + * Checks if the given string matches a namespace template, honoring + * asterisks as wildcards. + * + * @param {String} search + * @param {String} template + * @return {Boolean} + */ + function matchesTemplate(search, template) { + let searchIndex = 0; + let templateIndex = 0; + let starIndex = -1; + let matchIndex = 0; + + while (searchIndex < search.length) { + if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === '*')) { + // Match character or proceed with wildcard + if (template[templateIndex] === '*') { + starIndex = templateIndex; + matchIndex = searchIndex; + templateIndex++; // Skip the '*' + } else { + searchIndex++; + templateIndex++; + } + } else if (starIndex !== -1) { // eslint-disable-line no-negated-condition + // Backtrack to the last '*' and try to match more characters + templateIndex = starIndex + 1; + matchIndex++; + searchIndex = matchIndex; } else { - createDebug.names.push(new RegExp('^' + namespaces + '$')); + return false; // No match } } + + // Handle trailing '*' in template + while (templateIndex < template.length && template[templateIndex] === '*') { + templateIndex++; + } + + return templateIndex === template.length; } /** @@ -194,8 +232,8 @@ function setup(env) { */ function disable() { const namespaces = [ - ...createDebug.names.map(toNamespace), - ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace) + ...createDebug.names, + ...createDebug.skips.map(namespace => '-' + namespace) ].join(','); createDebug.enable(''); return namespaces; @@ -209,21 +247,14 @@ function setup(env) { * @api public */ function enabled(name) { - if (name[name.length - 1] === '*') { - return true; - } - - let i; - let len; - - for (i = 0, len = createDebug.skips.length; i < len; i++) { - if (createDebug.skips[i].test(name)) { + for (const skip of createDebug.skips) { + if (matchesTemplate(name, skip)) { return false; } } - for (i = 0, len = createDebug.names.length; i < len; i++) { - if (createDebug.names[i].test(name)) { + for (const ns of createDebug.names) { + if (matchesTemplate(name, ns)) { return true; } } @@ -231,19 +262,6 @@ function setup(env) { return false; } - /** - * Convert regexp to namespace - * - * @param {RegExp} regxep - * @return {String} namespace - * @api private - */ - function toNamespace(regexp) { - return regexp.toString() - .substring(2, regexp.toString().length - 2) - .replace(/\.\*\?$/, '*'); - } - /** * Coerce `val`. * diff --git a/node_modules/enhanced-resolve/LICENSE b/node_modules/enhanced-resolve/LICENSE deleted file mode 100644 index 8c11fc7289..0000000000 --- a/node_modules/enhanced-resolve/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright JS Foundation and other contributors - -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/enhanced-resolve/README.md b/node_modules/enhanced-resolve/README.md deleted file mode 100644 index 887590ecc9..0000000000 --- a/node_modules/enhanced-resolve/README.md +++ /dev/null @@ -1,183 +0,0 @@ -# enhanced-resolve - -[![npm][npm]][npm-url] -[![Build Status][build-status]][build-status-url] -[![codecov][codecov-badge]][codecov-url] -[![Install Size][size]][size-url] -[![GitHub Discussions][discussion]][discussion-url] - -Offers an async require.resolve function. It's highly configurable. - -## Features - -- plugin system -- provide a custom filesystem -- sync and async node.js filesystems included - -## Getting Started - -### Install - -```sh -# npm -npm install enhanced-resolve -# or Yarn -yarn add enhanced-resolve -``` - -### Resolve - -There is a Node.js API which allows to resolve requests according to the Node.js resolving rules. -Sync and async APIs are offered. A `create` method allows to create a custom resolve function. - -```js -const resolve = require("enhanced-resolve"); - -resolve("/some/path/to/folder", "module/dir", (err, result) => { - result; // === "/some/path/node_modules/module/dir/index.js" -}); - -resolve.sync("/some/path/to/folder", "../../dir"); -// === "/some/path/dir/index.js" - -const myResolve = resolve.create({ - // or resolve.create.sync - extensions: [".ts", ".js"] - // see more options below -}); - -myResolve("/some/path/to/folder", "ts-module", (err, result) => { - result; // === "/some/node_modules/ts-module/index.ts" -}); -``` - -### Creating a Resolver - -The easiest way to create a resolver is to use the `createResolver` function on `ResolveFactory`, along with one of the supplied File System implementations. - -```js -const fs = require("fs"); -const { CachedInputFileSystem, ResolverFactory } = require("enhanced-resolve"); - -// create a resolver -const myResolver = ResolverFactory.createResolver({ - // Typical usage will consume the `fs` + `CachedInputFileSystem`, which wraps Node.js `fs` to add caching. - fileSystem: new CachedInputFileSystem(fs, 4000), - extensions: [".js", ".json"] - /* any other resolver options here. Options/defaults can be seen below */ -}); - -// resolve a file with the new resolver -const context = {}; -const lookupStartPath = "/Users/webpack/some/root/dir"; -const request = "./path/to-look-up.js"; -const resolveContext = {}; -myResolver.resolve(context, lookupStartPath, request, resolveContext, ( - err /*Error*/, - filepath /*string*/ -) => { - // Do something with the path -}); -``` - -#### Resolver Options - -| Field | Default | Description | -|------------------|-----------------------------| --------------------------------------------------------------------------------------------------------------------------------------------------------- | -| alias | [] | A list of module alias configurations or an object which maps key to value | -| aliasFields | [] | A list of alias fields in description files | -| extensionAlias | {} | An object which maps extension to extension aliases | -| cachePredicate | function() { return true }; | A function which decides whether a request should be cached or not. An object is passed to the function with `path` and `request` properties. | -| cacheWithContext | true | If unsafe cache is enabled, includes `request.context` in the cache key | -| conditionNames | [] | A list of exports field condition names | -| descriptionFiles | ["package.json"] | A list of description files to read from | -| enforceExtension | false | Enforce that a extension from extensions must be used | -| exportsFields | ["exports"] | A list of exports fields in description files | -| extensions | [".js", ".json", ".node"] | A list of extensions which should be tried for files | -| fallback | [] | Same as `alias`, but only used if default resolving fails | -| fileSystem | | The file system which should be used | -| fullySpecified | false | Request passed to resolve is already fully specified and extensions or main files are not resolved for it (they are still resolved for internal requests) | -| mainFields | ["main"] | A list of main fields in description files | -| mainFiles | ["index"] | A list of main files in directories | -| modules | ["node_modules"] | A list of directories to resolve modules from, can be absolute path or folder name | -| plugins | [] | A list of additional resolve plugins which should be applied | -| resolver | undefined | A prepared Resolver to which the plugins are attached | -| resolveToContext | false | Resolve to a context instead of a file | -| preferRelative | false | Prefer to resolve module requests as relative request and fallback to resolving as module | -| preferAbsolute | false | Prefer to resolve server-relative urls as absolute paths before falling back to resolve in roots | -| restrictions | [] | A list of resolve restrictions | -| roots | [] | A list of root paths | -| symlinks | true | Whether to resolve symlinks to their symlinked location | -| unsafeCache | false | Use this cache object to unsafely cache the successful requests | - -## Plugins - -Similar to `webpack`, the core of `enhanced-resolve` functionality is implemented as individual plugins that are executed using [`tapable`](https://github.com/webpack/tapable). -These plugins can extend the functionality of the library, adding other ways for files/contexts to be resolved. - -A plugin should be a `class` (or its ES5 equivalent) with an `apply` method. The `apply` method will receive a `resolver` instance, that can be used to hook in to the event system. - -### Plugin Boilerplate - -```js -class MyResolverPlugin { - constructor(source, target) { - this.source = source; - this.target = target; - } - - apply(resolver) { - const target = resolver.ensureHook(this.target); - resolver - .getHook(this.source) - .tapAsync("MyResolverPlugin", (request, resolveContext, callback) => { - // Any logic you need to create a new `request` can go here - resolver.doResolve(target, request, null, resolveContext, callback); - }); - } -} -``` - -Plugins are executed in a pipeline, and register which event they should be executed before/after. In the example above, `source` is the name of the event that starts the pipeline, and `target` is what event this plugin should fire, which is what continues the execution of the pipeline. For an example of how these different plugin events create a chain, see `lib/ResolverFactory.js`, in the `//// pipeline ////` section. - -## Escaping - -It's allowed to escape `#` as `\0#` to avoid parsing it as fragment. - -enhanced-resolve will try to resolve requests containing `#` as path and as fragment, so it will automatically figure out if `./some#thing` means `.../some.js#thing` or `.../some#thing.js`. When a `#` is resolved as path it will be escaped in the result. Here: `.../some\0#thing.js`. - -## Tests - -```javascript -yarn test -``` - -## Passing options from webpack - -If you are using `webpack`, and you want to pass custom options to `enhanced-resolve`, the options are passed from the `resolve` key of your webpack configuration e.g.: - -``` -resolve: { - extensions: ['.js', '.jsx'], - modules: [path.resolve(__dirname, 'src'), 'node_modules'], - plugins: [new DirectoryNamedWebpackPlugin()] - ... -}, -``` - -## License - -Copyright (c) 2012-2019 JS Foundation and other contributors - -MIT (http://www.opensource.org/licenses/mit-license.php) - -[npm]: https://img.shields.io/npm/v/enhanced-resolve.svg -[npm-url]: https://www.npmjs.com/package/enhanced-resolve -[build-status]: https://github.com/webpack/enhanced-resolve/actions/workflows/test.yml/badge.svg?branch=master -[build-status-url]: https://github.com/webpack/enhanced-resolve/actions -[codecov-badge]: https://codecov.io/gh/webpack/enhanced-resolve/branch/main/graph/badge.svg?token=6B6NxtsZc3 -[codecov-url]: https://codecov.io/gh/webpack/enhanced-resolve -[size]: https://packagephobia.com/badge?p=enhanced-resolve -[size-url]: https://packagephobia.com/result?p=enhanced-resolve -[discussion]: https://img.shields.io/github/discussions/webpack/webpack -[discussion-url]: https://github.com/webpack/webpack/discussions diff --git a/node_modules/enhanced-resolve/lib/AliasFieldPlugin.js b/node_modules/enhanced-resolve/lib/AliasFieldPlugin.js deleted file mode 100644 index 765c835372..0000000000 --- a/node_modules/enhanced-resolve/lib/AliasFieldPlugin.js +++ /dev/null @@ -1,108 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -const DescriptionFileUtils = require("./DescriptionFileUtils"); -const getInnerRequest = require("./getInnerRequest"); - -/** @typedef {import("./Resolver")} Resolver */ -/** @typedef {import("./Resolver").JsonPrimitive} JsonPrimitive */ -/** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */ -/** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */ - -module.exports = class AliasFieldPlugin { - /** - * @param {string | ResolveStepHook} source source - * @param {string | Array} field field - * @param {string | ResolveStepHook} target target - */ - constructor(source, field, target) { - this.source = source; - this.field = field; - this.target = target; - } - - /** - * @param {Resolver} resolver the resolver - * @returns {void} - */ - apply(resolver) { - const target = resolver.ensureHook(this.target); - resolver - .getHook(this.source) - .tapAsync("AliasFieldPlugin", (request, resolveContext, callback) => { - if (!request.descriptionFileData) return callback(); - const innerRequest = getInnerRequest(resolver, request); - if (!innerRequest) return callback(); - const fieldData = DescriptionFileUtils.getField( - request.descriptionFileData, - this.field - ); - if (fieldData === null || typeof fieldData !== "object") { - if (resolveContext.log) - resolveContext.log( - "Field '" + - this.field + - "' doesn't contain a valid alias configuration" - ); - return callback(); - } - /** @type {JsonPrimitive | undefined} */ - const data = Object.prototype.hasOwnProperty.call( - fieldData, - innerRequest - ) - ? /** @type {{[Key in string]: JsonPrimitive}} */ (fieldData)[ - innerRequest - ] - : innerRequest.startsWith("./") - ? /** @type {{[Key in string]: JsonPrimitive}} */ (fieldData)[ - innerRequest.slice(2) - ] - : undefined; - if (data === innerRequest) return callback(); - if (data === undefined) return callback(); - if (data === false) { - /** @type {ResolveRequest} */ - const ignoreObj = { - ...request, - path: false - }; - if (typeof resolveContext.yield === "function") { - resolveContext.yield(ignoreObj); - return callback(null, null); - } - return callback(null, ignoreObj); - } - /** @type {ResolveRequest} */ - const obj = { - ...request, - path: /** @type {string} */ (request.descriptionFileRoot), - request: /** @type {string} */ (data), - fullySpecified: false - }; - resolver.doResolve( - target, - obj, - "aliased from description file " + - request.descriptionFilePath + - " with mapping '" + - innerRequest + - "' to '" + - /** @type {string} */ (data) + - "'", - resolveContext, - (err, result) => { - if (err) return callback(err); - - // Don't allow other aliasing or raw request - if (result === undefined) return callback(null, null); - callback(null, result); - } - ); - }); - } -}; diff --git a/node_modules/enhanced-resolve/lib/AliasPlugin.js b/node_modules/enhanced-resolve/lib/AliasPlugin.js deleted file mode 100644 index bbe9724a08..0000000000 --- a/node_modules/enhanced-resolve/lib/AliasPlugin.js +++ /dev/null @@ -1,154 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -const forEachBail = require("./forEachBail"); -const { PathType, getType } = require("./util/path"); - -/** @typedef {import("./Resolver")} Resolver */ -/** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */ -/** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */ -/** @typedef {string | Array | false} Alias */ -/** @typedef {{alias: Alias, name: string, onlyModule?: boolean}} AliasOption */ - -module.exports = class AliasPlugin { - /** - * @param {string | ResolveStepHook} source source - * @param {AliasOption | Array} options options - * @param {string | ResolveStepHook} target target - */ - constructor(source, options, target) { - this.source = source; - this.options = Array.isArray(options) ? options : [options]; - this.target = target; - } - - /** - * @param {Resolver} resolver the resolver - * @returns {void} - */ - apply(resolver) { - const target = resolver.ensureHook(this.target); - /** - * @param {string} maybeAbsolutePath path - * @returns {null|string} absolute path with slash ending - */ - const getAbsolutePathWithSlashEnding = maybeAbsolutePath => { - const type = getType(maybeAbsolutePath); - if (type === PathType.AbsolutePosix || type === PathType.AbsoluteWin) { - return resolver.join(maybeAbsolutePath, "_").slice(0, -1); - } - return null; - }; - /** - * @param {string} path path - * @param {string} maybeSubPath sub path - * @returns {boolean} true, if path is sub path - */ - const isSubPath = (path, maybeSubPath) => { - const absolutePath = getAbsolutePathWithSlashEnding(maybeSubPath); - if (!absolutePath) return false; - return path.startsWith(absolutePath); - }; - resolver - .getHook(this.source) - .tapAsync("AliasPlugin", (request, resolveContext, callback) => { - const innerRequest = request.request || request.path; - if (!innerRequest) return callback(); - forEachBail( - this.options, - (item, callback) => { - /** @type {boolean} */ - let shouldStop = false; - if ( - innerRequest === item.name || - (!item.onlyModule && - (request.request - ? innerRequest.startsWith(`${item.name}/`) - : isSubPath(innerRequest, item.name))) - ) { - /** @type {string} */ - const remainingRequest = innerRequest.slice(item.name.length); - /** - * @param {Alias} alias alias - * @param {(err?: null|Error, result?: null|ResolveRequest) => void} callback callback - * @returns {void} - */ - const resolveWithAlias = (alias, callback) => { - if (alias === false) { - /** @type {ResolveRequest} */ - const ignoreObj = { - ...request, - path: false - }; - if (typeof resolveContext.yield === "function") { - resolveContext.yield(ignoreObj); - return callback(null, null); - } - return callback(null, ignoreObj); - } - if ( - innerRequest !== alias && - !innerRequest.startsWith(alias + "/") - ) { - shouldStop = true; - const newRequestStr = alias + remainingRequest; - /** @type {ResolveRequest} */ - const obj = { - ...request, - request: newRequestStr, - fullySpecified: false - }; - return resolver.doResolve( - target, - obj, - "aliased with mapping '" + - item.name + - "': '" + - alias + - "' to '" + - newRequestStr + - "'", - resolveContext, - (err, result) => { - if (err) return callback(err); - if (result) return callback(null, result); - return callback(); - } - ); - } - return callback(); - }; - /** - * @param {null|Error} [err] error - * @param {null|ResolveRequest} [result] result - * @returns {void} - */ - const stoppingCallback = (err, result) => { - if (err) return callback(err); - - if (result) return callback(null, result); - // Don't allow other aliasing or raw request - if (shouldStop) return callback(null, null); - return callback(); - }; - if (Array.isArray(item.alias)) { - return forEachBail( - item.alias, - resolveWithAlias, - stoppingCallback - ); - } else { - return resolveWithAlias(item.alias, stoppingCallback); - } - } - return callback(); - }, - callback - ); - }); - } -}; diff --git a/node_modules/enhanced-resolve/lib/AppendPlugin.js b/node_modules/enhanced-resolve/lib/AppendPlugin.js deleted file mode 100644 index 45ad052bdb..0000000000 --- a/node_modules/enhanced-resolve/lib/AppendPlugin.js +++ /dev/null @@ -1,49 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -/** @typedef {import("./Resolver")} Resolver */ -/** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */ -/** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */ - -module.exports = class AppendPlugin { - /** - * @param {string | ResolveStepHook} source source - * @param {string} appending appending - * @param {string | ResolveStepHook} target target - */ - constructor(source, appending, target) { - this.source = source; - this.appending = appending; - this.target = target; - } - - /** - * @param {Resolver} resolver the resolver - * @returns {void} - */ - apply(resolver) { - const target = resolver.ensureHook(this.target); - resolver - .getHook(this.source) - .tapAsync("AppendPlugin", (request, resolveContext, callback) => { - /** @type {ResolveRequest} */ - const obj = { - ...request, - path: request.path + this.appending, - relativePath: - request.relativePath && request.relativePath + this.appending - }; - resolver.doResolve( - target, - obj, - this.appending, - resolveContext, - callback - ); - }); - } -}; diff --git a/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js b/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js deleted file mode 100644 index cddf00e5ab..0000000000 --- a/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js +++ /dev/null @@ -1,664 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -const nextTick = require("process").nextTick; - -/** @typedef {import("./Resolver").FileSystem} FileSystem */ -/** @typedef {import("./Resolver").PathLike} PathLike */ -/** @typedef {import("./Resolver").PathOrFileDescriptor} PathOrFileDescriptor */ -/** @typedef {import("./Resolver").SyncFileSystem} SyncFileSystem */ -/** @typedef {FileSystem & SyncFileSystem} BaseFileSystem */ - -/** - * @template T - * @typedef {import("./Resolver").FileSystemCallback} FileSystemCallback - */ - -/** - * @param {string} path path - * @returns {string} dirname - */ -const dirname = path => { - let idx = path.length - 1; - while (idx >= 0) { - const c = path.charCodeAt(idx); - // slash or backslash - if (c === 47 || c === 92) break; - idx--; - } - if (idx < 0) return ""; - return path.slice(0, idx); -}; - -/** - * @template T - * @param {FileSystemCallback[]} callbacks callbacks - * @param {Error | null} err error - * @param {T} result result - */ -const runCallbacks = (callbacks, err, result) => { - if (callbacks.length === 1) { - callbacks[0](err, result); - callbacks.length = 0; - return; - } - let error; - for (const callback of callbacks) { - try { - callback(err, result); - } catch (e) { - if (!error) error = e; - } - } - callbacks.length = 0; - if (error) throw error; -}; - -class OperationMergerBackend { - /** - * @param {Function | undefined} provider async method in filesystem - * @param {Function | undefined} syncProvider sync method in filesystem - * @param {BaseFileSystem} providerContext call context for the provider methods - */ - constructor(provider, syncProvider, providerContext) { - this._provider = provider; - this._syncProvider = syncProvider; - this._providerContext = providerContext; - this._activeAsyncOperations = new Map(); - - this.provide = this._provider - ? /** - * @param {PathLike | PathOrFileDescriptor} path path - * @param {object | FileSystemCallback | undefined} options options - * @param {FileSystemCallback=} callback callback - * @returns {any} result - */ - (path, options, callback) => { - if (typeof options === "function") { - callback = /** @type {FileSystemCallback} */ (options); - options = undefined; - } - if ( - typeof path !== "string" && - !Buffer.isBuffer(path) && - !(path instanceof URL) && - typeof path !== "number" - ) { - /** @type {Function} */ - (callback)( - new TypeError("path must be a string, Buffer, URL or number") - ); - return; - } - if (options) { - return /** @type {Function} */ (this._provider).call( - this._providerContext, - path, - options, - callback - ); - } - let callbacks = this._activeAsyncOperations.get(path); - if (callbacks) { - callbacks.push(callback); - return; - } - this._activeAsyncOperations.set(path, (callbacks = [callback])); - /** @type {Function} */ - (provider)( - path, - /** - * @param {Error} err error - * @param {any} result result - */ - (err, result) => { - this._activeAsyncOperations.delete(path); - runCallbacks(callbacks, err, result); - } - ); - } - : null; - this.provideSync = this._syncProvider - ? /** - * @param {PathLike | PathOrFileDescriptor} path path - * @param {object=} options options - * @returns {any} result - */ - (path, options) => { - return /** @type {Function} */ (this._syncProvider).call( - this._providerContext, - path, - options - ); - } - : null; - } - - purge() {} - purgeParent() {} -} - -/* - -IDLE: - insert data: goto SYNC - -SYNC: - before provide: run ticks - event loop tick: goto ASYNC_ACTIVE - -ASYNC: - timeout: run tick, goto ASYNC_PASSIVE - -ASYNC_PASSIVE: - before provide: run ticks - -IDLE --[insert data]--> SYNC --[event loop tick]--> ASYNC_ACTIVE --[interval tick]-> ASYNC_PASSIVE - ^ | - +---------[insert data]-------+ -*/ - -const STORAGE_MODE_IDLE = 0; -const STORAGE_MODE_SYNC = 1; -const STORAGE_MODE_ASYNC = 2; - -/** - * @callback Provide - * @param {PathLike | PathOrFileDescriptor} path path - * @param {any} options options - * @param {FileSystemCallback} callback callback - * @returns {void} - */ - -class CacheBackend { - /** - * @param {number} duration max cache duration of items - * @param {function | undefined} provider async method - * @param {function | undefined} syncProvider sync method - * @param {BaseFileSystem} providerContext call context for the provider methods - */ - constructor(duration, provider, syncProvider, providerContext) { - this._duration = duration; - this._provider = provider; - this._syncProvider = syncProvider; - this._providerContext = providerContext; - /** @type {Map[]>} */ - this._activeAsyncOperations = new Map(); - /** @type {Map }>} */ - this._data = new Map(); - /** @type {Set[]} */ - this._levels = []; - for (let i = 0; i < 10; i++) this._levels.push(new Set()); - for (let i = 5000; i < duration; i += 500) this._levels.push(new Set()); - this._currentLevel = 0; - this._tickInterval = Math.floor(duration / this._levels.length); - /** @type {STORAGE_MODE_IDLE | STORAGE_MODE_SYNC | STORAGE_MODE_ASYNC} */ - this._mode = STORAGE_MODE_IDLE; - - /** @type {NodeJS.Timeout | undefined} */ - this._timeout = undefined; - /** @type {number | undefined} */ - this._nextDecay = undefined; - - // @ts-ignore - this.provide = provider ? this.provide.bind(this) : null; - // @ts-ignore - this.provideSync = syncProvider ? this.provideSync.bind(this) : null; - } - - /** - * @param {PathLike | PathOrFileDescriptor} path path - * @param {any} options options - * @param {FileSystemCallback} callback callback - * @returns {void} - */ - provide(path, options, callback) { - if (typeof options === "function") { - callback = options; - options = undefined; - } - if ( - typeof path !== "string" && - !Buffer.isBuffer(path) && - !(path instanceof URL) && - typeof path !== "number" - ) { - callback(new TypeError("path must be a string, Buffer, URL or number")); - return; - } - const strPath = typeof path !== "string" ? path.toString() : path; - if (options) { - return /** @type {Function} */ (this._provider).call( - this._providerContext, - path, - options, - callback - ); - } - - // When in sync mode we can move to async mode - if (this._mode === STORAGE_MODE_SYNC) { - this._enterAsyncMode(); - } - - // Check in cache - let cacheEntry = this._data.get(strPath); - if (cacheEntry !== undefined) { - if (cacheEntry.err) return nextTick(callback, cacheEntry.err); - return nextTick(callback, null, cacheEntry.result); - } - - // Check if there is already the same operation running - let callbacks = this._activeAsyncOperations.get(strPath); - if (callbacks !== undefined) { - callbacks.push(callback); - return; - } - this._activeAsyncOperations.set(strPath, (callbacks = [callback])); - - // Run the operation - /** @type {Function} */ - (this._provider).call( - this._providerContext, - path, - /** - * @param {Error | null} err error - * @param {any} [result] result - */ - (err, result) => { - this._activeAsyncOperations.delete(strPath); - this._storeResult(strPath, err, result); - - // Enter async mode if not yet done - this._enterAsyncMode(); - - runCallbacks( - /** @type {FileSystemCallback[]} */ (callbacks), - err, - result - ); - } - ); - } - - /** - * @param {PathLike | PathOrFileDescriptor} path path - * @param {any} options options - * @returns {any} result - */ - provideSync(path, options) { - if ( - typeof path !== "string" && - !Buffer.isBuffer(path) && - !(path instanceof URL) && - typeof path !== "number" - ) { - throw new TypeError("path must be a string"); - } - const strPath = typeof path !== "string" ? path.toString() : path; - if (options) { - return /** @type {Function} */ (this._syncProvider).call( - this._providerContext, - path, - options - ); - } - - // In sync mode we may have to decay some cache items - if (this._mode === STORAGE_MODE_SYNC) { - this._runDecays(); - } - - // Check in cache - let cacheEntry = this._data.get(strPath); - if (cacheEntry !== undefined) { - if (cacheEntry.err) throw cacheEntry.err; - return cacheEntry.result; - } - - // Get all active async operations - // This sync operation will also complete them - const callbacks = this._activeAsyncOperations.get(strPath); - this._activeAsyncOperations.delete(strPath); - - // Run the operation - // When in idle mode, we will enter sync mode - let result; - try { - result = /** @type {Function} */ (this._syncProvider).call( - this._providerContext, - path - ); - } catch (err) { - this._storeResult(strPath, /** @type {Error} */ (err), undefined); - this._enterSyncModeWhenIdle(); - if (callbacks) { - runCallbacks(callbacks, /** @type {Error} */ (err), undefined); - } - throw err; - } - this._storeResult(strPath, null, result); - this._enterSyncModeWhenIdle(); - if (callbacks) { - runCallbacks(callbacks, null, result); - } - return result; - } - - /** - * @param {string | Buffer | URL | number | (string | URL | Buffer | number)[] | Set} [what] what to purge - */ - purge(what) { - if (!what) { - if (this._mode !== STORAGE_MODE_IDLE) { - this._data.clear(); - for (const level of this._levels) { - level.clear(); - } - this._enterIdleMode(); - } - } else if ( - typeof what === "string" || - Buffer.isBuffer(what) || - what instanceof URL || - typeof what === "number" - ) { - const strWhat = typeof what !== "string" ? what.toString() : what; - for (let [key, data] of this._data) { - if (key.startsWith(strWhat)) { - this._data.delete(key); - data.level.delete(key); - } - } - if (this._data.size === 0) { - this._enterIdleMode(); - } - } else { - for (let [key, data] of this._data) { - for (const item of what) { - const strItem = typeof item !== "string" ? item.toString() : item; - if (key.startsWith(strItem)) { - this._data.delete(key); - data.level.delete(key); - break; - } - } - } - if (this._data.size === 0) { - this._enterIdleMode(); - } - } - } - - /** - * @param {string | Buffer | URL | number | (string | URL | Buffer | number)[] | Set} [what] what to purge - */ - purgeParent(what) { - if (!what) { - this.purge(); - } else if ( - typeof what === "string" || - Buffer.isBuffer(what) || - what instanceof URL || - typeof what === "number" - ) { - const strWhat = typeof what !== "string" ? what.toString() : what; - this.purge(dirname(strWhat)); - } else { - const set = new Set(); - for (const item of what) { - const strItem = typeof item !== "string" ? item.toString() : item; - set.add(dirname(strItem)); - } - this.purge(set); - } - } - - /** - * @param {string} path path - * @param {Error | null} err error - * @param {any} result result - */ - _storeResult(path, err, result) { - if (this._data.has(path)) return; - const level = this._levels[this._currentLevel]; - this._data.set(path, { err, result, level }); - level.add(path); - } - - _decayLevel() { - const nextLevel = (this._currentLevel + 1) % this._levels.length; - const decay = this._levels[nextLevel]; - this._currentLevel = nextLevel; - for (let item of decay) { - this._data.delete(item); - } - decay.clear(); - if (this._data.size === 0) { - this._enterIdleMode(); - } else { - /** @type {number} */ - (this._nextDecay) += this._tickInterval; - } - } - - _runDecays() { - while ( - /** @type {number} */ (this._nextDecay) <= Date.now() && - this._mode !== STORAGE_MODE_IDLE - ) { - this._decayLevel(); - } - } - - _enterAsyncMode() { - let timeout = 0; - switch (this._mode) { - case STORAGE_MODE_ASYNC: - return; - case STORAGE_MODE_IDLE: - this._nextDecay = Date.now() + this._tickInterval; - timeout = this._tickInterval; - break; - case STORAGE_MODE_SYNC: - this._runDecays(); - // _runDecays may change the mode - if ( - /** @type {STORAGE_MODE_IDLE | STORAGE_MODE_SYNC | STORAGE_MODE_ASYNC}*/ - (this._mode) === STORAGE_MODE_IDLE - ) - return; - timeout = Math.max( - 0, - /** @type {number} */ (this._nextDecay) - Date.now() - ); - break; - } - this._mode = STORAGE_MODE_ASYNC; - const ref = setTimeout(() => { - this._mode = STORAGE_MODE_SYNC; - this._runDecays(); - }, timeout); - if (ref.unref) ref.unref(); - this._timeout = ref; - } - - _enterSyncModeWhenIdle() { - if (this._mode === STORAGE_MODE_IDLE) { - this._mode = STORAGE_MODE_SYNC; - this._nextDecay = Date.now() + this._tickInterval; - } - } - - _enterIdleMode() { - this._mode = STORAGE_MODE_IDLE; - this._nextDecay = undefined; - if (this._timeout) clearTimeout(this._timeout); - } -} - -/** - * @template {function} Provider - * @template {function} AsyncProvider - * @template FileSystem - * @param {number} duration duration in ms files are cached - * @param {Provider | undefined} provider provider - * @param {AsyncProvider | undefined} syncProvider sync provider - * @param {BaseFileSystem} providerContext provider context - * @returns {OperationMergerBackend | CacheBackend} backend - */ -const createBackend = (duration, provider, syncProvider, providerContext) => { - if (duration > 0) { - return new CacheBackend(duration, provider, syncProvider, providerContext); - } - return new OperationMergerBackend(provider, syncProvider, providerContext); -}; - -module.exports = class CachedInputFileSystem { - /** - * @param {BaseFileSystem} fileSystem file system - * @param {number} duration duration in ms files are cached - */ - constructor(fileSystem, duration) { - this.fileSystem = fileSystem; - - this._lstatBackend = createBackend( - duration, - this.fileSystem.lstat, - this.fileSystem.lstatSync, - this.fileSystem - ); - const lstat = this._lstatBackend.provide; - this.lstat = /** @type {FileSystem["lstat"]} */ (lstat); - const lstatSync = this._lstatBackend.provideSync; - this.lstatSync = /** @type {SyncFileSystem["lstatSync"]} */ (lstatSync); - - this._statBackend = createBackend( - duration, - this.fileSystem.stat, - this.fileSystem.statSync, - this.fileSystem - ); - const stat = this._statBackend.provide; - this.stat = /** @type {FileSystem["stat"]} */ (stat); - const statSync = this._statBackend.provideSync; - this.statSync = /** @type {SyncFileSystem["statSync"]} */ (statSync); - - this._readdirBackend = createBackend( - duration, - this.fileSystem.readdir, - this.fileSystem.readdirSync, - this.fileSystem - ); - const readdir = this._readdirBackend.provide; - this.readdir = /** @type {FileSystem["readdir"]} */ (readdir); - const readdirSync = this._readdirBackend.provideSync; - this.readdirSync = /** @type {SyncFileSystem["readdirSync"]} */ ( - readdirSync - ); - - this._readFileBackend = createBackend( - duration, - this.fileSystem.readFile, - this.fileSystem.readFileSync, - this.fileSystem - ); - const readFile = this._readFileBackend.provide; - this.readFile = /** @type {FileSystem["readFile"]} */ (readFile); - const readFileSync = this._readFileBackend.provideSync; - this.readFileSync = /** @type {SyncFileSystem["readFileSync"]} */ ( - readFileSync - ); - - this._readJsonBackend = createBackend( - duration, - // prettier-ignore - this.fileSystem.readJson || - (this.readFile && - ( - /** - * @param {string} path path - * @param {FileSystemCallback} callback - */ - (path, callback) => { - this.readFile(path, (err, buffer) => { - if (err) return callback(err); - if (!buffer || buffer.length === 0) - return callback(new Error("No file content")); - let data; - try { - data = JSON.parse(buffer.toString("utf-8")); - } catch (e) { - return callback(/** @type {Error} */ (e)); - } - callback(null, data); - }); - }) - ), - // prettier-ignore - this.fileSystem.readJsonSync || - (this.readFileSync && - ( - /** - * @param {string} path path - * @returns {any} result - */ - (path) => { - const buffer = this.readFileSync(path); - const data = JSON.parse(buffer.toString("utf-8")); - return data; - } - )), - this.fileSystem - ); - const readJson = this._readJsonBackend.provide; - this.readJson = /** @type {FileSystem["readJson"]} */ (readJson); - const readJsonSync = this._readJsonBackend.provideSync; - this.readJsonSync = /** @type {SyncFileSystem["readJsonSync"]} */ ( - readJsonSync - ); - - this._readlinkBackend = createBackend( - duration, - this.fileSystem.readlink, - this.fileSystem.readlinkSync, - this.fileSystem - ); - const readlink = this._readlinkBackend.provide; - this.readlink = /** @type {FileSystem["readlink"]} */ (readlink); - const readlinkSync = this._readlinkBackend.provideSync; - this.readlinkSync = /** @type {SyncFileSystem["readlinkSync"]} */ ( - readlinkSync - ); - - this._realpathBackend = createBackend( - duration, - this.fileSystem.realpath, - this.fileSystem.realpathSync, - this.fileSystem - ); - const realpath = this._realpathBackend.provide; - this.realpath = /** @type {FileSystem["realpath"]} */ (realpath); - const realpathSync = this._realpathBackend.provideSync; - this.realpathSync = /** @type {SyncFileSystem["realpathSync"]} */ ( - realpathSync - ); - } - - /** - * @param {string | Buffer | URL | number | (string | URL | Buffer | number)[] | Set} [what] what to purge - */ - purge(what) { - this._statBackend.purge(what); - this._lstatBackend.purge(what); - this._readdirBackend.purgeParent(what); - this._readFileBackend.purge(what); - this._readlinkBackend.purge(what); - this._readJsonBackend.purge(what); - this._realpathBackend.purge(what); - } -}; diff --git a/node_modules/enhanced-resolve/lib/CloneBasenamePlugin.js b/node_modules/enhanced-resolve/lib/CloneBasenamePlugin.js deleted file mode 100644 index cc193f5861..0000000000 --- a/node_modules/enhanced-resolve/lib/CloneBasenamePlugin.js +++ /dev/null @@ -1,53 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -const basename = require("./getPaths").basename; - -/** @typedef {import("./Resolver")} Resolver */ -/** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */ -/** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */ - -module.exports = class CloneBasenamePlugin { - /** - * @param {string | ResolveStepHook} source source - * @param {string | ResolveStepHook} target target - */ - constructor(source, target) { - this.source = source; - this.target = target; - } - - /** - * @param {Resolver} resolver the resolver - * @returns {void} - */ - apply(resolver) { - const target = resolver.ensureHook(this.target); - resolver - .getHook(this.source) - .tapAsync("CloneBasenamePlugin", (request, resolveContext, callback) => { - const requestPath = /** @type {string} */ (request.path); - const filename = /** @type {string} */ (basename(requestPath)); - const filePath = resolver.join(requestPath, filename); - /** @type {ResolveRequest} */ - const obj = { - ...request, - path: filePath, - relativePath: - request.relativePath && - resolver.join(request.relativePath, filename) - }; - resolver.doResolve( - target, - obj, - "using path: " + filePath, - resolveContext, - callback - ); - }); - } -}; diff --git a/node_modules/enhanced-resolve/lib/ConditionalPlugin.js b/node_modules/enhanced-resolve/lib/ConditionalPlugin.js deleted file mode 100644 index 0e6610763f..0000000000 --- a/node_modules/enhanced-resolve/lib/ConditionalPlugin.js +++ /dev/null @@ -1,59 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -/** @typedef {import("./Resolver")} Resolver */ -/** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */ -/** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */ - -module.exports = class ConditionalPlugin { - /** - * @param {string | ResolveStepHook} source source - * @param {Partial} test compare object - * @param {string | null} message log message - * @param {boolean} allowAlternatives when false, do not continue with the current step when "test" matches - * @param {string | ResolveStepHook} target target - */ - constructor(source, test, message, allowAlternatives, target) { - this.source = source; - this.test = test; - this.message = message; - this.allowAlternatives = allowAlternatives; - this.target = target; - } - - /** - * @param {Resolver} resolver the resolver - * @returns {void} - */ - apply(resolver) { - const target = resolver.ensureHook(this.target); - const { test, message, allowAlternatives } = this; - const keys = /** @type {(keyof ResolveRequest)[]} */ (Object.keys(test)); - resolver - .getHook(this.source) - .tapAsync("ConditionalPlugin", (request, resolveContext, callback) => { - for (const prop of keys) { - if (request[prop] !== test[prop]) return callback(); - } - resolver.doResolve( - target, - request, - message, - resolveContext, - allowAlternatives - ? callback - : (err, result) => { - if (err) return callback(err); - - // Don't allow other alternatives - if (result === undefined) return callback(null, null); - callback(null, result); - } - ); - }); - } -}; diff --git a/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js b/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js deleted file mode 100644 index 8bbdb72063..0000000000 --- a/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js +++ /dev/null @@ -1,98 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -const DescriptionFileUtils = require("./DescriptionFileUtils"); - -/** @typedef {import("./Resolver")} Resolver */ -/** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */ -/** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */ - -module.exports = class DescriptionFilePlugin { - /** - * @param {string | ResolveStepHook} source source - * @param {string[]} filenames filenames - * @param {boolean} pathIsFile pathIsFile - * @param {string | ResolveStepHook} target target - */ - constructor(source, filenames, pathIsFile, target) { - this.source = source; - this.filenames = filenames; - this.pathIsFile = pathIsFile; - this.target = target; - } - - /** - * @param {Resolver} resolver the resolver - * @returns {void} - */ - apply(resolver) { - const target = resolver.ensureHook(this.target); - resolver - .getHook(this.source) - .tapAsync( - "DescriptionFilePlugin", - (request, resolveContext, callback) => { - const path = request.path; - if (!path) return callback(); - const directory = this.pathIsFile - ? DescriptionFileUtils.cdUp(path) - : path; - if (!directory) return callback(); - DescriptionFileUtils.loadDescriptionFile( - resolver, - directory, - this.filenames, - request.descriptionFilePath - ? { - path: request.descriptionFilePath, - content: request.descriptionFileData, - directory: /** @type {string} */ (request.descriptionFileRoot) - } - : undefined, - resolveContext, - (err, result) => { - if (err) return callback(err); - if (!result) { - if (resolveContext.log) - resolveContext.log( - `No description file found in ${directory} or above` - ); - return callback(); - } - const relativePath = - "." + path.slice(result.directory.length).replace(/\\/g, "/"); - /** @type {ResolveRequest} */ - const obj = { - ...request, - descriptionFilePath: result.path, - descriptionFileData: result.content, - descriptionFileRoot: result.directory, - relativePath: relativePath - }; - resolver.doResolve( - target, - obj, - "using description file: " + - result.path + - " (relative path: " + - relativePath + - ")", - resolveContext, - (err, result) => { - if (err) return callback(err); - - // Don't allow other processing - if (result === undefined) return callback(null, null); - callback(null, result); - } - ); - } - ); - } - ); - } -}; diff --git a/node_modules/enhanced-resolve/lib/DescriptionFileUtils.js b/node_modules/enhanced-resolve/lib/DescriptionFileUtils.js deleted file mode 100644 index ff53ad5f1c..0000000000 --- a/node_modules/enhanced-resolve/lib/DescriptionFileUtils.js +++ /dev/null @@ -1,201 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -const forEachBail = require("./forEachBail"); - -/** @typedef {import("./Resolver")} Resolver */ -/** @typedef {import("./Resolver").JsonObject} JsonObject */ -/** @typedef {import("./Resolver").JsonValue} JsonValue */ -/** @typedef {import("./Resolver").ResolveContext} ResolveContext */ -/** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */ - -/** - * @typedef {Object} DescriptionFileInfo - * @property {JsonObject=} content - * @property {string} path - * @property {string} directory - */ - -/** - * @callback ErrorFirstCallback - * @param {Error|null=} error - * @param {DescriptionFileInfo=} result - */ - -/** - * @typedef {Object} Result - * @property {string} path path to description file - * @property {string} directory directory of description file - * @property {JsonObject} content content of description file - */ - -/** - * @param {Resolver} resolver resolver - * @param {string} directory directory - * @param {string[]} filenames filenames - * @param {DescriptionFileInfo|undefined} oldInfo oldInfo - * @param {ResolveContext} resolveContext resolveContext - * @param {ErrorFirstCallback} callback callback - */ -function loadDescriptionFile( - resolver, - directory, - filenames, - oldInfo, - resolveContext, - callback -) { - (function findDescriptionFile() { - if (oldInfo && oldInfo.directory === directory) { - // We already have info for this directory and can reuse it - return callback(null, oldInfo); - } - forEachBail( - filenames, - /** - * @param {string} filename filename - * @param {(err?: null|Error, result?: null|Result) => void} callback callback - * @returns {void} - */ - (filename, callback) => { - const descriptionFilePath = resolver.join(directory, filename); - if (resolver.fileSystem.readJson) { - resolver.fileSystem.readJson(descriptionFilePath, (err, content) => { - if (err) { - if ( - typeof (/** @type {NodeJS.ErrnoException} */ (err).code) !== - "undefined" - ) { - if (resolveContext.missingDependencies) { - resolveContext.missingDependencies.add(descriptionFilePath); - } - return callback(); - } - if (resolveContext.fileDependencies) { - resolveContext.fileDependencies.add(descriptionFilePath); - } - return onJson(err); - } - if (resolveContext.fileDependencies) { - resolveContext.fileDependencies.add(descriptionFilePath); - } - onJson(null, content); - }); - } else { - resolver.fileSystem.readFile(descriptionFilePath, (err, content) => { - if (err) { - if (resolveContext.missingDependencies) { - resolveContext.missingDependencies.add(descriptionFilePath); - } - return callback(); - } - if (resolveContext.fileDependencies) { - resolveContext.fileDependencies.add(descriptionFilePath); - } - - /** @type {JsonObject | undefined} */ - let json; - - if (content) { - try { - json = JSON.parse(content.toString()); - } catch (/** @type {unknown} */ e) { - return onJson(/** @type {Error} */ (e)); - } - } else { - return onJson(new Error("No content in file")); - } - - onJson(null, json); - }); - } - - /** - * @param {null|Error} [err] error - * @param {JsonObject} [content] content - * @returns {void} - */ - function onJson(err, content) { - if (err) { - if (resolveContext.log) - resolveContext.log( - descriptionFilePath + " (directory description file): " + err - ); - else - err.message = - descriptionFilePath + " (directory description file): " + err; - return callback(err); - } - callback(null, { - content: /** @type {JsonObject} */ (content), - directory, - path: descriptionFilePath - }); - } - }, - /** - * @param {null|Error} [err] error - * @param {null|Result} [result] result - * @returns {void} - */ - (err, result) => { - if (err) return callback(err); - if (result) { - return callback(null, result); - } else { - const dir = cdUp(directory); - if (!dir) { - return callback(); - } else { - directory = dir; - return findDescriptionFile(); - } - } - } - ); - })(); -} - -/** - * @param {JsonObject} content content - * @param {string|string[]} field field - * @returns {JsonValue | undefined} field data - */ -function getField(content, field) { - if (!content) return undefined; - if (Array.isArray(field)) { - /** @type {JsonValue} */ - let current = content; - for (let j = 0; j < field.length; j++) { - if (current === null || typeof current !== "object") { - current = null; - break; - } - current = /** @type {JsonObject} */ (current)[field[j]]; - } - return current; - } else { - return content[field]; - } -} - -/** - * @param {string} directory directory - * @returns {string|null} parent directory or null - */ -function cdUp(directory) { - if (directory === "/") return null; - const i = directory.lastIndexOf("/"), - j = directory.lastIndexOf("\\"); - const p = i < 0 ? j : j < 0 ? i : i < j ? j : i; - if (p < 0) return null; - return directory.slice(0, p || 1); -} - -exports.loadDescriptionFile = loadDescriptionFile; -exports.getField = getField; -exports.cdUp = cdUp; diff --git a/node_modules/enhanced-resolve/lib/DirectoryExistsPlugin.js b/node_modules/enhanced-resolve/lib/DirectoryExistsPlugin.js deleted file mode 100644 index 80c94094a6..0000000000 --- a/node_modules/enhanced-resolve/lib/DirectoryExistsPlugin.js +++ /dev/null @@ -1,63 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -/** @typedef {import("./Resolver")} Resolver */ -/** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */ - -module.exports = class DirectoryExistsPlugin { - /** - * @param {string | ResolveStepHook} source source - * @param {string | ResolveStepHook} target target - */ - constructor(source, target) { - this.source = source; - this.target = target; - } - - /** - * @param {Resolver} resolver the resolver - * @returns {void} - */ - apply(resolver) { - const target = resolver.ensureHook(this.target); - resolver - .getHook(this.source) - .tapAsync( - "DirectoryExistsPlugin", - (request, resolveContext, callback) => { - const fs = resolver.fileSystem; - const directory = request.path; - if (!directory) return callback(); - fs.stat(directory, (err, stat) => { - if (err || !stat) { - if (resolveContext.missingDependencies) - resolveContext.missingDependencies.add(directory); - if (resolveContext.log) - resolveContext.log(directory + " doesn't exist"); - return callback(); - } - if (!stat.isDirectory()) { - if (resolveContext.missingDependencies) - resolveContext.missingDependencies.add(directory); - if (resolveContext.log) - resolveContext.log(directory + " is not a directory"); - return callback(); - } - if (resolveContext.fileDependencies) - resolveContext.fileDependencies.add(directory); - resolver.doResolve( - target, - request, - `existing directory ${directory}`, - resolveContext, - callback - ); - }); - } - ); - } -}; diff --git a/node_modules/enhanced-resolve/lib/ExportsFieldPlugin.js b/node_modules/enhanced-resolve/lib/ExportsFieldPlugin.js deleted file mode 100644 index 671c1fee3b..0000000000 --- a/node_modules/enhanced-resolve/lib/ExportsFieldPlugin.js +++ /dev/null @@ -1,200 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Ivan Kopeykin @vankop -*/ - -"use strict"; - -const DescriptionFileUtils = require("./DescriptionFileUtils"); -const forEachBail = require("./forEachBail"); -const { processExportsField } = require("./util/entrypoints"); -const { parseIdentifier } = require("./util/identifier"); -const { - invalidSegmentRegEx, - deprecatedInvalidSegmentRegEx -} = require("./util/path"); - -/** @typedef {import("./Resolver")} Resolver */ -/** @typedef {import("./Resolver").JsonObject} JsonObject */ -/** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */ -/** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */ -/** @typedef {import("./util/entrypoints").ExportsField} ExportsField */ -/** @typedef {import("./util/entrypoints").FieldProcessor} FieldProcessor */ - -module.exports = class ExportsFieldPlugin { - /** - * @param {string | ResolveStepHook} source source - * @param {Set} conditionNames condition names - * @param {string | string[]} fieldNamePath name path - * @param {string | ResolveStepHook} target target - */ - constructor(source, conditionNames, fieldNamePath, target) { - this.source = source; - this.target = target; - this.conditionNames = conditionNames; - this.fieldName = fieldNamePath; - /** @type {WeakMap} */ - this.fieldProcessorCache = new WeakMap(); - } - - /** - * @param {Resolver} resolver the resolver - * @returns {void} - */ - apply(resolver) { - const target = resolver.ensureHook(this.target); - resolver - .getHook(this.source) - .tapAsync("ExportsFieldPlugin", (request, resolveContext, callback) => { - // When there is no description file, abort - if (!request.descriptionFilePath) return callback(); - if ( - // When the description file is inherited from parent, abort - // (There is no description file inside of this package) - request.relativePath !== "." || - request.request === undefined - ) - return callback(); - - const remainingRequest = - request.query || request.fragment - ? (request.request === "." ? "./" : request.request) + - request.query + - request.fragment - : request.request; - const exportsField = - /** @type {ExportsField|null|undefined} */ - ( - DescriptionFileUtils.getField( - /** @type {JsonObject} */ (request.descriptionFileData), - this.fieldName - ) - ); - if (!exportsField) return callback(); - - if (request.directory) { - return callback( - new Error( - `Resolving to directories is not possible with the exports field (request was ${remainingRequest}/)` - ) - ); - } - - /** @type {string[]} */ - let paths; - /** @type {string | null} */ - let usedField; - - try { - // We attach the cache to the description file instead of the exportsField value - // because we use a WeakMap and the exportsField could be a string too. - // Description file is always an object when exports field can be accessed. - let fieldProcessor = this.fieldProcessorCache.get( - /** @type {JsonObject} */ (request.descriptionFileData) - ); - if (fieldProcessor === undefined) { - fieldProcessor = processExportsField(exportsField); - this.fieldProcessorCache.set( - /** @type {JsonObject} */ (request.descriptionFileData), - fieldProcessor - ); - } - [paths, usedField] = fieldProcessor( - remainingRequest, - this.conditionNames - ); - } catch (/** @type {unknown} */ err) { - if (resolveContext.log) { - resolveContext.log( - `Exports field in ${request.descriptionFilePath} can't be processed: ${err}` - ); - } - return callback(/** @type {Error} */ (err)); - } - - if (paths.length === 0) { - return callback( - new Error( - `Package path ${remainingRequest} is not exported from package ${request.descriptionFileRoot} (see exports field in ${request.descriptionFilePath})` - ) - ); - } - - forEachBail( - paths, - /** - * @param {string} p path - * @param {(err?: null|Error, result?: null|ResolveRequest) => void} callback callback - * @param {number} i index - * @returns {void} - */ - (p, callback, i) => { - const parsedIdentifier = parseIdentifier(p); - - if (!parsedIdentifier) return callback(); - - const [relativePath, query, fragment] = parsedIdentifier; - - if (relativePath.length === 0 || !relativePath.startsWith("./")) { - if (paths.length === i) { - return callback( - new Error( - `Invalid "exports" target "${p}" defined for "${usedField}" in the package config ${request.descriptionFilePath}, targets must start with "./"` - ) - ); - } - - return callback(); - } - - if ( - invalidSegmentRegEx.exec(relativePath.slice(2)) !== null && - deprecatedInvalidSegmentRegEx.test(relativePath.slice(2)) !== null - ) { - if (paths.length === i) { - return callback( - new Error( - `Invalid "exports" target "${p}" defined for "${usedField}" in the package config ${request.descriptionFilePath}, targets must start with "./"` - ) - ); - } - - return callback(); - } - - /** @type {ResolveRequest} */ - const obj = { - ...request, - request: undefined, - path: resolver.join( - /** @type {string} */ (request.descriptionFileRoot), - relativePath - ), - relativePath, - query, - fragment - }; - - resolver.doResolve( - target, - obj, - "using exports field: " + p, - resolveContext, - (err, result) => { - if (err) return callback(err); - // Don't allow to continue - https://github.com/webpack/enhanced-resolve/issues/400 - if (result === undefined) return callback(null, null); - callback(null, result); - } - ); - }, - /** - * @param {null|Error} [err] error - * @param {null|ResolveRequest} [result] result - * @returns {void} - */ - (err, result) => callback(err, result || null) - ); - }); - } -}; diff --git a/node_modules/enhanced-resolve/lib/ExtensionAliasPlugin.js b/node_modules/enhanced-resolve/lib/ExtensionAliasPlugin.js deleted file mode 100644 index a947990609..0000000000 --- a/node_modules/enhanced-resolve/lib/ExtensionAliasPlugin.js +++ /dev/null @@ -1,101 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Ivan Kopeykin @vankop -*/ - -"use strict"; - -const forEachBail = require("./forEachBail"); - -/** @typedef {import("./Resolver")} Resolver */ -/** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */ -/** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */ -/** @typedef {{ alias: string|string[], extension: string }} ExtensionAliasOption */ - -module.exports = class ExtensionAliasPlugin { - /** - * @param {string | ResolveStepHook} source source - * @param {ExtensionAliasOption} options options - * @param {string | ResolveStepHook} target target - */ - constructor(source, options, target) { - this.source = source; - this.options = options; - this.target = target; - } - - /** - * @param {Resolver} resolver the resolver - * @returns {void} - */ - apply(resolver) { - const target = resolver.ensureHook(this.target); - const { extension, alias } = this.options; - resolver - .getHook(this.source) - .tapAsync("ExtensionAliasPlugin", (request, resolveContext, callback) => { - const requestPath = request.request; - if (!requestPath || !requestPath.endsWith(extension)) return callback(); - const isAliasString = typeof alias === "string"; - /** - * @param {string} alias extension alias - * @param {(err?: null|Error, result?: null|ResolveRequest) => void} callback callback - * @param {number} [index] index - * @returns {void} - */ - const resolve = (alias, callback, index) => { - const newRequest = `${requestPath.slice( - 0, - -extension.length - )}${alias}`; - - return resolver.doResolve( - target, - { - ...request, - request: newRequest, - fullySpecified: true - }, - `aliased from extension alias with mapping '${extension}' to '${alias}'`, - resolveContext, - (err, result) => { - // Throw error if we are on the last alias (for multiple aliases) and it failed, always throw if we are not an array or we have only one alias - if (!isAliasString && index) { - if (index !== this.options.alias.length) { - if (resolveContext.log) { - resolveContext.log( - `Failed to alias from extension alias with mapping '${extension}' to '${alias}' for '${newRequest}': ${err}` - ); - } - - return callback(null, result); - } - - return callback(err, result); - } else { - callback(err, result); - } - } - ); - }; - /** - * @param {null|Error} [err] error - * @param {null|ResolveRequest} [result] result - * @returns {void} - */ - const stoppingCallback = (err, result) => { - if (err) return callback(err); - if (result) return callback(null, result); - // Don't allow other aliasing or raw request - return callback(null, null); - }; - if (isAliasString) { - resolve(alias, stoppingCallback); - } else if (alias.length > 1) { - forEachBail(alias, resolve, stoppingCallback); - } else { - resolve(alias[0], stoppingCallback); - } - }); - } -}; diff --git a/node_modules/enhanced-resolve/lib/FileExistsPlugin.js b/node_modules/enhanced-resolve/lib/FileExistsPlugin.js deleted file mode 100644 index 2dd33e3eef..0000000000 --- a/node_modules/enhanced-resolve/lib/FileExistsPlugin.js +++ /dev/null @@ -1,58 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -/** @typedef {import("./Resolver")} Resolver */ -/** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */ - -module.exports = class FileExistsPlugin { - /** - * @param {string | ResolveStepHook} source source - * @param {string | ResolveStepHook} target target - */ - constructor(source, target) { - this.source = source; - this.target = target; - } - - /** - * @param {Resolver} resolver the resolver - * @returns {void} - */ - apply(resolver) { - const target = resolver.ensureHook(this.target); - const fs = resolver.fileSystem; - resolver - .getHook(this.source) - .tapAsync("FileExistsPlugin", (request, resolveContext, callback) => { - const file = request.path; - if (!file) return callback(); - fs.stat(file, (err, stat) => { - if (err || !stat) { - if (resolveContext.missingDependencies) - resolveContext.missingDependencies.add(file); - if (resolveContext.log) resolveContext.log(file + " doesn't exist"); - return callback(); - } - if (!stat.isFile()) { - if (resolveContext.missingDependencies) - resolveContext.missingDependencies.add(file); - if (resolveContext.log) resolveContext.log(file + " is not a file"); - return callback(); - } - if (resolveContext.fileDependencies) - resolveContext.fileDependencies.add(file); - resolver.doResolve( - target, - request, - "existing file: " + file, - resolveContext, - callback - ); - }); - }); - } -}; diff --git a/node_modules/enhanced-resolve/lib/ImportsFieldPlugin.js b/node_modules/enhanced-resolve/lib/ImportsFieldPlugin.js deleted file mode 100644 index 15cad76f90..0000000000 --- a/node_modules/enhanced-resolve/lib/ImportsFieldPlugin.js +++ /dev/null @@ -1,223 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Ivan Kopeykin @vankop -*/ - -"use strict"; - -const DescriptionFileUtils = require("./DescriptionFileUtils"); -const forEachBail = require("./forEachBail"); -const { processImportsField } = require("./util/entrypoints"); -const { parseIdentifier } = require("./util/identifier"); -const { - invalidSegmentRegEx, - deprecatedInvalidSegmentRegEx -} = require("./util/path"); - -/** @typedef {import("./Resolver")} Resolver */ -/** @typedef {import("./Resolver").JsonObject} JsonObject */ -/** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */ -/** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */ -/** @typedef {import("./util/entrypoints").FieldProcessor} FieldProcessor */ -/** @typedef {import("./util/entrypoints").ImportsField} ImportsField */ - -const dotCode = ".".charCodeAt(0); - -module.exports = class ImportsFieldPlugin { - /** - * @param {string | ResolveStepHook} source source - * @param {Set} conditionNames condition names - * @param {string | string[]} fieldNamePath name path - * @param {string | ResolveStepHook} targetFile target file - * @param {string | ResolveStepHook} targetPackage target package - */ - constructor( - source, - conditionNames, - fieldNamePath, - targetFile, - targetPackage - ) { - this.source = source; - this.targetFile = targetFile; - this.targetPackage = targetPackage; - this.conditionNames = conditionNames; - this.fieldName = fieldNamePath; - /** @type {WeakMap} */ - this.fieldProcessorCache = new WeakMap(); - } - - /** - * @param {Resolver} resolver the resolver - * @returns {void} - */ - apply(resolver) { - const targetFile = resolver.ensureHook(this.targetFile); - const targetPackage = resolver.ensureHook(this.targetPackage); - - resolver - .getHook(this.source) - .tapAsync("ImportsFieldPlugin", (request, resolveContext, callback) => { - // When there is no description file, abort - if (!request.descriptionFilePath || request.request === undefined) { - return callback(); - } - - const remainingRequest = - request.request + request.query + request.fragment; - const importsField = - /** @type {ImportsField|null|undefined} */ - ( - DescriptionFileUtils.getField( - /** @type {JsonObject} */ (request.descriptionFileData), - this.fieldName - ) - ); - if (!importsField) return callback(); - - if (request.directory) { - return callback( - new Error( - `Resolving to directories is not possible with the imports field (request was ${remainingRequest}/)` - ) - ); - } - - /** @type {string[]} */ - let paths; - /** @type {string | null} */ - let usedField; - - try { - // We attach the cache to the description file instead of the importsField value - // because we use a WeakMap and the importsField could be a string too. - // Description file is always an object when exports field can be accessed. - let fieldProcessor = this.fieldProcessorCache.get( - /** @type {JsonObject} */ (request.descriptionFileData) - ); - if (fieldProcessor === undefined) { - fieldProcessor = processImportsField(importsField); - this.fieldProcessorCache.set( - /** @type {JsonObject} */ (request.descriptionFileData), - fieldProcessor - ); - } - [paths, usedField] = fieldProcessor( - remainingRequest, - this.conditionNames - ); - } catch (/** @type {unknown} */ err) { - if (resolveContext.log) { - resolveContext.log( - `Imports field in ${request.descriptionFilePath} can't be processed: ${err}` - ); - } - return callback(/** @type {Error} */ (err)); - } - - if (paths.length === 0) { - return callback( - new Error( - `Package import ${remainingRequest} is not imported from package ${request.descriptionFileRoot} (see imports field in ${request.descriptionFilePath})` - ) - ); - } - - forEachBail( - paths, - /** - * @param {string} p path - * @param {(err?: null|Error, result?: null|ResolveRequest) => void} callback callback - * @param {number} i index - * @returns {void} - */ - (p, callback, i) => { - const parsedIdentifier = parseIdentifier(p); - - if (!parsedIdentifier) return callback(); - - const [path_, query, fragment] = parsedIdentifier; - - switch (path_.charCodeAt(0)) { - // should be relative - case dotCode: { - if ( - invalidSegmentRegEx.exec(path_.slice(2)) !== null && - deprecatedInvalidSegmentRegEx.test(path_.slice(2)) !== null - ) { - if (paths.length === i) { - return callback( - new Error( - `Invalid "imports" target "${p}" defined for "${usedField}" in the package config ${request.descriptionFilePath}, targets must start with "./"` - ) - ); - } - - return callback(); - } - - /** @type {ResolveRequest} */ - const obj = { - ...request, - request: undefined, - path: resolver.join( - /** @type {string} */ (request.descriptionFileRoot), - path_ - ), - relativePath: path_, - query, - fragment - }; - - resolver.doResolve( - targetFile, - obj, - "using imports field: " + p, - resolveContext, - (err, result) => { - if (err) return callback(err); - // Don't allow to continue - https://github.com/webpack/enhanced-resolve/issues/400 - if (result === undefined) return callback(null, null); - callback(null, result); - } - ); - break; - } - - // package resolving - default: { - /** @type {ResolveRequest} */ - const obj = { - ...request, - request: path_, - relativePath: path_, - fullySpecified: true, - query, - fragment - }; - - resolver.doResolve( - targetPackage, - obj, - "using imports field: " + p, - resolveContext, - (err, result) => { - if (err) return callback(err); - // Don't allow to continue - https://github.com/webpack/enhanced-resolve/issues/400 - if (result === undefined) return callback(null, null); - callback(null, result); - } - ); - } - } - }, - /** - * @param {null|Error} [err] error - * @param {null|ResolveRequest} [result] result - * @returns {void} - */ - (err, result) => callback(err, result || null) - ); - }); - } -}; diff --git a/node_modules/enhanced-resolve/lib/JoinRequestPartPlugin.js b/node_modules/enhanced-resolve/lib/JoinRequestPartPlugin.js deleted file mode 100644 index 21c2cae01c..0000000000 --- a/node_modules/enhanced-resolve/lib/JoinRequestPartPlugin.js +++ /dev/null @@ -1,75 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -/** @typedef {import("./Resolver")} Resolver */ -/** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */ -/** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */ - -const namespaceStartCharCode = "@".charCodeAt(0); - -module.exports = class JoinRequestPartPlugin { - /** - * @param {string | ResolveStepHook} source source - * @param {string | ResolveStepHook} target target - */ - constructor(source, target) { - this.source = source; - this.target = target; - } - - /** - * @param {Resolver} resolver the resolver - * @returns {void} - */ - apply(resolver) { - const target = resolver.ensureHook(this.target); - resolver - .getHook(this.source) - .tapAsync( - "JoinRequestPartPlugin", - (request, resolveContext, callback) => { - const req = request.request || ""; - let i = req.indexOf("/", 3); - - if (i >= 0 && req.charCodeAt(2) === namespaceStartCharCode) { - i = req.indexOf("/", i + 1); - } - - /** @type {string} */ - let moduleName; - /** @type {string} */ - let remainingRequest; - /** @type {boolean} */ - let fullySpecified; - if (i < 0) { - moduleName = req; - remainingRequest = "."; - fullySpecified = false; - } else { - moduleName = req.slice(0, i); - remainingRequest = "." + req.slice(i); - fullySpecified = /** @type {boolean} */ (request.fullySpecified); - } - /** @type {ResolveRequest} */ - const obj = { - ...request, - path: resolver.join( - /** @type {string} */ - (request.path), - moduleName - ), - relativePath: - request.relativePath && - resolver.join(request.relativePath, moduleName), - request: remainingRequest, - fullySpecified - }; - resolver.doResolve(target, obj, null, resolveContext, callback); - } - ); - } -}; diff --git a/node_modules/enhanced-resolve/lib/JoinRequestPlugin.js b/node_modules/enhanced-resolve/lib/JoinRequestPlugin.js deleted file mode 100644 index 2ac99e972d..0000000000 --- a/node_modules/enhanced-resolve/lib/JoinRequestPlugin.js +++ /dev/null @@ -1,45 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -/** @typedef {import("./Resolver")} Resolver */ -/** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */ -/** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */ - -module.exports = class JoinRequestPlugin { - /** - * @param {string | ResolveStepHook} source source - * @param {string | ResolveStepHook} target target - */ - constructor(source, target) { - this.source = source; - this.target = target; - } - - /** - * @param {Resolver} resolver the resolver - * @returns {void} - */ - apply(resolver) { - const target = resolver.ensureHook(this.target); - resolver - .getHook(this.source) - .tapAsync("JoinRequestPlugin", (request, resolveContext, callback) => { - const requestPath = /** @type {string} */ (request.path); - const requestRequest = /** @type {string} */ (request.request); - /** @type {ResolveRequest} */ - const obj = { - ...request, - path: resolver.join(requestPath, requestRequest), - relativePath: - request.relativePath && - resolver.join(request.relativePath, requestRequest), - request: undefined - }; - resolver.doResolve(target, obj, null, resolveContext, callback); - }); - } -}; diff --git a/node_modules/enhanced-resolve/lib/LogInfoPlugin.js b/node_modules/enhanced-resolve/lib/LogInfoPlugin.js deleted file mode 100644 index d8b92070b0..0000000000 --- a/node_modules/enhanced-resolve/lib/LogInfoPlugin.js +++ /dev/null @@ -1,54 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -/** @typedef {import("./Resolver")} Resolver */ -/** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */ - -module.exports = class LogInfoPlugin { - /** - * @param {string | ResolveStepHook} source source - */ - constructor(source) { - this.source = source; - } - - /** - * @param {Resolver} resolver the resolver - * @returns {void} - */ - apply(resolver) { - const source = this.source; - resolver - .getHook(this.source) - .tapAsync("LogInfoPlugin", (request, resolveContext, callback) => { - if (!resolveContext.log) return callback(); - const log = resolveContext.log; - const prefix = "[" + source + "] "; - if (request.path) - log(prefix + "Resolving in directory: " + request.path); - if (request.request) - log(prefix + "Resolving request: " + request.request); - if (request.module) log(prefix + "Request is an module request."); - if (request.directory) log(prefix + "Request is a directory request."); - if (request.query) - log(prefix + "Resolving request query: " + request.query); - if (request.fragment) - log(prefix + "Resolving request fragment: " + request.fragment); - if (request.descriptionFilePath) - log( - prefix + "Has description data from " + request.descriptionFilePath - ); - if (request.relativePath) - log( - prefix + - "Relative path from description file is: " + - request.relativePath - ); - callback(); - }); - } -}; diff --git a/node_modules/enhanced-resolve/lib/MainFieldPlugin.js b/node_modules/enhanced-resolve/lib/MainFieldPlugin.js deleted file mode 100644 index 645b7df240..0000000000 --- a/node_modules/enhanced-resolve/lib/MainFieldPlugin.js +++ /dev/null @@ -1,90 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -const path = require("path"); -const DescriptionFileUtils = require("./DescriptionFileUtils"); - -/** @typedef {import("./Resolver")} Resolver */ -/** @typedef {import("./Resolver").JsonObject} JsonObject */ -/** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */ -/** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */ - -/** @typedef {{name: string|Array, forceRelative: boolean}} MainFieldOptions */ - -const alreadyTriedMainField = Symbol("alreadyTriedMainField"); - -module.exports = class MainFieldPlugin { - /** - * @param {string | ResolveStepHook} source source - * @param {MainFieldOptions} options options - * @param {string | ResolveStepHook} target target - */ - constructor(source, options, target) { - this.source = source; - this.options = options; - this.target = target; - } - - /** - * @param {Resolver} resolver the resolver - * @returns {void} - */ - apply(resolver) { - const target = resolver.ensureHook(this.target); - resolver - .getHook(this.source) - .tapAsync("MainFieldPlugin", (request, resolveContext, callback) => { - if ( - request.path !== request.descriptionFileRoot || - /** @type {ResolveRequest & { [alreadyTriedMainField]?: string }} */ - (request)[alreadyTriedMainField] === request.descriptionFilePath || - !request.descriptionFilePath - ) - return callback(); - const filename = path.basename(request.descriptionFilePath); - let mainModule = - /** @type {string|null|undefined} */ - ( - DescriptionFileUtils.getField( - /** @type {JsonObject} */ (request.descriptionFileData), - this.options.name - ) - ); - - if ( - !mainModule || - typeof mainModule !== "string" || - mainModule === "." || - mainModule === "./" - ) { - return callback(); - } - if (this.options.forceRelative && !/^\.\.?\//.test(mainModule)) - mainModule = "./" + mainModule; - /** @type {ResolveRequest & { [alreadyTriedMainField]?: string }} */ - const obj = { - ...request, - request: mainModule, - module: false, - directory: mainModule.endsWith("/"), - [alreadyTriedMainField]: request.descriptionFilePath - }; - return resolver.doResolve( - target, - obj, - "use " + - mainModule + - " from " + - this.options.name + - " in " + - filename, - resolveContext, - callback - ); - }); - } -}; diff --git a/node_modules/enhanced-resolve/lib/ModulesInHierachicDirectoriesPlugin.js b/node_modules/enhanced-resolve/lib/ModulesInHierachicDirectoriesPlugin.js deleted file mode 100644 index 06065e82c6..0000000000 --- a/node_modules/enhanced-resolve/lib/ModulesInHierachicDirectoriesPlugin.js +++ /dev/null @@ -1,9 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -// TODO remove in next major -module.exports = require("./ModulesInHierarchicalDirectoriesPlugin"); diff --git a/node_modules/enhanced-resolve/lib/ModulesInHierarchicalDirectoriesPlugin.js b/node_modules/enhanced-resolve/lib/ModulesInHierarchicalDirectoriesPlugin.js deleted file mode 100644 index 651377b2ac..0000000000 --- a/node_modules/enhanced-resolve/lib/ModulesInHierarchicalDirectoriesPlugin.js +++ /dev/null @@ -1,87 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -const forEachBail = require("./forEachBail"); -const getPaths = require("./getPaths"); - -/** @typedef {import("./Resolver")} Resolver */ -/** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */ -/** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */ - -module.exports = class ModulesInHierarchicalDirectoriesPlugin { - /** - * @param {string | ResolveStepHook} source source - * @param {string | Array} directories directories - * @param {string | ResolveStepHook} target target - */ - constructor(source, directories, target) { - this.source = source; - this.directories = /** @type {Array} */ ([]).concat(directories); - this.target = target; - } - - /** - * @param {Resolver} resolver the resolver - * @returns {void} - */ - apply(resolver) { - const target = resolver.ensureHook(this.target); - resolver - .getHook(this.source) - .tapAsync( - "ModulesInHierarchicalDirectoriesPlugin", - (request, resolveContext, callback) => { - const fs = resolver.fileSystem; - const addrs = getPaths(/** @type {string} */ (request.path)) - .paths.map(p => { - return this.directories.map(d => resolver.join(p, d)); - }) - .reduce((array, p) => { - array.push.apply(array, p); - return array; - }, []); - forEachBail( - addrs, - /** - * @param {string} addr addr - * @param {(err?: null|Error, result?: null|ResolveRequest) => void} callback callback - * @returns {void} - */ - (addr, callback) => { - fs.stat(addr, (err, stat) => { - if (!err && stat && stat.isDirectory()) { - /** @type {ResolveRequest} */ - const obj = { - ...request, - path: addr, - request: "./" + request.request, - module: false - }; - const message = "looking for modules in " + addr; - return resolver.doResolve( - target, - obj, - message, - resolveContext, - callback - ); - } - if (resolveContext.log) - resolveContext.log( - addr + " doesn't exist or is not a directory" - ); - if (resolveContext.missingDependencies) - resolveContext.missingDependencies.add(addr); - return callback(); - }); - }, - callback - ); - } - ); - } -}; diff --git a/node_modules/enhanced-resolve/lib/ModulesInRootPlugin.js b/node_modules/enhanced-resolve/lib/ModulesInRootPlugin.js deleted file mode 100644 index b7e5168810..0000000000 --- a/node_modules/enhanced-resolve/lib/ModulesInRootPlugin.js +++ /dev/null @@ -1,49 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -/** @typedef {import("./Resolver")} Resolver */ -/** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */ -/** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */ - -module.exports = class ModulesInRootPlugin { - /** - * @param {string | ResolveStepHook} source source - * @param {string} path path - * @param {string | ResolveStepHook} target target - */ - constructor(source, path, target) { - this.source = source; - this.path = path; - this.target = target; - } - - /** - * @param {Resolver} resolver the resolver - * @returns {void} - */ - apply(resolver) { - const target = resolver.ensureHook(this.target); - resolver - .getHook(this.source) - .tapAsync("ModulesInRootPlugin", (request, resolveContext, callback) => { - /** @type {ResolveRequest} */ - const obj = { - ...request, - path: this.path, - request: "./" + request.request, - module: false - }; - resolver.doResolve( - target, - obj, - "looking for modules in " + this.path, - resolveContext, - callback - ); - }); - } -}; diff --git a/node_modules/enhanced-resolve/lib/NextPlugin.js b/node_modules/enhanced-resolve/lib/NextPlugin.js deleted file mode 100644 index e59c56b8e0..0000000000 --- a/node_modules/enhanced-resolve/lib/NextPlugin.js +++ /dev/null @@ -1,33 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -/** @typedef {import("./Resolver")} Resolver */ -/** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */ - -module.exports = class NextPlugin { - /** - * @param {string | ResolveStepHook} source source - * @param {string | ResolveStepHook} target target - */ - constructor(source, target) { - this.source = source; - this.target = target; - } - - /** - * @param {Resolver} resolver the resolver - * @returns {void} - */ - apply(resolver) { - const target = resolver.ensureHook(this.target); - resolver - .getHook(this.source) - .tapAsync("NextPlugin", (request, resolveContext, callback) => { - resolver.doResolve(target, request, null, resolveContext, callback); - }); - } -}; diff --git a/node_modules/enhanced-resolve/lib/ParsePlugin.js b/node_modules/enhanced-resolve/lib/ParsePlugin.js deleted file mode 100644 index b7db0b07ec..0000000000 --- a/node_modules/enhanced-resolve/lib/ParsePlugin.js +++ /dev/null @@ -1,76 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -/** @typedef {import("./Resolver")} Resolver */ -/** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */ -/** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */ - -module.exports = class ParsePlugin { - /** - * @param {string | ResolveStepHook} source source - * @param {Partial} requestOptions request options - * @param {string | ResolveStepHook} target target - */ - constructor(source, requestOptions, target) { - this.source = source; - this.requestOptions = requestOptions; - this.target = target; - } - - /** - * @param {Resolver} resolver the resolver - * @returns {void} - */ - apply(resolver) { - const target = resolver.ensureHook(this.target); - resolver - .getHook(this.source) - .tapAsync("ParsePlugin", (request, resolveContext, callback) => { - const parsed = resolver.parse(/** @type {string} */ (request.request)); - /** @type {ResolveRequest} */ - const obj = { ...request, ...parsed, ...this.requestOptions }; - if (request.query && !parsed.query) { - obj.query = request.query; - } - if (request.fragment && !parsed.fragment) { - obj.fragment = request.fragment; - } - if (parsed && resolveContext.log) { - if (parsed.module) resolveContext.log("Parsed request is a module"); - if (parsed.directory) - resolveContext.log("Parsed request is a directory"); - } - // There is an edge-case where a request with # can be a path or a fragment -> try both - if (obj.request && !obj.query && obj.fragment) { - const directory = obj.fragment.endsWith("/"); - /** @type {ResolveRequest} */ - const alternative = { - ...obj, - directory, - request: - obj.request + - (obj.directory ? "/" : "") + - (directory ? obj.fragment.slice(0, -1) : obj.fragment), - fragment: "" - }; - resolver.doResolve( - target, - alternative, - null, - resolveContext, - (err, result) => { - if (err) return callback(err); - if (result) return callback(null, result); - resolver.doResolve(target, obj, null, resolveContext, callback); - } - ); - return; - } - resolver.doResolve(target, obj, null, resolveContext, callback); - }); - } -}; diff --git a/node_modules/enhanced-resolve/lib/PnpPlugin.js b/node_modules/enhanced-resolve/lib/PnpPlugin.js deleted file mode 100644 index d3d98bad92..0000000000 --- a/node_modules/enhanced-resolve/lib/PnpPlugin.js +++ /dev/null @@ -1,133 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Maël Nison @arcanis -*/ - -"use strict"; - -/** @typedef {import("./Resolver")} Resolver */ -/** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */ -/** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */ -/** - * @typedef {Object} PnpApiImpl - * @property {function(string, string, object): string | null} resolveToUnqualified - */ - -module.exports = class PnpPlugin { - /** - * @param {string | ResolveStepHook} source source - * @param {PnpApiImpl} pnpApi pnpApi - * @param {string | ResolveStepHook} target target - * @param {string | ResolveStepHook} alternateTarget alternateTarget - */ - constructor(source, pnpApi, target, alternateTarget) { - this.source = source; - this.pnpApi = pnpApi; - this.target = target; - this.alternateTarget = alternateTarget; - } - - /** - * @param {Resolver} resolver the resolver - * @returns {void} - */ - apply(resolver) { - /** @type {ResolveStepHook} */ - const target = resolver.ensureHook(this.target); - const alternateTarget = resolver.ensureHook(this.alternateTarget); - resolver - .getHook(this.source) - .tapAsync("PnpPlugin", (request, resolveContext, callback) => { - const req = request.request; - if (!req) return callback(); - - // The trailing slash indicates to PnP that this value is a folder rather than a file - const issuer = `${request.path}/`; - - const packageMatch = /^(@[^/]+\/)?[^/]+/.exec(req); - if (!packageMatch) return callback(); - - const packageName = packageMatch[0]; - const innerRequest = `.${req.slice(packageName.length)}`; - - /** @type {string|undefined|null} */ - let resolution; - /** @type {string|undefined|null} */ - let apiResolution; - try { - resolution = this.pnpApi.resolveToUnqualified(packageName, issuer, { - considerBuiltins: false - }); - - if (resolution === null) { - // This is either not a PnP managed issuer or it's a Node builtin - // Try to continue resolving with our alternatives - resolver.doResolve( - alternateTarget, - request, - "issuer is not managed by a pnpapi", - resolveContext, - (err, result) => { - if (err) return callback(err); - if (result) return callback(null, result); - // Skip alternatives - return callback(null, null); - } - ); - return; - } - - if (resolveContext.fileDependencies) { - apiResolution = this.pnpApi.resolveToUnqualified("pnpapi", issuer, { - considerBuiltins: false - }); - } - } catch (/** @type {unknown} */ error) { - if ( - /** @type {Error & { code: string }} */ - (error).code === "MODULE_NOT_FOUND" && - /** @type {Error & { pnpCode: string }} */ - (error).pnpCode === "UNDECLARED_DEPENDENCY" - ) { - // This is not a PnP managed dependency. - // Try to continue resolving with our alternatives - if (resolveContext.log) { - resolveContext.log(`request is not managed by the pnpapi`); - for (const line of /** @type {Error} */ (error).message - .split("\n") - .filter(Boolean)) - resolveContext.log(` ${line}`); - } - return callback(); - } - return callback(/** @type {Error} */ (error)); - } - - if (resolution === packageName) return callback(); - - if (apiResolution && resolveContext.fileDependencies) { - resolveContext.fileDependencies.add(apiResolution); - } - /** @type {ResolveRequest} */ - const obj = { - ...request, - path: resolution, - request: innerRequest, - ignoreSymlinks: true, - fullySpecified: request.fullySpecified && innerRequest !== "." - }; - resolver.doResolve( - target, - obj, - `resolved by pnp to ${resolution}`, - resolveContext, - (err, result) => { - if (err) return callback(err); - if (result) return callback(null, result); - // Skip alternatives - return callback(null, null); - } - ); - }); - } -}; diff --git a/node_modules/enhanced-resolve/lib/Resolver.js b/node_modules/enhanced-resolve/lib/Resolver.js deleted file mode 100644 index fdb73dc1a0..0000000000 --- a/node_modules/enhanced-resolve/lib/Resolver.js +++ /dev/null @@ -1,800 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -const { AsyncSeriesBailHook, AsyncSeriesHook, SyncHook } = require("tapable"); -const createInnerContext = require("./createInnerContext"); -const { parseIdentifier } = require("./util/identifier"); -const { - normalize, - cachedJoin: join, - getType, - PathType -} = require("./util/path"); - -/** @typedef {import("./ResolverFactory").ResolveOptions} ResolveOptions */ - -/** @typedef {Error & { details?: string }} ErrorWithDetail */ - -/** @typedef {(err: ErrorWithDetail | null, res?: string | false, req?: ResolveRequest) => void} ResolveCallback */ - -/** - * @typedef {Object} PossibleFileSystemError - * @property {string=} code - * @property {number=} errno - * @property {string=} path - * @property {string=} syscall - */ - -/** - * @template T - * @callback FileSystemCallback - * @param {PossibleFileSystemError & Error | null} err - * @param {T=} result - */ - -/** - * @typedef {string | Buffer | URL} PathLike - */ - -/** - * @typedef {PathLike | number} PathOrFileDescriptor - */ - -/** - * @typedef {Object} ObjectEncodingOptions - * @property {BufferEncoding | null | undefined} [encoding] - */ - -/** @typedef {function(NodeJS.ErrnoException | null, string=): void} StringCallback */ -/** @typedef {function(NodeJS.ErrnoException | null, Buffer=): void} BufferCallback */ -/** @typedef {function(NodeJS.ErrnoException | null, (string | Buffer)=): void} StringOrBufferCallback */ -/** @typedef {function(NodeJS.ErrnoException | null, IStats=): void} StatsCallback */ -/** @typedef {function(NodeJS.ErrnoException | null, IBigIntStats=): void} BigIntStatsCallback */ -/** @typedef {function(NodeJS.ErrnoException | null, (IStats | IBigIntStats)=): void} StatsOrBigIntStatsCallback */ -/** @typedef {function(NodeJS.ErrnoException | Error | null, JsonObject=): void} ReadJsonCallback */ -/** @typedef {function(NodeJS.ErrnoException | null, string[]=): void} ReaddirStringCallback */ -/** @typedef {function(NodeJS.ErrnoException | null, Buffer[]=): void} ReaddirBufferCallback */ -/** @typedef {function(NodeJS.ErrnoException | null, (string[] | Buffer[])=): void} ReaddirStringOrBufferCallback */ -/** @typedef {function(NodeJS.ErrnoException | null, Dirent[]=): void} ReaddirDirentCallback */ - -/** - * @template T - * @typedef {Object} IStatsBase - * @property {() => boolean} isFile - * @property {() => boolean} isDirectory - * @property {() => boolean} isBlockDevice - * @property {() => boolean} isCharacterDevice - * @property {() => boolean} isSymbolicLink - * @property {() => boolean} isFIFO - * @property {() => boolean} isSocket - * @property {T} dev - * @property {T} ino - * @property {T} mode - * @property {T} nlink - * @property {T} uid - * @property {T} gid - * @property {T} rdev - * @property {T} size - * @property {T} blksize - * @property {T} blocks - * @property {T} atimeMs - * @property {T} mtimeMs - * @property {T} ctimeMs - * @property {T} birthtimeMs - * @property {Date} atime - * @property {Date} mtime - * @property {Date} ctime - * @property {Date} birthtime - */ - -/** - * @typedef {IStatsBase} IStats - */ - -/** - * @typedef {IStatsBase & { atimeNs: bigint, mtimeNs: bigint, ctimeNs: bigint, birthtimeNs: bigint }} IBigIntStats - */ - -/** - * @typedef {Object} Dirent - * @property {() => boolean} isFile - * @property {() => boolean} isDirectory - * @property {() => boolean} isBlockDevice - * @property {() => boolean} isCharacterDevice - * @property {() => boolean} isSymbolicLink - * @property {() => boolean} isFIFO - * @property {() => boolean} isSocket - * @property {string} name - * @property {string} path - */ - -/** - * @typedef {Object} StatOptions - * @property {(boolean | undefined)=} bigint - */ - -/** - * @typedef {Object} StatSyncOptions - * @property {(boolean | undefined)=} bigint - * @property {(boolean | undefined)=} throwIfNoEntry - */ - -/** - * @typedef {{ - * (path: PathOrFileDescriptor, options: ({ encoding?: null | undefined, flag?: string | undefined } & import("events").Abortable) | undefined | null, callback: BufferCallback): void; - * (path: PathOrFileDescriptor, options: ({ encoding: BufferEncoding, flag?: string | undefined } & import("events").Abortable) | BufferEncoding, callback: StringCallback): void; - * (path: PathOrFileDescriptor, options: (ObjectEncodingOptions & { flag?: string | undefined } & import("events").Abortable) | BufferEncoding | undefined | null, callback: StringOrBufferCallback): void; - * (path: PathOrFileDescriptor, callback: BufferCallback): void; - * }} ReadFile - */ - -/** - * @typedef {ObjectEncodingOptions | BufferEncoding | undefined | null} EncodingOption - */ - -/** - * @typedef {'buffer'| { encoding: 'buffer' }} BufferEncodingOption - */ - -/** - * @typedef {{ - * (path: PathOrFileDescriptor, options?: { encoding?: null | undefined, flag?: string | undefined } | null): Buffer; - * (path: PathOrFileDescriptor, options: { encoding: BufferEncoding, flag?: string | undefined } | BufferEncoding): string; - * (path: PathOrFileDescriptor, options?: (ObjectEncodingOptions & { flag?: string | undefined }) | BufferEncoding | null): string | Buffer; - * }} ReadFileSync - */ - -/** - * @typedef {{ - * (path: PathLike, options: { encoding: BufferEncoding | null, withFileTypes?: false | undefined, recursive?: boolean | undefined } | BufferEncoding | undefined | null, callback: ReaddirStringCallback): void; - * (path: PathLike, options: { encoding: 'buffer', withFileTypes?: false | undefined, recursive?: boolean | undefined } | 'buffer', callback: ReaddirBufferCallback): void; - * (path: PathLike, callback: ReaddirStringCallback): void; - * (path: PathLike, options: (ObjectEncodingOptions & { withFileTypes?: false | undefined, recursive?: boolean | undefined }) | BufferEncoding | undefined | null, callback: ReaddirStringOrBufferCallback): void; - * (path: PathLike, options: ObjectEncodingOptions & { withFileTypes: true, recursive?: boolean | undefined }, callback: ReaddirDirentCallback): void; - * }} Readdir - */ - -/** - * @typedef {{ - * (path: PathLike, options?: { encoding: BufferEncoding | null, withFileTypes?: false | undefined, recursive?: boolean | undefined } | BufferEncoding | null): string[]; - * (path: PathLike, options: { encoding: 'buffer', withFileTypes?: false | undefined, recursive?: boolean | undefined } | 'buffer'): Buffer[]; - * (path: PathLike, options?: (ObjectEncodingOptions & { withFileTypes?: false | undefined, recursive?: boolean | undefined }) | BufferEncoding | null): string[] | Buffer[]; - * (path: PathLike, options: ObjectEncodingOptions & { withFileTypes: true, recursive?: boolean | undefined }): Dirent[]; - * }} ReaddirSync - - /** - * @typedef {function(PathOrFileDescriptor, ReadJsonCallback): void} ReadJson - */ - -/** - * @typedef {function(PathOrFileDescriptor): JsonObject} ReadJsonSync - */ - -/** - * @typedef {{ - * (path: PathLike, options: EncodingOption, callback: StringCallback): void; - * (path: PathLike, options: BufferEncodingOption, callback: BufferCallback): void; - * (path: PathLike, options: EncodingOption, callback: StringOrBufferCallback): void; - * (path: PathLike, callback: StringCallback): void; - * }} Readlink - */ - -/** - * @typedef {{ - * (path: PathLike, options?: EncodingOption): string; - * (path: PathLike, options: BufferEncodingOption): Buffer; - * (path: PathLike, options?: EncodingOption): string | Buffer; - * }} ReadlinkSync - */ - -/** - * @typedef {{ - * (path: PathLike, callback: StatsCallback): void; - * (path: PathLike, options: (StatOptions & { bigint?: false | undefined }) | undefined, callback: StatsCallback): void; - * (path: PathLike, options: StatOptions & { bigint: true }, callback: BigIntStatsCallback): void; - * (path: PathLike, options: StatOptions | undefined, callback: StatsOrBigIntStatsCallback): void; - * }} LStat - */ - -/** - * @typedef {{ - * (path: PathLike, options?: undefined): IStats; - * (path: PathLike, options?: StatSyncOptions & { bigint?: false | undefined, throwIfNoEntry: false }): IStats | undefined; - * (path: PathLike, options: StatSyncOptions & { bigint: true, throwIfNoEntry: false }): IBigIntStats | undefined; - * (path: PathLike, options?: StatSyncOptions & { bigint?: false | undefined }): IStats; - * (path: PathLike, options: StatSyncOptions & { bigint: true }): IBigIntStats; - * (path: PathLike, options: StatSyncOptions & { bigint: boolean, throwIfNoEntry?: false | undefined }): IStats | IBigIntStats; - * (path: PathLike, options?: StatSyncOptions): IStats | IBigIntStats | undefined; - * }} LStatSync - */ - -/** - * @typedef {{ - * (path: PathLike, callback: StatsCallback): void; - * (path: PathLike, options: (StatOptions & { bigint?: false | undefined }) | undefined, callback: StatsCallback): void; - * (path: PathLike, options: StatOptions & { bigint: true }, callback: BigIntStatsCallback): void; - * (path: PathLike, options: StatOptions | undefined, callback: StatsOrBigIntStatsCallback): void; - * }} Stat - */ - -/** - * @typedef {{ - * (path: PathLike, options?: undefined): IStats; - * (path: PathLike, options?: StatSyncOptions & { bigint?: false | undefined, throwIfNoEntry: false }): IStats | undefined; - * (path: PathLike, options: StatSyncOptions & { bigint: true, throwIfNoEntry: false }): IBigIntStats | undefined; - * (path: PathLike, options?: StatSyncOptions & { bigint?: false | undefined }): IStats; - * (path: PathLike, options: StatSyncOptions & { bigint: true }): IBigIntStats; - * (path: PathLike, options: StatSyncOptions & { bigint: boolean, throwIfNoEntry?: false | undefined }): IStats | IBigIntStats; - * (path: PathLike, options?: StatSyncOptions): IStats | IBigIntStats | undefined; - * }} StatSync - */ - -/** - * @typedef {{ - * (path: PathLike, options: EncodingOption, callback: StringCallback): void; - * (path: PathLike, options: BufferEncodingOption, callback: BufferCallback): void; - * (path: PathLike, options: EncodingOption, callback: StringOrBufferCallback): void; - * (path: PathLike, callback: StringCallback): void; - * }} RealPath - */ - -/** - * @typedef {{ - * (path: PathLike, options?: EncodingOption): string; - * (path: PathLike, options: BufferEncodingOption): Buffer; - * (path: PathLike, options?: EncodingOption): string | Buffer; - * }} RealPathSync - */ - -/** - * @typedef {Object} FileSystem - * @property {ReadFile} readFile - * @property {Readdir} readdir - * @property {ReadJson=} readJson - * @property {Readlink} readlink - * @property {LStat=} lstat - * @property {Stat} stat - * @property {RealPath=} realpath - */ - -/** - * @typedef {Object} SyncFileSystem - * @property {ReadFileSync} readFileSync - * @property {ReaddirSync} readdirSync - * @property {ReadJsonSync=} readJsonSync - * @property {ReadlinkSync} readlinkSync - * @property {LStatSync=} lstatSync - * @property {StatSync} statSync - * @property {RealPathSync=} realpathSync - */ - -/** - * @typedef {Object} ParsedIdentifier - * @property {string} request - * @property {string} query - * @property {string} fragment - * @property {boolean} directory - * @property {boolean} module - * @property {boolean} file - * @property {boolean} internal - */ - -/** @typedef {string | number | boolean | null} JsonPrimitive */ -/** @typedef {JsonValue[]} JsonArray */ -/** @typedef {JsonPrimitive | JsonObject | JsonArray} JsonValue */ -/** @typedef {{[Key in string]: JsonValue} & {[Key in string]?: JsonValue | undefined}} JsonObject */ - -/** - * @typedef {Object} BaseResolveRequest - * @property {string | false} path - * @property {object=} context - * @property {string=} descriptionFilePath - * @property {string=} descriptionFileRoot - * @property {JsonObject=} descriptionFileData - * @property {string=} relativePath - * @property {boolean=} ignoreSymlinks - * @property {boolean=} fullySpecified - * @property {string=} __innerRequest - * @property {string=} __innerRequest_request - * @property {string=} __innerRequest_relativePath - */ - -/** @typedef {BaseResolveRequest & Partial} ResolveRequest */ - -/** - * String with special formatting - * @typedef {string} StackEntry - */ - -/** - * @template T - * @typedef {{ add: (item: T) => void }} WriteOnlySet - */ - -/** @typedef {(function (ResolveRequest): void)} ResolveContextYield */ - -/** - * Resolve context - * @typedef {Object} ResolveContext - * @property {WriteOnlySet=} contextDependencies - * @property {WriteOnlySet=} fileDependencies files that was found on file system - * @property {WriteOnlySet=} missingDependencies dependencies that was not found on file system - * @property {Set=} stack set of hooks' calls. For instance, `resolve → parsedResolve → describedResolve`, - * @property {(function(string): void)=} log log function - * @property {ResolveContextYield=} yield yield result, if provided plugins can return several results - */ - -/** @typedef {AsyncSeriesBailHook<[ResolveRequest, ResolveContext], ResolveRequest | null>} ResolveStepHook */ - -/** - * @typedef {Object} KnownHooks - * @property {SyncHook<[ResolveStepHook, ResolveRequest], void>} resolveStep - * @property {SyncHook<[ResolveRequest, Error]>} noResolve - * @property {ResolveStepHook} resolve - * @property {AsyncSeriesHook<[ResolveRequest, ResolveContext]>} result - */ - -/** - * @typedef {{[key: string]: ResolveStepHook}} EnsuredHooks - */ - -/** - * @param {string} str input string - * @returns {string} in camel case - */ -function toCamelCase(str) { - return str.replace(/-([a-z])/g, str => str.slice(1).toUpperCase()); -} - -class Resolver { - /** - * @param {ResolveStepHook} hook hook - * @param {ResolveRequest} request request - * @returns {StackEntry} stack entry - */ - static createStackEntry(hook, request) { - return ( - hook.name + - ": (" + - request.path + - ") " + - (request.request || "") + - (request.query || "") + - (request.fragment || "") + - (request.directory ? " directory" : "") + - (request.module ? " module" : "") - ); - } - - /** - * @param {FileSystem} fileSystem a filesystem - * @param {ResolveOptions} options options - */ - constructor(fileSystem, options) { - this.fileSystem = fileSystem; - this.options = options; - /** @type {KnownHooks} */ - this.hooks = { - resolveStep: new SyncHook(["hook", "request"], "resolveStep"), - noResolve: new SyncHook(["request", "error"], "noResolve"), - resolve: new AsyncSeriesBailHook( - ["request", "resolveContext"], - "resolve" - ), - result: new AsyncSeriesHook(["result", "resolveContext"], "result") - }; - } - - /** - * @param {string | ResolveStepHook} name hook name or hook itself - * @returns {ResolveStepHook} the hook - */ - ensureHook(name) { - if (typeof name !== "string") { - return name; - } - name = toCamelCase(name); - if (/^before/.test(name)) { - return /** @type {ResolveStepHook} */ ( - this.ensureHook(name[6].toLowerCase() + name.slice(7)).withOptions({ - stage: -10 - }) - ); - } - if (/^after/.test(name)) { - return /** @type {ResolveStepHook} */ ( - this.ensureHook(name[5].toLowerCase() + name.slice(6)).withOptions({ - stage: 10 - }) - ); - } - /** @type {ResolveStepHook} */ - const hook = /** @type {KnownHooks & EnsuredHooks} */ (this.hooks)[name]; - if (!hook) { - /** @type {KnownHooks & EnsuredHooks} */ - (this.hooks)[name] = new AsyncSeriesBailHook( - ["request", "resolveContext"], - name - ); - - return /** @type {KnownHooks & EnsuredHooks} */ (this.hooks)[name]; - } - return hook; - } - - /** - * @param {string | ResolveStepHook} name hook name or hook itself - * @returns {ResolveStepHook} the hook - */ - getHook(name) { - if (typeof name !== "string") { - return name; - } - name = toCamelCase(name); - if (/^before/.test(name)) { - return /** @type {ResolveStepHook} */ ( - this.getHook(name[6].toLowerCase() + name.slice(7)).withOptions({ - stage: -10 - }) - ); - } - if (/^after/.test(name)) { - return /** @type {ResolveStepHook} */ ( - this.getHook(name[5].toLowerCase() + name.slice(6)).withOptions({ - stage: 10 - }) - ); - } - /** @type {ResolveStepHook} */ - const hook = /** @type {KnownHooks & EnsuredHooks} */ (this.hooks)[name]; - if (!hook) { - throw new Error(`Hook ${name} doesn't exist`); - } - return hook; - } - - /** - * @param {object} context context information object - * @param {string} path context path - * @param {string} request request string - * @returns {string | false} result - */ - resolveSync(context, path, request) { - /** @type {Error | null | undefined} */ - let err = undefined; - /** @type {string | false | undefined} */ - let result = undefined; - let sync = false; - this.resolve(context, path, request, {}, (e, r) => { - err = e; - result = r; - sync = true; - }); - if (!sync) { - throw new Error( - "Cannot 'resolveSync' because the fileSystem is not sync. Use 'resolve'!" - ); - } - if (err) throw err; - if (result === undefined) throw new Error("No result"); - return result; - } - - /** - * @param {object} context context information object - * @param {string} path context path - * @param {string} request request string - * @param {ResolveContext} resolveContext resolve context - * @param {ResolveCallback} callback callback function - * @returns {void} - */ - resolve(context, path, request, resolveContext, callback) { - if (!context || typeof context !== "object") - return callback(new Error("context argument is not an object")); - if (typeof path !== "string") - return callback(new Error("path argument is not a string")); - if (typeof request !== "string") - return callback(new Error("request argument is not a string")); - if (!resolveContext) - return callback(new Error("resolveContext argument is not set")); - - /** @type {ResolveRequest} */ - const obj = { - context: context, - path: path, - request: request - }; - - /** @type {ResolveContextYield | undefined} */ - let yield_; - let yieldCalled = false; - /** @type {ResolveContextYield | undefined} */ - let finishYield; - if (typeof resolveContext.yield === "function") { - const old = resolveContext.yield; - /** - * @param {ResolveRequest} obj object - */ - yield_ = obj => { - old(obj); - yieldCalled = true; - }; - /** - * @param {ResolveRequest} result result - * @returns {void} - */ - finishYield = result => { - if (result) { - /** @type {ResolveContextYield} */ (yield_)(result); - } - callback(null); - }; - } - - const message = `resolve '${request}' in '${path}'`; - - /** - * @param {ResolveRequest} result result - * @returns {void} - */ - const finishResolved = result => { - return callback( - null, - result.path === false - ? false - : `${result.path.replace(/#/g, "\0#")}${ - result.query ? result.query.replace(/#/g, "\0#") : "" - }${result.fragment || ""}`, - result - ); - }; - - /** - * @param {string[]} log logs - * @returns {void} - */ - const finishWithoutResolve = log => { - /** - * @type {ErrorWithDetail} - */ - const error = new Error("Can't " + message); - error.details = log.join("\n"); - this.hooks.noResolve.call(obj, error); - return callback(error); - }; - - if (resolveContext.log) { - // We need log anyway to capture it in case of an error - const parentLog = resolveContext.log; - /** @type {string[]} */ - const log = []; - return this.doResolve( - this.hooks.resolve, - obj, - message, - { - log: msg => { - parentLog(msg); - log.push(msg); - }, - yield: yield_, - fileDependencies: resolveContext.fileDependencies, - contextDependencies: resolveContext.contextDependencies, - missingDependencies: resolveContext.missingDependencies, - stack: resolveContext.stack - }, - (err, result) => { - if (err) return callback(err); - - if (yieldCalled || (result && yield_)) { - return /** @type {ResolveContextYield} */ (finishYield)( - /** @type {ResolveRequest} */ (result) - ); - } - - if (result) return finishResolved(result); - - return finishWithoutResolve(log); - } - ); - } else { - // Try to resolve assuming there is no error - // We don't log stuff in this case - return this.doResolve( - this.hooks.resolve, - obj, - message, - { - log: undefined, - yield: yield_, - fileDependencies: resolveContext.fileDependencies, - contextDependencies: resolveContext.contextDependencies, - missingDependencies: resolveContext.missingDependencies, - stack: resolveContext.stack - }, - (err, result) => { - if (err) return callback(err); - - if (yieldCalled || (result && yield_)) { - return /** @type {ResolveContextYield} */ (finishYield)( - /** @type {ResolveRequest} */ (result) - ); - } - - if (result) return finishResolved(result); - - // log is missing for the error details - // so we redo the resolving for the log info - // this is more expensive to the success case - // is assumed by default - /** @type {string[]} */ - const log = []; - - return this.doResolve( - this.hooks.resolve, - obj, - message, - { - log: msg => log.push(msg), - yield: yield_, - stack: resolveContext.stack - }, - (err, result) => { - if (err) return callback(err); - - // In a case that there is a race condition and yield will be called - if (yieldCalled || (result && yield_)) { - return /** @type {ResolveContextYield} */ (finishYield)( - /** @type {ResolveRequest} */ (result) - ); - } - - return finishWithoutResolve(log); - } - ); - } - ); - } - } - - /** - * @param {ResolveStepHook} hook hook - * @param {ResolveRequest} request request - * @param {null|string} message string - * @param {ResolveContext} resolveContext resolver context - * @param {(err?: null|Error, result?: ResolveRequest) => void} callback callback - * @returns {void} - */ - doResolve(hook, request, message, resolveContext, callback) { - const stackEntry = Resolver.createStackEntry(hook, request); - - /** @type {Set | undefined} */ - let newStack; - if (resolveContext.stack) { - newStack = new Set(resolveContext.stack); - if (resolveContext.stack.has(stackEntry)) { - /** - * Prevent recursion - * @type {Error & {recursion?: boolean}} - */ - const recursionError = new Error( - "Recursion in resolving\nStack:\n " + - Array.from(newStack).join("\n ") - ); - recursionError.recursion = true; - if (resolveContext.log) - resolveContext.log("abort resolving because of recursion"); - return callback(recursionError); - } - newStack.add(stackEntry); - } else { - // creating a set with new Set([item]) - // allocates a new array that has to be garbage collected - // this is an EXTREMELY hot path, so let's avoid it - newStack = new Set(); - newStack.add(stackEntry); - } - this.hooks.resolveStep.call(hook, request); - - if (hook.isUsed()) { - const innerContext = createInnerContext( - { - log: resolveContext.log, - yield: resolveContext.yield, - fileDependencies: resolveContext.fileDependencies, - contextDependencies: resolveContext.contextDependencies, - missingDependencies: resolveContext.missingDependencies, - stack: newStack - }, - message - ); - return hook.callAsync(request, innerContext, (err, result) => { - if (err) return callback(err); - if (result) return callback(null, result); - callback(); - }); - } else { - callback(); - } - } - - /** - * @param {string} identifier identifier - * @returns {ParsedIdentifier} parsed identifier - */ - parse(identifier) { - const part = { - request: "", - query: "", - fragment: "", - module: false, - directory: false, - file: false, - internal: false - }; - - const parsedIdentifier = parseIdentifier(identifier); - - if (!parsedIdentifier) return part; - - [part.request, part.query, part.fragment] = parsedIdentifier; - - if (part.request.length > 0) { - part.internal = this.isPrivate(identifier); - part.module = this.isModule(part.request); - part.directory = this.isDirectory(part.request); - if (part.directory) { - part.request = part.request.slice(0, -1); - } - } - - return part; - } - - /** - * @param {string} path path - * @returns {boolean} true, if the path is a module - */ - isModule(path) { - return getType(path) === PathType.Normal; - } - - /** - * @param {string} path path - * @returns {boolean} true, if the path is private - */ - isPrivate(path) { - return getType(path) === PathType.Internal; - } - - /** - * @param {string} path a path - * @returns {boolean} true, if the path is a directory path - */ - isDirectory(path) { - return path.endsWith("/"); - } - - /** - * @param {string} path path - * @param {string} request request - * @returns {string} joined path - */ - join(path, request) { - return join(path, request); - } - - /** - * @param {string} path path - * @returns {string} normalized path - */ - normalize(path) { - return normalize(path); - } -} - -module.exports = Resolver; diff --git a/node_modules/enhanced-resolve/lib/ResolverFactory.js b/node_modules/enhanced-resolve/lib/ResolverFactory.js deleted file mode 100644 index 59558c7fe5..0000000000 --- a/node_modules/enhanced-resolve/lib/ResolverFactory.js +++ /dev/null @@ -1,728 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -const versions = require("process").versions; -const Resolver = require("./Resolver"); -const { getType, PathType } = require("./util/path"); - -const SyncAsyncFileSystemDecorator = require("./SyncAsyncFileSystemDecorator"); - -const AliasFieldPlugin = require("./AliasFieldPlugin"); -const AliasPlugin = require("./AliasPlugin"); -const AppendPlugin = require("./AppendPlugin"); -const ConditionalPlugin = require("./ConditionalPlugin"); -const DescriptionFilePlugin = require("./DescriptionFilePlugin"); -const DirectoryExistsPlugin = require("./DirectoryExistsPlugin"); -const ExportsFieldPlugin = require("./ExportsFieldPlugin"); -const ExtensionAliasPlugin = require("./ExtensionAliasPlugin"); -const FileExistsPlugin = require("./FileExistsPlugin"); -const ImportsFieldPlugin = require("./ImportsFieldPlugin"); -const JoinRequestPartPlugin = require("./JoinRequestPartPlugin"); -const JoinRequestPlugin = require("./JoinRequestPlugin"); -const MainFieldPlugin = require("./MainFieldPlugin"); -const ModulesInHierarchicalDirectoriesPlugin = require("./ModulesInHierarchicalDirectoriesPlugin"); -const ModulesInRootPlugin = require("./ModulesInRootPlugin"); -const NextPlugin = require("./NextPlugin"); -const ParsePlugin = require("./ParsePlugin"); -const PnpPlugin = require("./PnpPlugin"); -const RestrictionsPlugin = require("./RestrictionsPlugin"); -const ResultPlugin = require("./ResultPlugin"); -const RootsPlugin = require("./RootsPlugin"); -const SelfReferencePlugin = require("./SelfReferencePlugin"); -const SymlinkPlugin = require("./SymlinkPlugin"); -const TryNextPlugin = require("./TryNextPlugin"); -const UnsafeCachePlugin = require("./UnsafeCachePlugin"); -const UseFilePlugin = require("./UseFilePlugin"); - -/** @typedef {import("./AliasPlugin").AliasOption} AliasOptionEntry */ -/** @typedef {import("./ExtensionAliasPlugin").ExtensionAliasOption} ExtensionAliasOption */ -/** @typedef {import("./PnpPlugin").PnpApiImpl} PnpApi */ -/** @typedef {import("./Resolver").EnsuredHooks} EnsuredHooks */ -/** @typedef {import("./Resolver").FileSystem} FileSystem */ -/** @typedef {import("./Resolver").KnownHooks} KnownHooks */ -/** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */ -/** @typedef {import("./Resolver").SyncFileSystem} SyncFileSystem */ - -/** @typedef {string|string[]|false} AliasOptionNewRequest */ -/** @typedef {{[k: string]: AliasOptionNewRequest}} AliasOptions */ -/** @typedef {{[k: string]: string|string[] }} ExtensionAliasOptions */ -/** @typedef {false | 0 | "" | null | undefined} Falsy */ -/** @typedef {{apply: function(Resolver): void} | (function(this: Resolver, Resolver): void) | Falsy} Plugin */ - -/** - * @typedef {Object} UserResolveOptions - * @property {(AliasOptions | AliasOptionEntry[])=} alias A list of module alias configurations or an object which maps key to value - * @property {(AliasOptions | AliasOptionEntry[])=} fallback A list of module alias configurations or an object which maps key to value, applied only after modules option - * @property {ExtensionAliasOptions=} extensionAlias An object which maps extension to extension aliases - * @property {(string | string[])[]=} aliasFields A list of alias fields in description files - * @property {(function(ResolveRequest): boolean)=} cachePredicate A function which decides whether a request should be cached or not. An object is passed with at least `path` and `request` properties. - * @property {boolean=} cacheWithContext Whether or not the unsafeCache should include request context as part of the cache key. - * @property {string[]=} descriptionFiles A list of description files to read from - * @property {string[]=} conditionNames A list of exports field condition names. - * @property {boolean=} enforceExtension Enforce that a extension from extensions must be used - * @property {(string | string[])[]=} exportsFields A list of exports fields in description files - * @property {(string | string[])[]=} importsFields A list of imports fields in description files - * @property {string[]=} extensions A list of extensions which should be tried for files - * @property {FileSystem} fileSystem The file system which should be used - * @property {(object | boolean)=} unsafeCache Use this cache object to unsafely cache the successful requests - * @property {boolean=} symlinks Resolve symlinks to their symlinked location - * @property {Resolver=} resolver A prepared Resolver to which the plugins are attached - * @property {string[] | string=} modules A list of directories to resolve modules from, can be absolute path or folder name - * @property {(string | string[] | {name: string | string[], forceRelative: boolean})[]=} mainFields A list of main fields in description files - * @property {string[]=} mainFiles A list of main files in directories - * @property {Plugin[]=} plugins A list of additional resolve plugins which should be applied - * @property {PnpApi | null=} pnpApi A PnP API that should be used - null is "never", undefined is "auto" - * @property {string[]=} roots A list of root paths - * @property {boolean=} fullySpecified The request is already fully specified and no extensions or directories are resolved for it - * @property {boolean=} resolveToContext Resolve to a context instead of a file - * @property {(string|RegExp)[]=} restrictions A list of resolve restrictions - * @property {boolean=} useSyncFileSystemCalls Use only the sync constraints of the file system calls - * @property {boolean=} preferRelative Prefer to resolve module requests as relative requests before falling back to modules - * @property {boolean=} preferAbsolute Prefer to resolve server-relative urls as absolute paths before falling back to resolve in roots - */ - -/** - * @typedef {Object} ResolveOptions - * @property {AliasOptionEntry[]} alias - * @property {AliasOptionEntry[]} fallback - * @property {Set} aliasFields - * @property {ExtensionAliasOption[]} extensionAlias - * @property {(function(ResolveRequest): boolean)} cachePredicate - * @property {boolean} cacheWithContext - * @property {Set} conditionNames A list of exports field condition names. - * @property {string[]} descriptionFiles - * @property {boolean} enforceExtension - * @property {Set} exportsFields - * @property {Set} importsFields - * @property {Set} extensions - * @property {FileSystem} fileSystem - * @property {object | false} unsafeCache - * @property {boolean} symlinks - * @property {Resolver=} resolver - * @property {Array} modules - * @property {{name: string[], forceRelative: boolean}[]} mainFields - * @property {Set} mainFiles - * @property {Plugin[]} plugins - * @property {PnpApi | null} pnpApi - * @property {Set} roots - * @property {boolean} fullySpecified - * @property {boolean} resolveToContext - * @property {Set} restrictions - * @property {boolean} preferRelative - * @property {boolean} preferAbsolute - */ - -/** - * @param {PnpApi | null=} option option - * @returns {PnpApi | null} processed option - */ -function processPnpApiOption(option) { - if ( - option === undefined && - /** @type {NodeJS.ProcessVersions & {pnp: string}} */ versions.pnp - ) { - const _findPnpApi = - /** @type {function(string): PnpApi | null}} */ - ( - // @ts-ignore - require("module").findPnpApi - ); - - if (_findPnpApi) { - return { - resolveToUnqualified(request, issuer, opts) { - const pnpapi = _findPnpApi(issuer); - - if (!pnpapi) { - // Issuer isn't managed by PnP - return null; - } - - return pnpapi.resolveToUnqualified(request, issuer, opts); - } - }; - } - } - - return option || null; -} - -/** - * @param {AliasOptions | AliasOptionEntry[] | undefined} alias alias - * @returns {AliasOptionEntry[]} normalized aliases - */ -function normalizeAlias(alias) { - return typeof alias === "object" && !Array.isArray(alias) && alias !== null - ? Object.keys(alias).map(key => { - /** @type {AliasOptionEntry} */ - const obj = { name: key, onlyModule: false, alias: alias[key] }; - - if (/\$$/.test(key)) { - obj.onlyModule = true; - obj.name = key.slice(0, -1); - } - - return obj; - }) - : /** @type {Array} */ (alias) || []; -} - -/** - * @param {UserResolveOptions} options input options - * @returns {ResolveOptions} output options - */ -function createOptions(options) { - const mainFieldsSet = new Set(options.mainFields || ["main"]); - /** @type {ResolveOptions["mainFields"]} */ - const mainFields = []; - - for (const item of mainFieldsSet) { - if (typeof item === "string") { - mainFields.push({ - name: [item], - forceRelative: true - }); - } else if (Array.isArray(item)) { - mainFields.push({ - name: item, - forceRelative: true - }); - } else { - mainFields.push({ - name: Array.isArray(item.name) ? item.name : [item.name], - forceRelative: item.forceRelative - }); - } - } - - return { - alias: normalizeAlias(options.alias), - fallback: normalizeAlias(options.fallback), - aliasFields: new Set(options.aliasFields), - cachePredicate: - options.cachePredicate || - function () { - return true; - }, - cacheWithContext: - typeof options.cacheWithContext !== "undefined" - ? options.cacheWithContext - : true, - exportsFields: new Set(options.exportsFields || ["exports"]), - importsFields: new Set(options.importsFields || ["imports"]), - conditionNames: new Set(options.conditionNames), - descriptionFiles: Array.from( - new Set(options.descriptionFiles || ["package.json"]) - ), - enforceExtension: - options.enforceExtension === undefined - ? options.extensions && options.extensions.includes("") - ? true - : false - : options.enforceExtension, - extensions: new Set(options.extensions || [".js", ".json", ".node"]), - extensionAlias: options.extensionAlias - ? Object.keys(options.extensionAlias).map(k => ({ - extension: k, - alias: /** @type {ExtensionAliasOptions} */ (options.extensionAlias)[ - k - ] - })) - : [], - fileSystem: options.useSyncFileSystemCalls - ? new SyncAsyncFileSystemDecorator( - /** @type {SyncFileSystem} */ ( - /** @type {unknown} */ (options.fileSystem) - ) - ) - : options.fileSystem, - unsafeCache: - options.unsafeCache && typeof options.unsafeCache !== "object" - ? {} - : options.unsafeCache || false, - symlinks: typeof options.symlinks !== "undefined" ? options.symlinks : true, - resolver: options.resolver, - modules: mergeFilteredToArray( - Array.isArray(options.modules) - ? options.modules - : options.modules - ? [options.modules] - : ["node_modules"], - item => { - const type = getType(item); - return type === PathType.Normal || type === PathType.Relative; - } - ), - mainFields, - mainFiles: new Set(options.mainFiles || ["index"]), - plugins: options.plugins || [], - pnpApi: processPnpApiOption(options.pnpApi), - roots: new Set(options.roots || undefined), - fullySpecified: options.fullySpecified || false, - resolveToContext: options.resolveToContext || false, - preferRelative: options.preferRelative || false, - preferAbsolute: options.preferAbsolute || false, - restrictions: new Set(options.restrictions) - }; -} - -/** - * @param {UserResolveOptions} options resolve options - * @returns {Resolver} created resolver - */ -exports.createResolver = function (options) { - const normalizedOptions = createOptions(options); - - const { - alias, - fallback, - aliasFields, - cachePredicate, - cacheWithContext, - conditionNames, - descriptionFiles, - enforceExtension, - exportsFields, - extensionAlias, - importsFields, - extensions, - fileSystem, - fullySpecified, - mainFields, - mainFiles, - modules, - plugins: userPlugins, - pnpApi, - resolveToContext, - preferRelative, - preferAbsolute, - symlinks, - unsafeCache, - resolver: customResolver, - restrictions, - roots - } = normalizedOptions; - - const plugins = userPlugins.slice(); - - const resolver = customResolver - ? customResolver - : new Resolver(fileSystem, normalizedOptions); - - //// pipeline //// - - resolver.ensureHook("resolve"); - resolver.ensureHook("internalResolve"); - resolver.ensureHook("newInternalResolve"); - resolver.ensureHook("parsedResolve"); - resolver.ensureHook("describedResolve"); - resolver.ensureHook("rawResolve"); - resolver.ensureHook("normalResolve"); - resolver.ensureHook("internal"); - resolver.ensureHook("rawModule"); - resolver.ensureHook("alternateRawModule"); - resolver.ensureHook("module"); - resolver.ensureHook("resolveAsModule"); - resolver.ensureHook("undescribedResolveInPackage"); - resolver.ensureHook("resolveInPackage"); - resolver.ensureHook("resolveInExistingDirectory"); - resolver.ensureHook("relative"); - resolver.ensureHook("describedRelative"); - resolver.ensureHook("directory"); - resolver.ensureHook("undescribedExistingDirectory"); - resolver.ensureHook("existingDirectory"); - resolver.ensureHook("undescribedRawFile"); - resolver.ensureHook("rawFile"); - resolver.ensureHook("file"); - resolver.ensureHook("finalFile"); - resolver.ensureHook("existingFile"); - resolver.ensureHook("resolved"); - - // TODO remove in next major - // cspell:word Interal - // Backward-compat - // @ts-ignore - resolver.hooks.newInteralResolve = resolver.hooks.newInternalResolve; - - // resolve - for (const { source, resolveOptions } of [ - { source: "resolve", resolveOptions: { fullySpecified } }, - { source: "internal-resolve", resolveOptions: { fullySpecified: false } } - ]) { - if (unsafeCache) { - plugins.push( - new UnsafeCachePlugin( - source, - cachePredicate, - /** @type {import("./UnsafeCachePlugin").Cache} */ (unsafeCache), - cacheWithContext, - `new-${source}` - ) - ); - plugins.push( - new ParsePlugin(`new-${source}`, resolveOptions, "parsed-resolve") - ); - } else { - plugins.push(new ParsePlugin(source, resolveOptions, "parsed-resolve")); - } - } - - // parsed-resolve - plugins.push( - new DescriptionFilePlugin( - "parsed-resolve", - descriptionFiles, - false, - "described-resolve" - ) - ); - plugins.push(new NextPlugin("after-parsed-resolve", "described-resolve")); - - // described-resolve - plugins.push(new NextPlugin("described-resolve", "raw-resolve")); - if (fallback.length > 0) { - plugins.push( - new AliasPlugin("described-resolve", fallback, "internal-resolve") - ); - } - - // raw-resolve - if (alias.length > 0) { - plugins.push(new AliasPlugin("raw-resolve", alias, "internal-resolve")); - } - aliasFields.forEach(item => { - plugins.push(new AliasFieldPlugin("raw-resolve", item, "internal-resolve")); - }); - extensionAlias.forEach(item => - plugins.push( - new ExtensionAliasPlugin("raw-resolve", item, "normal-resolve") - ) - ); - plugins.push(new NextPlugin("raw-resolve", "normal-resolve")); - - // normal-resolve - if (preferRelative) { - plugins.push(new JoinRequestPlugin("after-normal-resolve", "relative")); - } - plugins.push( - new ConditionalPlugin( - "after-normal-resolve", - { module: true }, - "resolve as module", - false, - "raw-module" - ) - ); - plugins.push( - new ConditionalPlugin( - "after-normal-resolve", - { internal: true }, - "resolve as internal import", - false, - "internal" - ) - ); - if (preferAbsolute) { - plugins.push(new JoinRequestPlugin("after-normal-resolve", "relative")); - } - if (roots.size > 0) { - plugins.push(new RootsPlugin("after-normal-resolve", roots, "relative")); - } - if (!preferRelative && !preferAbsolute) { - plugins.push(new JoinRequestPlugin("after-normal-resolve", "relative")); - } - - // internal - importsFields.forEach(importsField => { - plugins.push( - new ImportsFieldPlugin( - "internal", - conditionNames, - importsField, - "relative", - "internal-resolve" - ) - ); - }); - - // raw-module - exportsFields.forEach(exportsField => { - plugins.push( - new SelfReferencePlugin("raw-module", exportsField, "resolve-as-module") - ); - }); - modules.forEach(item => { - if (Array.isArray(item)) { - if (item.includes("node_modules") && pnpApi) { - plugins.push( - new ModulesInHierarchicalDirectoriesPlugin( - "raw-module", - item.filter(i => i !== "node_modules"), - "module" - ) - ); - plugins.push( - new PnpPlugin( - "raw-module", - pnpApi, - "undescribed-resolve-in-package", - "alternate-raw-module" - ) - ); - - plugins.push( - new ModulesInHierarchicalDirectoriesPlugin( - "alternate-raw-module", - ["node_modules"], - "module" - ) - ); - } else { - plugins.push( - new ModulesInHierarchicalDirectoriesPlugin( - "raw-module", - item, - "module" - ) - ); - } - } else { - plugins.push(new ModulesInRootPlugin("raw-module", item, "module")); - } - }); - - // module - plugins.push(new JoinRequestPartPlugin("module", "resolve-as-module")); - - // resolve-as-module - if (!resolveToContext) { - plugins.push( - new ConditionalPlugin( - "resolve-as-module", - { directory: false, request: "." }, - "single file module", - true, - "undescribed-raw-file" - ) - ); - } - plugins.push( - new DirectoryExistsPlugin( - "resolve-as-module", - "undescribed-resolve-in-package" - ) - ); - - // undescribed-resolve-in-package - plugins.push( - new DescriptionFilePlugin( - "undescribed-resolve-in-package", - descriptionFiles, - false, - "resolve-in-package" - ) - ); - plugins.push( - new NextPlugin("after-undescribed-resolve-in-package", "resolve-in-package") - ); - - // resolve-in-package - exportsFields.forEach(exportsField => { - plugins.push( - new ExportsFieldPlugin( - "resolve-in-package", - conditionNames, - exportsField, - "relative" - ) - ); - }); - plugins.push( - new NextPlugin("resolve-in-package", "resolve-in-existing-directory") - ); - - // resolve-in-existing-directory - plugins.push( - new JoinRequestPlugin("resolve-in-existing-directory", "relative") - ); - - // relative - plugins.push( - new DescriptionFilePlugin( - "relative", - descriptionFiles, - true, - "described-relative" - ) - ); - plugins.push(new NextPlugin("after-relative", "described-relative")); - - // described-relative - if (resolveToContext) { - plugins.push(new NextPlugin("described-relative", "directory")); - } else { - plugins.push( - new ConditionalPlugin( - "described-relative", - { directory: false }, - null, - true, - "raw-file" - ) - ); - plugins.push( - new ConditionalPlugin( - "described-relative", - { fullySpecified: false }, - "as directory", - true, - "directory" - ) - ); - } - - // directory - plugins.push( - new DirectoryExistsPlugin("directory", "undescribed-existing-directory") - ); - - if (resolveToContext) { - // undescribed-existing-directory - plugins.push(new NextPlugin("undescribed-existing-directory", "resolved")); - } else { - // undescribed-existing-directory - plugins.push( - new DescriptionFilePlugin( - "undescribed-existing-directory", - descriptionFiles, - false, - "existing-directory" - ) - ); - mainFiles.forEach(item => { - plugins.push( - new UseFilePlugin( - "undescribed-existing-directory", - item, - "undescribed-raw-file" - ) - ); - }); - - // described-existing-directory - mainFields.forEach(item => { - plugins.push( - new MainFieldPlugin( - "existing-directory", - item, - "resolve-in-existing-directory" - ) - ); - }); - mainFiles.forEach(item => { - plugins.push( - new UseFilePlugin("existing-directory", item, "undescribed-raw-file") - ); - }); - - // undescribed-raw-file - plugins.push( - new DescriptionFilePlugin( - "undescribed-raw-file", - descriptionFiles, - true, - "raw-file" - ) - ); - plugins.push(new NextPlugin("after-undescribed-raw-file", "raw-file")); - - // raw-file - plugins.push( - new ConditionalPlugin( - "raw-file", - { fullySpecified: true }, - null, - false, - "file" - ) - ); - if (!enforceExtension) { - plugins.push(new TryNextPlugin("raw-file", "no extension", "file")); - } - extensions.forEach(item => { - plugins.push(new AppendPlugin("raw-file", item, "file")); - }); - - // file - if (alias.length > 0) - plugins.push(new AliasPlugin("file", alias, "internal-resolve")); - aliasFields.forEach(item => { - plugins.push(new AliasFieldPlugin("file", item, "internal-resolve")); - }); - plugins.push(new NextPlugin("file", "final-file")); - - // final-file - plugins.push(new FileExistsPlugin("final-file", "existing-file")); - - // existing-file - if (symlinks) - plugins.push(new SymlinkPlugin("existing-file", "existing-file")); - plugins.push(new NextPlugin("existing-file", "resolved")); - } - - const resolved = - /** @type {KnownHooks & EnsuredHooks} */ - (resolver.hooks).resolved; - - // resolved - if (restrictions.size > 0) { - plugins.push(new RestrictionsPlugin(resolved, restrictions)); - } - - plugins.push(new ResultPlugin(resolved)); - - //// RESOLVER //// - - for (const plugin of plugins) { - if (typeof plugin === "function") { - /** @type {function(this: Resolver, Resolver): void} */ - (plugin).call(resolver, resolver); - } else if (plugin) { - plugin.apply(resolver); - } - } - - return resolver; -}; - -/** - * Merging filtered elements - * @param {string[]} array source array - * @param {function(string): boolean} filter predicate - * @returns {Array} merge result - */ -function mergeFilteredToArray(array, filter) { - /** @type {Array} */ - const result = []; - const set = new Set(array); - - for (const item of set) { - if (filter(item)) { - const lastElement = - result.length > 0 ? result[result.length - 1] : undefined; - if (Array.isArray(lastElement)) { - lastElement.push(item); - } else { - result.push([item]); - } - } else { - result.push(item); - } - } - - return result; -} diff --git a/node_modules/enhanced-resolve/lib/RestrictionsPlugin.js b/node_modules/enhanced-resolve/lib/RestrictionsPlugin.js deleted file mode 100644 index e52ca9d5b2..0000000000 --- a/node_modules/enhanced-resolve/lib/RestrictionsPlugin.js +++ /dev/null @@ -1,70 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Ivan Kopeykin @vankop -*/ - -"use strict"; - -/** @typedef {import("./Resolver")} Resolver */ -/** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */ - -const slashCode = "/".charCodeAt(0); -const backslashCode = "\\".charCodeAt(0); - -/** - * @param {string} path path - * @param {string} parent parent path - * @returns {boolean} true, if path is inside of parent - */ -const isInside = (path, parent) => { - if (!path.startsWith(parent)) return false; - if (path.length === parent.length) return true; - const charCode = path.charCodeAt(parent.length); - return charCode === slashCode || charCode === backslashCode; -}; - -module.exports = class RestrictionsPlugin { - /** - * @param {string | ResolveStepHook} source source - * @param {Set} restrictions restrictions - */ - constructor(source, restrictions) { - this.source = source; - this.restrictions = restrictions; - } - - /** - * @param {Resolver} resolver the resolver - * @returns {void} - */ - apply(resolver) { - resolver - .getHook(this.source) - .tapAsync("RestrictionsPlugin", (request, resolveContext, callback) => { - if (typeof request.path === "string") { - const path = request.path; - for (const rule of this.restrictions) { - if (typeof rule === "string") { - if (!isInside(path, rule)) { - if (resolveContext.log) { - resolveContext.log( - `${path} is not inside of the restriction ${rule}` - ); - } - return callback(null, null); - } - } else if (!rule.test(path)) { - if (resolveContext.log) { - resolveContext.log( - `${path} doesn't match the restriction ${rule}` - ); - } - return callback(null, null); - } - } - } - - callback(); - }); - } -}; diff --git a/node_modules/enhanced-resolve/lib/ResultPlugin.js b/node_modules/enhanced-resolve/lib/ResultPlugin.js deleted file mode 100644 index e25c43fe77..0000000000 --- a/node_modules/enhanced-resolve/lib/ResultPlugin.js +++ /dev/null @@ -1,42 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -/** @typedef {import("./Resolver")} Resolver */ -/** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */ - -module.exports = class ResultPlugin { - /** - * @param {ResolveStepHook} source source - */ - constructor(source) { - this.source = source; - } - - /** - * @param {Resolver} resolver the resolver - * @returns {void} - */ - apply(resolver) { - this.source.tapAsync( - "ResultPlugin", - (request, resolverContext, callback) => { - const obj = { ...request }; - if (resolverContext.log) - resolverContext.log("reporting result " + obj.path); - resolver.hooks.result.callAsync(obj, resolverContext, err => { - if (err) return callback(err); - if (typeof resolverContext.yield === "function") { - resolverContext.yield(obj); - callback(null, null); - } else { - callback(null, obj); - } - }); - } - ); - } -}; diff --git a/node_modules/enhanced-resolve/lib/RootsPlugin.js b/node_modules/enhanced-resolve/lib/RootsPlugin.js deleted file mode 100644 index 1d299113ce..0000000000 --- a/node_modules/enhanced-resolve/lib/RootsPlugin.js +++ /dev/null @@ -1,69 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Ivan Kopeykin @vankop -*/ - -"use strict"; - -const forEachBail = require("./forEachBail"); - -/** @typedef {import("./Resolver")} Resolver */ -/** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */ -/** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */ - -class RootsPlugin { - /** - * @param {string | ResolveStepHook} source source hook - * @param {Set} roots roots - * @param {string | ResolveStepHook} target target hook - */ - constructor(source, roots, target) { - this.roots = Array.from(roots); - this.source = source; - this.target = target; - } - - /** - * @param {Resolver} resolver the resolver - * @returns {void} - */ - apply(resolver) { - const target = resolver.ensureHook(this.target); - - resolver - .getHook(this.source) - .tapAsync("RootsPlugin", (request, resolveContext, callback) => { - const req = request.request; - if (!req) return callback(); - if (!req.startsWith("/")) return callback(); - - forEachBail( - this.roots, - /** - * @param {string} root root - * @param {(err?: null|Error, result?: null|ResolveRequest) => void} callback callback - * @returns {void} - */ - (root, callback) => { - const path = resolver.join(root, req.slice(1)); - /** @type {ResolveRequest} */ - const obj = { - ...request, - path, - relativePath: request.relativePath && path - }; - resolver.doResolve( - target, - obj, - `root path ${root}`, - resolveContext, - callback - ); - }, - callback - ); - }); - } -} - -module.exports = RootsPlugin; diff --git a/node_modules/enhanced-resolve/lib/SelfReferencePlugin.js b/node_modules/enhanced-resolve/lib/SelfReferencePlugin.js deleted file mode 100644 index a8dc1484b6..0000000000 --- a/node_modules/enhanced-resolve/lib/SelfReferencePlugin.js +++ /dev/null @@ -1,82 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -const DescriptionFileUtils = require("./DescriptionFileUtils"); - -/** @typedef {import("./Resolver")} Resolver */ -/** @typedef {import("./Resolver").JsonObject} JsonObject */ -/** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */ -/** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */ - -const slashCode = "/".charCodeAt(0); - -module.exports = class SelfReferencePlugin { - /** - * @param {string | ResolveStepHook} source source - * @param {string | string[]} fieldNamePath name path - * @param {string | ResolveStepHook} target target - */ - constructor(source, fieldNamePath, target) { - this.source = source; - this.target = target; - this.fieldName = fieldNamePath; - } - - /** - * @param {Resolver} resolver the resolver - * @returns {void} - */ - apply(resolver) { - const target = resolver.ensureHook(this.target); - resolver - .getHook(this.source) - .tapAsync("SelfReferencePlugin", (request, resolveContext, callback) => { - if (!request.descriptionFilePath) return callback(); - - const req = request.request; - if (!req) return callback(); - - // Feature is only enabled when an exports field is present - const exportsField = DescriptionFileUtils.getField( - /** @type {JsonObject} */ (request.descriptionFileData), - this.fieldName - ); - if (!exportsField) return callback(); - - const name = DescriptionFileUtils.getField( - /** @type {JsonObject} */ (request.descriptionFileData), - "name" - ); - if (typeof name !== "string") return callback(); - - if ( - req.startsWith(name) && - (req.length === name.length || - req.charCodeAt(name.length) === slashCode) - ) { - const remainingRequest = `.${req.slice(name.length)}`; - /** @type {ResolveRequest} */ - const obj = { - ...request, - request: remainingRequest, - path: /** @type {string} */ (request.descriptionFileRoot), - relativePath: "." - }; - - resolver.doResolve( - target, - obj, - "self reference", - resolveContext, - callback - ); - } else { - return callback(); - } - }); - } -}; diff --git a/node_modules/enhanced-resolve/lib/SymlinkPlugin.js b/node_modules/enhanced-resolve/lib/SymlinkPlugin.js deleted file mode 100644 index 7adab54844..0000000000 --- a/node_modules/enhanced-resolve/lib/SymlinkPlugin.js +++ /dev/null @@ -1,100 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -const forEachBail = require("./forEachBail"); -const getPaths = require("./getPaths"); -const { getType, PathType } = require("./util/path"); - -/** @typedef {import("./Resolver")} Resolver */ -/** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */ -/** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */ - -module.exports = class SymlinkPlugin { - /** - * @param {string | ResolveStepHook} source source - * @param {string | ResolveStepHook} target target - */ - constructor(source, target) { - this.source = source; - this.target = target; - } - - /** - * @param {Resolver} resolver the resolver - * @returns {void} - */ - apply(resolver) { - const target = resolver.ensureHook(this.target); - const fs = resolver.fileSystem; - resolver - .getHook(this.source) - .tapAsync("SymlinkPlugin", (request, resolveContext, callback) => { - if (request.ignoreSymlinks) return callback(); - const pathsResult = getPaths(/** @type {string} */ (request.path)); - const pathSegments = pathsResult.segments; - const paths = pathsResult.paths; - - let containsSymlink = false; - let idx = -1; - forEachBail( - paths, - /** - * @param {string} path path - * @param {(err?: null|Error, result?: null|number) => void} callback callback - * @returns {void} - */ - (path, callback) => { - idx++; - if (resolveContext.fileDependencies) - resolveContext.fileDependencies.add(path); - fs.readlink(path, (err, result) => { - if (!err && result) { - pathSegments[idx] = /** @type {string} */ (result); - containsSymlink = true; - // Shortcut when absolute symlink found - const resultType = getType(result.toString()); - if ( - resultType === PathType.AbsoluteWin || - resultType === PathType.AbsolutePosix - ) { - return callback(null, idx); - } - } - callback(); - }); - }, - /** - * @param {null|Error} [err] error - * @param {null|number} [idx] result - * @returns {void} - */ - (err, idx) => { - if (!containsSymlink) return callback(); - const resultSegments = - typeof idx === "number" - ? pathSegments.slice(0, idx + 1) - : pathSegments.slice(); - const result = resultSegments.reduceRight((a, b) => { - return resolver.join(a, b); - }); - /** @type {ResolveRequest} */ - const obj = { - ...request, - path: result - }; - resolver.doResolve( - target, - obj, - "resolved symlink to " + result, - resolveContext, - callback - ); - } - ); - }); - } -}; diff --git a/node_modules/enhanced-resolve/lib/SyncAsyncFileSystemDecorator.js b/node_modules/enhanced-resolve/lib/SyncAsyncFileSystemDecorator.js deleted file mode 100644 index d1f1814ee3..0000000000 --- a/node_modules/enhanced-resolve/lib/SyncAsyncFileSystemDecorator.js +++ /dev/null @@ -1,220 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -/** @typedef {import("./Resolver").FileSystem} FileSystem */ -/** @typedef {import("./Resolver").ReaddirStringCallback} ReaddirStringCallback */ -/** @typedef {import("./Resolver").StringCallback} StringCallback */ -/** @typedef {import("./Resolver").SyncFileSystem} SyncFileSystem */ - -/** - * @param {SyncFileSystem} fs file system implementation - * @constructor - */ -function SyncAsyncFileSystemDecorator(fs) { - this.fs = fs; - - this.lstat = undefined; - this.lstatSync = undefined; - const lstatSync = fs.lstatSync; - if (lstatSync) { - this.lstat = - /** @type {FileSystem["lstat"]} */ - ( - (arg, options, callback) => { - let result; - try { - result = /** @type {Function | undefined} */ (callback) - ? lstatSync.call(fs, arg, options) - : lstatSync.call(fs, arg); - } catch (e) { - return (callback || options)( - /** @type {NodeJS.ErrnoException | null} */ (e) - ); - } - - (callback || options)(null, /** @type {any} */ (result)); - } - ); - this.lstatSync = - /** @type {SyncFileSystem["lstatSync"]} */ - ((arg, options) => lstatSync.call(fs, arg, options)); - } - - this.stat = - /** @type {FileSystem["stat"]} */ - ( - (arg, options, callback) => { - let result; - try { - result = /** @type {Function | undefined} */ (callback) - ? fs.statSync(arg, options) - : fs.statSync(arg); - } catch (e) { - return (callback || options)( - /** @type {NodeJS.ErrnoException | null} */ (e) - ); - } - - (callback || options)(null, /** @type {any} */ (result)); - } - ); - this.statSync = - /** @type {SyncFileSystem["statSync"]} */ - ((arg, options) => fs.statSync(arg, options)); - - this.readdir = - /** @type {FileSystem["readdir"]} */ - ( - (arg, options, callback) => { - let result; - try { - result = /** @type {Function | undefined} */ (callback) - ? fs.readdirSync( - arg, - /** @type {Exclude[1], ReaddirStringCallback>} */ - (options) - ) - : fs.readdirSync(arg); - } catch (e) { - return (callback || options)( - /** @type {NodeJS.ErrnoException | null} */ (e) - ); - } - - (callback || options)(null, /** @type {any} */ (result)); - } - ); - this.readdirSync = - /** @type {SyncFileSystem["readdirSync"]} */ - ( - (arg, options) => - fs.readdirSync( - arg, - /** @type {Parameters[1]} */ (options) - ) - ); - - this.readFile = - /** @type {FileSystem["readFile"]} */ - ( - (arg, options, callback) => { - let result; - try { - result = /** @type {Function | undefined} */ (callback) - ? fs.readFileSync(arg, options) - : fs.readFileSync(arg); - } catch (e) { - return (callback || options)( - /** @type {NodeJS.ErrnoException | null} */ (e) - ); - } - - (callback || options)(null, /** @type {any} */ (result)); - } - ); - this.readFileSync = - /** @type {SyncFileSystem["readFileSync"]} */ - ((arg, options) => fs.readFileSync(arg, options)); - - this.readlink = - /** @type {FileSystem["readlink"]} */ - ( - (arg, options, callback) => { - let result; - try { - result = /** @type {Function | undefined} */ (callback) - ? fs.readlinkSync( - arg, - /** @type {Exclude[1], StringCallback>} */ - (options) - ) - : fs.readlinkSync(arg); - } catch (e) { - return (callback || options)( - /** @type {NodeJS.ErrnoException | null} */ (e) - ); - } - - (callback || options)(null, /** @type {any} */ (result)); - } - ); - this.readlinkSync = - /** @type {SyncFileSystem["readlinkSync"]} */ - ( - (arg, options) => - fs.readlinkSync( - arg, - /** @type {Parameters[1]} */ (options) - ) - ); - - this.readJson = undefined; - this.readJsonSync = undefined; - const readJsonSync = fs.readJsonSync; - if (readJsonSync) { - this.readJson = - /** @type {FileSystem["readJson"]} */ - ( - (arg, callback) => { - let result; - try { - result = readJsonSync.call(fs, arg); - } catch (e) { - return callback( - /** @type {NodeJS.ErrnoException | Error | null} */ (e) - ); - } - - callback(null, result); - } - ); - this.readJsonSync = - /** @type {SyncFileSystem["readJsonSync"]} */ - (arg => readJsonSync.call(fs, arg)); - } - - this.realpath = undefined; - this.realpathSync = undefined; - const realpathSync = fs.realpathSync; - if (realpathSync) { - this.realpath = - /** @type {FileSystem["realpath"]} */ - ( - (arg, options, callback) => { - let result; - try { - result = /** @type {Function | undefined} */ (callback) - ? realpathSync.call( - fs, - arg, - /** @type {Exclude>[1], StringCallback>} */ - (options) - ) - : realpathSync.call(fs, arg); - } catch (e) { - return (callback || options)( - /** @type {NodeJS.ErrnoException | null} */ (e) - ); - } - - (callback || options)(null, /** @type {any} */ (result)); - } - ); - this.realpathSync = - /** @type {SyncFileSystem["realpathSync"]} */ - ( - (arg, options) => - realpathSync.call( - fs, - arg, - /** @type {Parameters>[1]} */ - (options) - ) - ); - } -} -module.exports = SyncAsyncFileSystemDecorator; diff --git a/node_modules/enhanced-resolve/lib/TryNextPlugin.js b/node_modules/enhanced-resolve/lib/TryNextPlugin.js deleted file mode 100644 index 1b70bef072..0000000000 --- a/node_modules/enhanced-resolve/lib/TryNextPlugin.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -/** @typedef {import("./Resolver")} Resolver */ -/** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */ - -module.exports = class TryNextPlugin { - /** - * @param {string | ResolveStepHook} source source - * @param {string} message message - * @param {string | ResolveStepHook} target target - */ - constructor(source, message, target) { - this.source = source; - this.message = message; - this.target = target; - } - - /** - * @param {Resolver} resolver the resolver - * @returns {void} - */ - apply(resolver) { - const target = resolver.ensureHook(this.target); - resolver - .getHook(this.source) - .tapAsync("TryNextPlugin", (request, resolveContext, callback) => { - resolver.doResolve( - target, - request, - this.message, - resolveContext, - callback - ); - }); - } -}; diff --git a/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js b/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js deleted file mode 100644 index e6c01498e9..0000000000 --- a/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js +++ /dev/null @@ -1,112 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -/** @typedef {import("./Resolver")} Resolver */ -/** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */ -/** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */ -/** @typedef {import("./Resolver").ResolveContextYield} ResolveContextYield */ -/** @typedef {{[k: string]: ResolveRequest | ResolveRequest[] | undefined}} Cache */ - -/** - * @param {string} type type of cache - * @param {ResolveRequest} request request - * @param {boolean} withContext cache with context? - * @returns {string} cache id - */ -function getCacheId(type, request, withContext) { - return JSON.stringify({ - type, - context: withContext ? request.context : "", - path: request.path, - query: request.query, - fragment: request.fragment, - request: request.request - }); -} - -module.exports = class UnsafeCachePlugin { - /** - * @param {string | ResolveStepHook} source source - * @param {function(ResolveRequest): boolean} filterPredicate filterPredicate - * @param {Cache} cache cache - * @param {boolean} withContext withContext - * @param {string | ResolveStepHook} target target - */ - constructor(source, filterPredicate, cache, withContext, target) { - this.source = source; - this.filterPredicate = filterPredicate; - this.withContext = withContext; - this.cache = cache; - this.target = target; - } - - /** - * @param {Resolver} resolver the resolver - * @returns {void} - */ - apply(resolver) { - const target = resolver.ensureHook(this.target); - resolver - .getHook(this.source) - .tapAsync("UnsafeCachePlugin", (request, resolveContext, callback) => { - if (!this.filterPredicate(request)) return callback(); - const isYield = typeof resolveContext.yield === "function"; - const cacheId = getCacheId( - isYield ? "yield" : "default", - request, - this.withContext - ); - const cacheEntry = this.cache[cacheId]; - if (cacheEntry) { - if (isYield) { - const yield_ = /** @type {Function} */ (resolveContext.yield); - if (Array.isArray(cacheEntry)) { - for (const result of cacheEntry) yield_(result); - } else { - yield_(cacheEntry); - } - return callback(null, null); - } - return callback(null, /** @type {ResolveRequest} */ (cacheEntry)); - } - - /** @type {ResolveContextYield|undefined} */ - let yieldFn; - /** @type {ResolveContextYield|undefined} */ - let yield_; - /** @type {ResolveRequest[]} */ - const yieldResult = []; - if (isYield) { - yieldFn = resolveContext.yield; - yield_ = result => { - yieldResult.push(result); - }; - } - - resolver.doResolve( - target, - request, - null, - yield_ ? { ...resolveContext, yield: yield_ } : resolveContext, - (err, result) => { - if (err) return callback(err); - if (isYield) { - if (result) yieldResult.push(result); - for (const result of yieldResult) { - /** @type {ResolveContextYield} */ - (yieldFn)(result); - } - this.cache[cacheId] = yieldResult; - return callback(null, null); - } - if (result) return callback(null, (this.cache[cacheId] = result)); - callback(); - } - ); - }); - } -}; diff --git a/node_modules/enhanced-resolve/lib/UseFilePlugin.js b/node_modules/enhanced-resolve/lib/UseFilePlugin.js deleted file mode 100644 index 14aebdd486..0000000000 --- a/node_modules/enhanced-resolve/lib/UseFilePlugin.js +++ /dev/null @@ -1,55 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -/** @typedef {import("./Resolver")} Resolver */ -/** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */ -/** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */ - -module.exports = class UseFilePlugin { - /** - * @param {string | ResolveStepHook} source source - * @param {string} filename filename - * @param {string | ResolveStepHook} target target - */ - constructor(source, filename, target) { - this.source = source; - this.filename = filename; - this.target = target; - } - - /** - * @param {Resolver} resolver the resolver - * @returns {void} - */ - apply(resolver) { - const target = resolver.ensureHook(this.target); - resolver - .getHook(this.source) - .tapAsync("UseFilePlugin", (request, resolveContext, callback) => { - const filePath = resolver.join( - /** @type {string} */ (request.path), - this.filename - ); - - /** @type {ResolveRequest} */ - const obj = { - ...request, - path: filePath, - relativePath: - request.relativePath && - resolver.join(request.relativePath, this.filename) - }; - resolver.doResolve( - target, - obj, - "using path: " + filePath, - resolveContext, - callback - ); - }); - } -}; diff --git a/node_modules/enhanced-resolve/lib/createInnerContext.js b/node_modules/enhanced-resolve/lib/createInnerContext.js deleted file mode 100644 index 88c7a58e03..0000000000 --- a/node_modules/enhanced-resolve/lib/createInnerContext.js +++ /dev/null @@ -1,46 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -/** @typedef {import("./Resolver").ResolveContext} ResolveContext */ - -/** - * @param {ResolveContext} options options for inner context - * @param {null|string} message message to log - * @returns {ResolveContext} inner context - */ -module.exports = function createInnerContext(options, message) { - let messageReported = false; - let innerLog = undefined; - if (options.log) { - if (message) { - /** - * @param {string} msg message - */ - innerLog = msg => { - if (!messageReported) { - /** @type {(function(string): void)} */ - (options.log)(message); - messageReported = true; - } - - /** @type {(function(string): void)} */ - (options.log)(" " + msg); - }; - } else { - innerLog = options.log; - } - } - - return { - log: innerLog, - yield: options.yield, - fileDependencies: options.fileDependencies, - contextDependencies: options.contextDependencies, - missingDependencies: options.missingDependencies, - stack: options.stack - }; -}; diff --git a/node_modules/enhanced-resolve/lib/forEachBail.js b/node_modules/enhanced-resolve/lib/forEachBail.js deleted file mode 100644 index 32a7250aa1..0000000000 --- a/node_modules/enhanced-resolve/lib/forEachBail.js +++ /dev/null @@ -1,50 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -/** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */ - -/** - * @template T - * @template Z - * @callback Iterator - * @param {T} item item - * @param {(err?: null|Error, result?: null|Z) => void} callback callback - * @param {number} i index - * @returns {void} - */ - -/** - * @template T - * @template Z - * @param {T[]} array array - * @param {Iterator} iterator iterator - * @param {(err?: null|Error, result?: null|Z, i?: number) => void} callback callback after all items are iterated - * @returns {void} - */ -module.exports = function forEachBail(array, iterator, callback) { - if (array.length === 0) return callback(); - - let i = 0; - const next = () => { - /** @type {boolean|undefined} */ - let loop = undefined; - iterator( - array[i++], - (err, result) => { - if (err || result !== undefined || i >= array.length) { - return callback(err, result, i); - } - if (loop === false) while (next()); - loop = true; - }, - i - ); - if (!loop) loop = false; - return loop; - }; - while (next()); -}; diff --git a/node_modules/enhanced-resolve/lib/getInnerRequest.js b/node_modules/enhanced-resolve/lib/getInnerRequest.js deleted file mode 100644 index c34c10f21e..0000000000 --- a/node_modules/enhanced-resolve/lib/getInnerRequest.js +++ /dev/null @@ -1,36 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -/** @typedef {import("./Resolver")} Resolver */ -/** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */ - -/** - * @param {Resolver} resolver resolver - * @param {ResolveRequest} request string - * @returns {string} inner request - */ -module.exports = function getInnerRequest(resolver, request) { - if ( - typeof request.__innerRequest === "string" && - request.__innerRequest_request === request.request && - request.__innerRequest_relativePath === request.relativePath - ) - return request.__innerRequest; - /** @type {string|undefined} */ - let innerRequest; - if (request.request) { - innerRequest = request.request; - if (/^\.\.?(?:\/|$)/.test(innerRequest) && request.relativePath) { - innerRequest = resolver.join(request.relativePath, innerRequest); - } - } else { - innerRequest = request.relativePath; - } - request.__innerRequest_request = request.request; - request.__innerRequest_relativePath = request.relativePath; - return (request.__innerRequest = /** @type {string} */ (innerRequest)); -}; diff --git a/node_modules/enhanced-resolve/lib/getPaths.js b/node_modules/enhanced-resolve/lib/getPaths.js deleted file mode 100644 index d5835b0d06..0000000000 --- a/node_modules/enhanced-resolve/lib/getPaths.js +++ /dev/null @@ -1,45 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -/** - * @param {string} path path - * @returns {{paths: string[], segments: string[]}}} paths and segments - */ -module.exports = function getPaths(path) { - if (path === "/") return { paths: ["/"], segments: [""] }; - const parts = path.split(/(.*?[\\/]+)/); - const paths = [path]; - const segments = [parts[parts.length - 1]]; - let part = parts[parts.length - 1]; - path = path.substring(0, path.length - part.length - 1); - for (let i = parts.length - 2; i > 2; i -= 2) { - paths.push(path); - part = parts[i]; - path = path.substring(0, path.length - part.length) || "/"; - segments.push(part.slice(0, -1)); - } - part = parts[1]; - segments.push(part); - paths.push(part); - return { - paths: paths, - segments: segments - }; -}; - -/** - * @param {string} path path - * @returns {string|null} basename or null - */ -module.exports.basename = function basename(path) { - const i = path.lastIndexOf("/"), - j = path.lastIndexOf("\\"); - const p = i < 0 ? j : j < 0 ? i : i < j ? j : i; - if (p < 0) return null; - const s = path.slice(p + 1); - return s; -}; diff --git a/node_modules/enhanced-resolve/lib/index.js b/node_modules/enhanced-resolve/lib/index.js deleted file mode 100644 index ab02cfa256..0000000000 --- a/node_modules/enhanced-resolve/lib/index.js +++ /dev/null @@ -1,203 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -const fs = require("graceful-fs"); -const CachedInputFileSystem = require("./CachedInputFileSystem"); -const ResolverFactory = require("./ResolverFactory"); - -/** @typedef {import("./PnpPlugin").PnpApiImpl} PnpApi */ -/** @typedef {import("./Resolver")} Resolver */ -/** @typedef {import("./Resolver").FileSystem} FileSystem */ -/** @typedef {import("./Resolver").ResolveCallback} ResolveCallback */ -/** @typedef {import("./Resolver").ResolveContext} ResolveContext */ -/** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */ -/** @typedef {import("./ResolverFactory").Plugin} Plugin */ -/** @typedef {import("./ResolverFactory").UserResolveOptions} ResolveOptions */ -/** @typedef {{ - * (context: object, path: string, request: string, resolveContext: ResolveContext, callback: ResolveCallback): void; - * (context: object, path: string, request: string, callback: ResolveCallback): void; - * (path: string, request: string, resolveContext: ResolveContext, callback: ResolveCallback): void; - * (path: string, request: string, callback: ResolveCallback): void; - * }} ResolveFunctionAsync - */ -/** @typedef {{ - * (context: object, path: string, request: string): string|false; - * (path: string, request: string): string|false; - * }} ResolveFunction - */ - -const nodeFileSystem = new CachedInputFileSystem(fs, 4000); - -const nodeContext = { - environments: ["node+es3+es5+process+native"] -}; - -const asyncResolver = ResolverFactory.createResolver({ - conditionNames: ["node"], - extensions: [".js", ".json", ".node"], - fileSystem: nodeFileSystem -}); - -/** - * @type {ResolveFunctionAsync} - */ -const resolve = - /** - * @param {object|string} context - * @param {string} path - * @param {string|ResolveContext|ResolveCallback} request - * @param {ResolveContext|ResolveCallback=} resolveContext - * @param {ResolveCallback=} callback - */ - (context, path, request, resolveContext, callback) => { - if (typeof context === "string") { - callback = /** @type {ResolveCallback} */ (resolveContext); - resolveContext = /** @type {ResolveContext} */ (request); - request = path; - path = context; - context = nodeContext; - } - if (typeof callback !== "function") { - callback = /** @type {ResolveCallback} */ (resolveContext); - } - asyncResolver.resolve( - context, - path, - /** @type {string} */ (request), - /** @type {ResolveContext} */ (resolveContext), - /** @type {ResolveCallback} */ (callback) - ); - }; - -const syncResolver = ResolverFactory.createResolver({ - conditionNames: ["node"], - extensions: [".js", ".json", ".node"], - useSyncFileSystemCalls: true, - fileSystem: nodeFileSystem -}); - -/** - * @type {ResolveFunction} - */ -const resolveSync = - /** - * @param {object|string} context - * @param {string} path - * @param {string=} request - */ - (context, path, request) => { - if (typeof context === "string") { - request = path; - path = context; - context = nodeContext; - } - return syncResolver.resolveSync( - context, - path, - /** @type {string} */ (request) - ); - }; - -/** @typedef {Omit & Partial>} ResolveOptionsOptionalFS */ - -/** - * @param {ResolveOptionsOptionalFS} options Resolver options - * @returns {ResolveFunctionAsync} Resolver function - */ -function create(options) { - const resolver = ResolverFactory.createResolver({ - fileSystem: nodeFileSystem, - ...options - }); - /** - * @param {object|string} context Custom context - * @param {string} path Base path - * @param {string|ResolveContext|ResolveCallback} request String to resolve - * @param {ResolveContext|ResolveCallback=} resolveContext Resolve context - * @param {ResolveCallback=} callback Result callback - */ - return function (context, path, request, resolveContext, callback) { - if (typeof context === "string") { - callback = /** @type {ResolveCallback} */ (resolveContext); - resolveContext = /** @type {ResolveContext} */ (request); - request = path; - path = context; - context = nodeContext; - } - if (typeof callback !== "function") { - callback = /** @type {ResolveCallback} */ (resolveContext); - } - resolver.resolve( - context, - path, - /** @type {string} */ (request), - /** @type {ResolveContext} */ (resolveContext), - callback - ); - }; -} - -/** - * @param {ResolveOptionsOptionalFS} options Resolver options - * @returns {ResolveFunction} Resolver function - */ -function createSync(options) { - const resolver = ResolverFactory.createResolver({ - useSyncFileSystemCalls: true, - fileSystem: nodeFileSystem, - ...options - }); - /** - * @param {object|string} context custom context - * @param {string} path base path - * @param {string=} request request to resolve - * @returns {string|false} Resolved path or false - */ - return function (context, path, request) { - if (typeof context === "string") { - request = path; - path = context; - context = nodeContext; - } - return resolver.resolveSync(context, path, /** @type {string} */ (request)); - }; -} - -/** - * @template A - * @template B - * @param {A} obj input a - * @param {B} exports input b - * @returns {A & B} merged - */ -const mergeExports = (obj, exports) => { - const descriptors = Object.getOwnPropertyDescriptors(exports); - Object.defineProperties(obj, descriptors); - return /** @type {A & B} */ (Object.freeze(obj)); -}; - -module.exports = mergeExports(resolve, { - get sync() { - return resolveSync; - }, - create: mergeExports(create, { - get sync() { - return createSync; - } - }), - ResolverFactory, - CachedInputFileSystem, - get CloneBasenamePlugin() { - return require("./CloneBasenamePlugin"); - }, - get LogInfoPlugin() { - return require("./LogInfoPlugin"); - }, - get forEachBail() { - return require("./forEachBail"); - } -}); diff --git a/node_modules/enhanced-resolve/lib/util/entrypoints.js b/node_modules/enhanced-resolve/lib/util/entrypoints.js deleted file mode 100644 index 683a8e8029..0000000000 --- a/node_modules/enhanced-resolve/lib/util/entrypoints.js +++ /dev/null @@ -1,573 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Ivan Kopeykin @vankop -*/ - -"use strict"; - -/** @typedef {string|(string|ConditionalMapping)[]} DirectMapping */ -/** @typedef {{[k: string]: MappingValue}} ConditionalMapping */ -/** @typedef {ConditionalMapping|DirectMapping|null} MappingValue */ -/** @typedef {Record|ConditionalMapping|DirectMapping} ExportsField */ -/** @typedef {Record} ImportsField */ - -/** - * Processing exports/imports field - * @callback FieldProcessor - * @param {string} request request - * @param {Set} conditionNames condition names - * @returns {[string[], string | null]} resolved paths with used field - */ - -/* -Example exports field: -{ - ".": "./main.js", - "./feature": { - "browser": "./feature-browser.js", - "default": "./feature.js" - } -} -Terminology: - -Enhanced-resolve name keys ("." and "./feature") as exports field keys. - -If value is string or string[], mapping is called as a direct mapping -and value called as a direct export. - -If value is key-value object, mapping is called as a conditional mapping -and value called as a conditional export. - -Key in conditional mapping is called condition name. - -Conditional mapping nested in another conditional mapping is called nested mapping. - ----------- - -Example imports field: -{ - "#a": "./main.js", - "#moment": { - "browser": "./moment/index.js", - "default": "moment" - }, - "#moment/": { - "browser": "./moment/", - "default": "moment/" - } -} -Terminology: - -Enhanced-resolve name keys ("#a" and "#moment/", "#moment") as imports field keys. - -If value is string or string[], mapping is called as a direct mapping -and value called as a direct export. - -If value is key-value object, mapping is called as a conditional mapping -and value called as a conditional export. - -Key in conditional mapping is called condition name. - -Conditional mapping nested in another conditional mapping is called nested mapping. - -*/ - -const { parseIdentifier } = require("./identifier"); -const slashCode = "/".charCodeAt(0); -const dotCode = ".".charCodeAt(0); -const hashCode = "#".charCodeAt(0); -const patternRegEx = /\*/g; - -/** - * @param {ExportsField} exportsField the exports field - * @returns {FieldProcessor} process callback - */ -module.exports.processExportsField = function processExportsField( - exportsField -) { - return createFieldProcessor( - buildExportsField(exportsField), - request => (request.length === 0 ? "." : "./" + request), - assertExportsFieldRequest, - assertExportTarget - ); -}; - -/** - * @param {ImportsField} importsField the exports field - * @returns {FieldProcessor} process callback - */ -module.exports.processImportsField = function processImportsField( - importsField -) { - return createFieldProcessor( - importsField, - request => "#" + request, - assertImportsFieldRequest, - assertImportTarget - ); -}; - -/** - * @param {ExportsField | ImportsField} field root - * @param {(s: string) => string} normalizeRequest Normalize request, for `imports` field it adds `#`, for `exports` field it adds `.` or `./` - * @param {(s: string) => string} assertRequest assertRequest - * @param {(s: string, f: boolean) => void} assertTarget assertTarget - * @returns {FieldProcessor} field processor - */ -function createFieldProcessor( - field, - normalizeRequest, - assertRequest, - assertTarget -) { - return function fieldProcessor(request, conditionNames) { - request = assertRequest(request); - - const match = findMatch(normalizeRequest(request), field); - - if (match === null) return [[], null]; - - const [mapping, remainingRequest, isSubpathMapping, isPattern, usedField] = - match; - - /** @type {DirectMapping|null} */ - let direct = null; - - if (isConditionalMapping(mapping)) { - direct = conditionalMapping( - /** @type {ConditionalMapping} */ (mapping), - conditionNames - ); - - // matching not found - if (direct === null) return [[], null]; - } else { - direct = /** @type {DirectMapping} */ (mapping); - } - - return [ - directMapping( - remainingRequest, - isPattern, - isSubpathMapping, - direct, - conditionNames, - assertTarget - ), - usedField - ]; - }; -} - -/** - * @param {string} request request - * @returns {string} updated request - */ -function assertExportsFieldRequest(request) { - if (request.charCodeAt(0) !== dotCode) { - throw new Error('Request should be relative path and start with "."'); - } - if (request.length === 1) return ""; - if (request.charCodeAt(1) !== slashCode) { - throw new Error('Request should be relative path and start with "./"'); - } - if (request.charCodeAt(request.length - 1) === slashCode) { - throw new Error("Only requesting file allowed"); - } - - return request.slice(2); -} - -/** - * @param {string} request request - * @returns {string} updated request - */ -function assertImportsFieldRequest(request) { - if (request.charCodeAt(0) !== hashCode) { - throw new Error('Request should start with "#"'); - } - if (request.length === 1) { - throw new Error("Request should have at least 2 characters"); - } - if (request.charCodeAt(1) === slashCode) { - throw new Error('Request should not start with "#/"'); - } - if (request.charCodeAt(request.length - 1) === slashCode) { - throw new Error("Only requesting file allowed"); - } - - return request.slice(1); -} - -/** - * @param {string} exp export target - * @param {boolean} expectFolder is folder expected - */ -function assertExportTarget(exp, expectFolder) { - const parsedIdentifier = parseIdentifier(exp); - - if (!parsedIdentifier) { - return; - } - - const [relativePath] = parsedIdentifier; - const isFolder = - relativePath.charCodeAt(relativePath.length - 1) === slashCode; - - if (isFolder !== expectFolder) { - throw new Error( - expectFolder - ? `Expecting folder to folder mapping. ${JSON.stringify( - exp - )} should end with "/"` - : `Expecting file to file mapping. ${JSON.stringify( - exp - )} should not end with "/"` - ); - } -} - -/** - * @param {string} imp import target - * @param {boolean} expectFolder is folder expected - */ -function assertImportTarget(imp, expectFolder) { - const parsedIdentifier = parseIdentifier(imp); - - if (!parsedIdentifier) { - return; - } - - const [relativePath] = parsedIdentifier; - const isFolder = - relativePath.charCodeAt(relativePath.length - 1) === slashCode; - - if (isFolder !== expectFolder) { - throw new Error( - expectFolder - ? `Expecting folder to folder mapping. ${JSON.stringify( - imp - )} should end with "/"` - : `Expecting file to file mapping. ${JSON.stringify( - imp - )} should not end with "/"` - ); - } -} - -/** - * @param {string} a first string - * @param {string} b second string - * @returns {number} compare result - */ -function patternKeyCompare(a, b) { - const aPatternIndex = a.indexOf("*"); - const bPatternIndex = b.indexOf("*"); - const baseLenA = aPatternIndex === -1 ? a.length : aPatternIndex + 1; - const baseLenB = bPatternIndex === -1 ? b.length : bPatternIndex + 1; - - if (baseLenA > baseLenB) return -1; - if (baseLenB > baseLenA) return 1; - if (aPatternIndex === -1) return 1; - if (bPatternIndex === -1) return -1; - if (a.length > b.length) return -1; - if (b.length > a.length) return 1; - - return 0; -} - -/** - * Trying to match request to field - * @param {string} request request - * @param {ExportsField | ImportsField} field exports or import field - * @returns {[MappingValue, string, boolean, boolean, string]|null} match or null, number is negative and one less when it's a folder mapping, number is request.length + 1 for direct mappings - */ -function findMatch(request, field) { - if ( - Object.prototype.hasOwnProperty.call(field, request) && - !request.includes("*") && - !request.endsWith("/") - ) { - const target = /** @type {{[k: string]: MappingValue}} */ (field)[request]; - - return [target, "", false, false, request]; - } - - /** @type {string} */ - let bestMatch = ""; - /** @type {string|undefined} */ - let bestMatchSubpath; - - const keys = Object.getOwnPropertyNames(field); - - for (let i = 0; i < keys.length; i++) { - const key = keys[i]; - const patternIndex = key.indexOf("*"); - - if (patternIndex !== -1 && request.startsWith(key.slice(0, patternIndex))) { - const patternTrailer = key.slice(patternIndex + 1); - - if ( - request.length >= key.length && - request.endsWith(patternTrailer) && - patternKeyCompare(bestMatch, key) === 1 && - key.lastIndexOf("*") === patternIndex - ) { - bestMatch = key; - bestMatchSubpath = request.slice( - patternIndex, - request.length - patternTrailer.length - ); - } - } - // For legacy `./foo/` - else if ( - key[key.length - 1] === "/" && - request.startsWith(key) && - patternKeyCompare(bestMatch, key) === 1 - ) { - bestMatch = key; - bestMatchSubpath = request.slice(key.length); - } - } - - if (bestMatch === "") return null; - - const target = /** @type {{[k: string]: MappingValue}} */ (field)[bestMatch]; - const isSubpathMapping = bestMatch.endsWith("/"); - const isPattern = bestMatch.includes("*"); - - return [ - target, - /** @type {string} */ (bestMatchSubpath), - isSubpathMapping, - isPattern, - bestMatch - ]; -} - -/** - * @param {ConditionalMapping|DirectMapping|null} mapping mapping - * @returns {boolean} is conditional mapping - */ -function isConditionalMapping(mapping) { - return ( - mapping !== null && typeof mapping === "object" && !Array.isArray(mapping) - ); -} - -/** - * @param {string|undefined} remainingRequest remaining request when folder mapping, undefined for file mappings - * @param {boolean} isPattern true, if mapping is a pattern (contains "*") - * @param {boolean} isSubpathMapping true, for subpath mappings - * @param {DirectMapping|null} mappingTarget direct export - * @param {Set} conditionNames condition names - * @param {(d: string, f: boolean) => void} assert asserting direct value - * @returns {string[]} mapping result - */ -function directMapping( - remainingRequest, - isPattern, - isSubpathMapping, - mappingTarget, - conditionNames, - assert -) { - if (mappingTarget === null) return []; - - if (typeof mappingTarget === "string") { - return [ - targetMapping( - remainingRequest, - isPattern, - isSubpathMapping, - mappingTarget, - assert - ) - ]; - } - - /** @type {string[]} */ - const targets = []; - - for (const exp of mappingTarget) { - if (typeof exp === "string") { - targets.push( - targetMapping( - remainingRequest, - isPattern, - isSubpathMapping, - exp, - assert - ) - ); - continue; - } - - const mapping = conditionalMapping(exp, conditionNames); - if (!mapping) continue; - const innerExports = directMapping( - remainingRequest, - isPattern, - isSubpathMapping, - mapping, - conditionNames, - assert - ); - for (const innerExport of innerExports) { - targets.push(innerExport); - } - } - - return targets; -} - -/** - * @param {string|undefined} remainingRequest remaining request when folder mapping, undefined for file mappings - * @param {boolean} isPattern true, if mapping is a pattern (contains "*") - * @param {boolean} isSubpathMapping true, for subpath mappings - * @param {string} mappingTarget direct export - * @param {(d: string, f: boolean) => void} assert asserting direct value - * @returns {string} mapping result - */ -function targetMapping( - remainingRequest, - isPattern, - isSubpathMapping, - mappingTarget, - assert -) { - if (remainingRequest === undefined) { - assert(mappingTarget, false); - - return mappingTarget; - } - - if (isSubpathMapping) { - assert(mappingTarget, true); - - return mappingTarget + remainingRequest; - } - - assert(mappingTarget, false); - - let result = mappingTarget; - - if (isPattern) { - result = result.replace( - patternRegEx, - remainingRequest.replace(/\$/g, "$$") - ); - } - - return result; -} - -/** - * @param {ConditionalMapping} conditionalMapping_ conditional mapping - * @param {Set} conditionNames condition names - * @returns {DirectMapping|null} direct mapping if found - */ -function conditionalMapping(conditionalMapping_, conditionNames) { - /** @type {[ConditionalMapping, string[], number][]} */ - let lookup = [[conditionalMapping_, Object.keys(conditionalMapping_), 0]]; - - loop: while (lookup.length > 0) { - const [mapping, conditions, j] = lookup[lookup.length - 1]; - - for (let i = j; i < conditions.length; i++) { - const condition = conditions[i]; - - if (condition === "default") { - const innerMapping = mapping[condition]; - // is nested - if (isConditionalMapping(innerMapping)) { - const conditionalMapping = /** @type {ConditionalMapping} */ ( - innerMapping - ); - lookup[lookup.length - 1][2] = i + 1; - lookup.push([conditionalMapping, Object.keys(conditionalMapping), 0]); - continue loop; - } - - return /** @type {DirectMapping} */ (innerMapping); - } - - if (conditionNames.has(condition)) { - const innerMapping = mapping[condition]; - // is nested - if (isConditionalMapping(innerMapping)) { - const conditionalMapping = /** @type {ConditionalMapping} */ ( - innerMapping - ); - lookup[lookup.length - 1][2] = i + 1; - lookup.push([conditionalMapping, Object.keys(conditionalMapping), 0]); - continue loop; - } - - return /** @type {DirectMapping} */ (innerMapping); - } - } - - lookup.pop(); - } - - return null; -} - -/** - * @param {ExportsField} field exports field - * @returns {ExportsField} normalized exports field - */ -function buildExportsField(field) { - // handle syntax sugar, if exports field is direct mapping for "." - if (typeof field === "string" || Array.isArray(field)) { - return { ".": field }; - } - - const keys = Object.keys(field); - - for (let i = 0; i < keys.length; i++) { - const key = keys[i]; - - if (key.charCodeAt(0) !== dotCode) { - // handle syntax sugar, if exports field is conditional mapping for "." - if (i === 0) { - while (i < keys.length) { - const charCode = keys[i].charCodeAt(0); - if (charCode === dotCode || charCode === slashCode) { - throw new Error( - `Exports field key should be relative path and start with "." (key: ${JSON.stringify( - key - )})` - ); - } - i++; - } - - return { ".": field }; - } - - throw new Error( - `Exports field key should be relative path and start with "." (key: ${JSON.stringify( - key - )})` - ); - } - - if (key.length === 1) { - continue; - } - - if (key.charCodeAt(1) !== slashCode) { - throw new Error( - `Exports field key should be relative path and start with "./" (key: ${JSON.stringify( - key - )})` - ); - } - } - - return field; -} diff --git a/node_modules/enhanced-resolve/lib/util/identifier.js b/node_modules/enhanced-resolve/lib/util/identifier.js deleted file mode 100644 index d38cc39584..0000000000 --- a/node_modules/enhanced-resolve/lib/util/identifier.js +++ /dev/null @@ -1,27 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Ivan Kopeykin @vankop -*/ - -"use strict"; - -const PATH_QUERY_FRAGMENT_REGEXP = - /^(#?(?:\0.|[^?#\0])*)(\?(?:\0.|[^#\0])*)?(#.*)?$/; - -/** - * @param {string} identifier identifier - * @returns {[string, string, string]|null} parsed identifier - */ -function parseIdentifier(identifier) { - const match = PATH_QUERY_FRAGMENT_REGEXP.exec(identifier); - - if (!match) return null; - - return [ - match[1].replace(/\0(.)/g, "$1"), - match[2] ? match[2].replace(/\0(.)/g, "$1") : "", - match[3] || "" - ]; -} - -module.exports.parseIdentifier = parseIdentifier; diff --git a/node_modules/enhanced-resolve/lib/util/module-browser.js b/node_modules/enhanced-resolve/lib/util/module-browser.js deleted file mode 100644 index 1258c22e15..0000000000 --- a/node_modules/enhanced-resolve/lib/util/module-browser.js +++ /dev/null @@ -1,8 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -module.exports = {}; diff --git a/node_modules/enhanced-resolve/lib/util/path.js b/node_modules/enhanced-resolve/lib/util/path.js deleted file mode 100644 index bbb0e4d4de..0000000000 --- a/node_modules/enhanced-resolve/lib/util/path.js +++ /dev/null @@ -1,203 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -const path = require("path"); - -const CHAR_HASH = "#".charCodeAt(0); -const CHAR_SLASH = "/".charCodeAt(0); -const CHAR_BACKSLASH = "\\".charCodeAt(0); -const CHAR_A = "A".charCodeAt(0); -const CHAR_Z = "Z".charCodeAt(0); -const CHAR_LOWER_A = "a".charCodeAt(0); -const CHAR_LOWER_Z = "z".charCodeAt(0); -const CHAR_DOT = ".".charCodeAt(0); -const CHAR_COLON = ":".charCodeAt(0); - -const posixNormalize = path.posix.normalize; -const winNormalize = path.win32.normalize; - -/** - * @enum {number} - */ -const PathType = Object.freeze({ - Empty: 0, - Normal: 1, - Relative: 2, - AbsoluteWin: 3, - AbsolutePosix: 4, - Internal: 5 -}); -exports.PathType = PathType; - -const invalidSegmentRegEx = - /(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))?(\\|\/|$)/i; -exports.invalidSegmentRegEx = invalidSegmentRegEx; - -const deprecatedInvalidSegmentRegEx = - /(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))(\\|\/|$)/i; -exports.deprecatedInvalidSegmentRegEx = deprecatedInvalidSegmentRegEx; - -/** - * @param {string} p a path - * @returns {PathType} type of path - */ -const getType = p => { - switch (p.length) { - case 0: - return PathType.Empty; - case 1: { - const c0 = p.charCodeAt(0); - switch (c0) { - case CHAR_DOT: - return PathType.Relative; - case CHAR_SLASH: - return PathType.AbsolutePosix; - case CHAR_HASH: - return PathType.Internal; - } - return PathType.Normal; - } - case 2: { - const c0 = p.charCodeAt(0); - switch (c0) { - case CHAR_DOT: { - const c1 = p.charCodeAt(1); - switch (c1) { - case CHAR_DOT: - case CHAR_SLASH: - return PathType.Relative; - } - return PathType.Normal; - } - case CHAR_SLASH: - return PathType.AbsolutePosix; - case CHAR_HASH: - return PathType.Internal; - } - const c1 = p.charCodeAt(1); - if (c1 === CHAR_COLON) { - if ( - (c0 >= CHAR_A && c0 <= CHAR_Z) || - (c0 >= CHAR_LOWER_A && c0 <= CHAR_LOWER_Z) - ) { - return PathType.AbsoluteWin; - } - } - return PathType.Normal; - } - } - const c0 = p.charCodeAt(0); - switch (c0) { - case CHAR_DOT: { - const c1 = p.charCodeAt(1); - switch (c1) { - case CHAR_SLASH: - return PathType.Relative; - case CHAR_DOT: { - const c2 = p.charCodeAt(2); - if (c2 === CHAR_SLASH) return PathType.Relative; - return PathType.Normal; - } - } - return PathType.Normal; - } - case CHAR_SLASH: - return PathType.AbsolutePosix; - case CHAR_HASH: - return PathType.Internal; - } - const c1 = p.charCodeAt(1); - if (c1 === CHAR_COLON) { - const c2 = p.charCodeAt(2); - if ( - (c2 === CHAR_BACKSLASH || c2 === CHAR_SLASH) && - ((c0 >= CHAR_A && c0 <= CHAR_Z) || - (c0 >= CHAR_LOWER_A && c0 <= CHAR_LOWER_Z)) - ) { - return PathType.AbsoluteWin; - } - } - return PathType.Normal; -}; -exports.getType = getType; - -/** - * @param {string} p a path - * @returns {string} the normalized path - */ -const normalize = p => { - switch (getType(p)) { - case PathType.Empty: - return p; - case PathType.AbsoluteWin: - return winNormalize(p); - case PathType.Relative: { - const r = posixNormalize(p); - return getType(r) === PathType.Relative ? r : `./${r}`; - } - } - return posixNormalize(p); -}; -exports.normalize = normalize; - -/** - * @param {string} rootPath the root path - * @param {string | undefined} request the request path - * @returns {string} the joined path - */ -const join = (rootPath, request) => { - if (!request) return normalize(rootPath); - const requestType = getType(request); - switch (requestType) { - case PathType.AbsolutePosix: - return posixNormalize(request); - case PathType.AbsoluteWin: - return winNormalize(request); - } - switch (getType(rootPath)) { - case PathType.Normal: - case PathType.Relative: - case PathType.AbsolutePosix: - return posixNormalize(`${rootPath}/${request}`); - case PathType.AbsoluteWin: - return winNormalize(`${rootPath}\\${request}`); - } - switch (requestType) { - case PathType.Empty: - return rootPath; - case PathType.Relative: { - const r = posixNormalize(rootPath); - return getType(r) === PathType.Relative ? r : `./${r}`; - } - } - return posixNormalize(rootPath); -}; -exports.join = join; - -/** @type {Map>} */ -const joinCache = new Map(); - -/** - * @param {string} rootPath the root path - * @param {string} request the request path - * @returns {string} the joined path - */ -const cachedJoin = (rootPath, request) => { - /** @type {string | undefined} */ - let cacheEntry; - let cache = joinCache.get(rootPath); - if (cache === undefined) { - joinCache.set(rootPath, (cache = new Map())); - } else { - cacheEntry = cache.get(request); - if (cacheEntry !== undefined) return cacheEntry; - } - cacheEntry = join(rootPath, request); - cache.set(request, cacheEntry); - return cacheEntry; -}; -exports.cachedJoin = cachedJoin; diff --git a/node_modules/enhanced-resolve/lib/util/process-browser.js b/node_modules/enhanced-resolve/lib/util/process-browser.js deleted file mode 100644 index a99141fdd8..0000000000 --- a/node_modules/enhanced-resolve/lib/util/process-browser.js +++ /dev/null @@ -1,22 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -module.exports = { - /** - * @type {Record} - */ - versions: {}, - /** - * @param {function} fn function - */ - nextTick(fn) { - const args = Array.prototype.slice.call(arguments, 1); - Promise.resolve().then(function () { - fn.apply(null, args); - }); - } -}; diff --git a/node_modules/enhanced-resolve/package.json b/node_modules/enhanced-resolve/package.json deleted file mode 100644 index c5ae7206e1..0000000000 --- a/node_modules/enhanced-resolve/package.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "name": "enhanced-resolve", - "version": "5.17.1", - "author": "Tobias Koppers @sokra", - "description": "Offers a async require.resolve function. It's highly configurable.", - "files": [ - "lib", - "types.d.ts", - "LICENSE" - ], - "browser": { - "process": "./lib/util/process-browser.js", - "module": "./lib/util/module-browser.js" - }, - "dependencies": { - "graceful-fs": "^4.2.4", - "tapable": "^2.2.0" - }, - "license": "MIT", - "devDependencies": { - "@types/graceful-fs": "^4.1.6", - "@types/jest": "^27.5.1", - "@types/node": "20.9.5", - "cspell": "4.2.8", - "eslint": "^7.9.0", - "eslint-config-prettier": "^6.11.0", - "eslint-plugin-jsdoc": "^30.5.1", - "eslint-plugin-node": "^11.1.0", - "eslint-plugin-prettier": "^3.1.4", - "husky": "^6.0.0", - "jest": "^27.5.1", - "lint-staged": "^10.4.0", - "memfs": "^3.2.0", - "prettier": "^2.1.2", - "tooling": "webpack/tooling#v1.23.1", - "typescript": "^5.3.3" - }, - "engines": { - "node": ">=10.13.0" - }, - "main": "lib/index.js", - "types": "types.d.ts", - "homepage": "http://github.com/webpack/enhanced-resolve", - "scripts": { - "lint": "yarn run code-lint && yarn run type-lint && yarn typings-test && yarn run special-lint && yarn run spelling", - "fix": "yarn run code-lint-fix && yarn run special-lint-fix", - "code-lint": "eslint --cache lib test", - "code-lint-fix": "eslint --cache lib test --fix", - "type-lint": "tsc", - "typings-test": "tsc -p tsconfig.types.test.json", - "type-report": "rimraf coverage && yarn cover:types && yarn cover:report && open-cli coverage/lcov-report/index.html", - "special-lint": "node node_modules/tooling/lockfile-lint && node node_modules/tooling/inherit-types && node node_modules/tooling/format-file-header && node node_modules/tooling/generate-types", - "special-lint-fix": "node node_modules/tooling/inherit-types --write && node node_modules/tooling/format-file-header --write && node node_modules/tooling/generate-types --write", - "pretty": "prettier --loglevel warn --write \"lib/**/*.{js,json}\" \"test/*.js\"", - "pretest": "yarn lint", - "spelling": "cspell \"**\"", - "test:only": "node_modules/.bin/jest", - "test:watch": "yarn test:only -- --watch", - "test:coverage": "yarn test:only -- --collectCoverageFrom=\"lib/**/*.js\" --coverage", - "test": "yarn test:coverage", - "precover": "yarn lint", - "prepare": "husky install" - }, - "lint-staged": { - "*": "cspell --no-must-find-files", - "*.js": "eslint --cache" - }, - "repository": { - "type": "git", - "url": "git://github.com/webpack/enhanced-resolve.git" - } -} diff --git a/node_modules/enhanced-resolve/types.d.ts b/node_modules/enhanced-resolve/types.d.ts deleted file mode 100644 index fc09289d60..0000000000 --- a/node_modules/enhanced-resolve/types.d.ts +++ /dev/null @@ -1,1135 +0,0 @@ -/* - * This file was automatically generated. - * DO NOT MODIFY BY HAND. - * Run `yarn special-lint-fix` to update - */ - -import { Buffer } from "buffer"; -import { AsyncSeriesBailHook, AsyncSeriesHook, SyncHook } from "tapable"; -import { URL as URL_Import } from "url"; - -declare interface Abortable { - /** - * When provided the corresponding `AbortController` can be used to cancel an asynchronous action. - */ - signal?: AbortSignal; -} -type Alias = string | false | string[]; -declare interface AliasOption { - alias: Alias; - name: string; - onlyModule?: boolean; -} -type AliasOptionNewRequest = string | false | string[]; -declare interface AliasOptions { - [index: string]: AliasOptionNewRequest; -} -type BaseFileSystem = FileSystem & SyncFileSystem; -declare interface BaseResolveRequest { - path: string | false; - context?: object; - descriptionFilePath?: string; - descriptionFileRoot?: string; - descriptionFileData?: JsonObject; - relativePath?: string; - ignoreSymlinks?: boolean; - fullySpecified?: boolean; - __innerRequest?: string; - __innerRequest_request?: string; - __innerRequest_relativePath?: string; -} -type BufferEncoding = - | "ascii" - | "utf8" - | "utf-8" - | "utf16le" - | "utf-16le" - | "ucs2" - | "ucs-2" - | "base64" - | "base64url" - | "latin1" - | "binary" - | "hex"; -type BufferEncodingOption = "buffer" | { encoding: "buffer" }; -declare class CachedInputFileSystem { - constructor(fileSystem: BaseFileSystem, duration: number); - fileSystem: BaseFileSystem; - lstat?: LStat; - lstatSync?: LStatSync; - stat: Stat; - statSync: StatSync; - readdir: Readdir; - readdirSync: ReaddirSync; - readFile: ReadFile; - readFileSync: ReadFileSync; - readJson?: ( - arg0: PathOrFileDescriptor, - arg1: ( - arg0: null | Error | NodeJS.ErrnoException, - arg1?: JsonObject - ) => void - ) => void; - readJsonSync?: (arg0: PathOrFileDescriptor) => JsonObject; - readlink: Readlink; - readlinkSync: ReadlinkSync; - realpath?: RealPath; - realpathSync?: RealPathSync; - purge( - what?: - | string - | number - | Buffer - | URL_url - | (string | number | Buffer | URL_url)[] - | Set - ): void; -} -declare class CloneBasenamePlugin { - constructor( - source: - | string - | AsyncSeriesBailHook< - [ResolveRequest, ResolveContext], - null | ResolveRequest - >, - target: - | string - | AsyncSeriesBailHook< - [ResolveRequest, ResolveContext], - null | ResolveRequest - > - ); - source: - | string - | AsyncSeriesBailHook< - [ResolveRequest, ResolveContext], - null | ResolveRequest - >; - target: - | string - | AsyncSeriesBailHook< - [ResolveRequest, ResolveContext], - null | ResolveRequest - >; - apply(resolver: Resolver): void; -} -declare interface Dirent { - isFile: () => boolean; - isDirectory: () => boolean; - isBlockDevice: () => boolean; - isCharacterDevice: () => boolean; - isSymbolicLink: () => boolean; - isFIFO: () => boolean; - isSocket: () => boolean; - name: string; - path: string; -} -type EncodingOption = - | undefined - | null - | "ascii" - | "utf8" - | "utf-8" - | "utf16le" - | "utf-16le" - | "ucs2" - | "ucs-2" - | "base64" - | "base64url" - | "latin1" - | "binary" - | "hex" - | ObjectEncodingOptions; -type ErrorWithDetail = Error & { details?: string }; -declare interface ExtensionAliasOption { - alias: string | string[]; - extension: string; -} -declare interface ExtensionAliasOptions { - [index: string]: string | string[]; -} -declare interface FileSystem { - readFile: ReadFile; - readdir: Readdir; - readJson?: ( - arg0: PathOrFileDescriptor, - arg1: ( - arg0: null | Error | NodeJS.ErrnoException, - arg1?: JsonObject - ) => void - ) => void; - readlink: Readlink; - lstat?: LStat; - stat: Stat; - realpath?: RealPath; -} -type IBigIntStats = IStatsBase & { - atimeNs: bigint; - mtimeNs: bigint; - ctimeNs: bigint; - birthtimeNs: bigint; -}; -declare interface IStats { - isFile: () => boolean; - isDirectory: () => boolean; - isBlockDevice: () => boolean; - isCharacterDevice: () => boolean; - isSymbolicLink: () => boolean; - isFIFO: () => boolean; - isSocket: () => boolean; - dev: number; - ino: number; - mode: number; - nlink: number; - uid: number; - gid: number; - rdev: number; - size: number; - blksize: number; - blocks: number; - atimeMs: number; - mtimeMs: number; - ctimeMs: number; - birthtimeMs: number; - atime: Date; - mtime: Date; - ctime: Date; - birthtime: Date; -} -declare interface IStatsBase { - isFile: () => boolean; - isDirectory: () => boolean; - isBlockDevice: () => boolean; - isCharacterDevice: () => boolean; - isSymbolicLink: () => boolean; - isFIFO: () => boolean; - isSocket: () => boolean; - dev: T; - ino: T; - mode: T; - nlink: T; - uid: T; - gid: T; - rdev: T; - size: T; - blksize: T; - blocks: T; - atimeMs: T; - mtimeMs: T; - ctimeMs: T; - birthtimeMs: T; - atime: Date; - mtime: Date; - ctime: Date; - birthtime: Date; -} -declare interface Iterator { - ( - item: T, - callback: (err?: null | Error, result?: null | Z) => void, - i: number - ): void; -} -type JsonObject = { [index: string]: JsonValue } & { - [index: string]: - | undefined - | null - | string - | number - | boolean - | JsonObject - | JsonValue[]; -}; -type JsonValue = null | string | number | boolean | JsonObject | JsonValue[]; -declare interface KnownHooks { - resolveStep: SyncHook< - [ - AsyncSeriesBailHook< - [ResolveRequest, ResolveContext], - null | ResolveRequest - >, - ResolveRequest - ] - >; - noResolve: SyncHook<[ResolveRequest, Error]>; - resolve: AsyncSeriesBailHook< - [ResolveRequest, ResolveContext], - null | ResolveRequest - >; - result: AsyncSeriesHook<[ResolveRequest, ResolveContext]>; -} -declare interface LStat { - ( - path: PathLike, - callback: (arg0: null | NodeJS.ErrnoException, arg1?: IStats) => void - ): void; - ( - path: PathLike, - options: undefined | (StatOptions & { bigint?: false }), - callback: (arg0: null | NodeJS.ErrnoException, arg1?: IStats) => void - ): void; - ( - path: PathLike, - options: StatOptions & { bigint: true }, - callback: (arg0: null | NodeJS.ErrnoException, arg1?: IBigIntStats) => void - ): void; - ( - path: PathLike, - options: undefined | StatOptions, - callback: ( - arg0: null | NodeJS.ErrnoException, - arg1?: IStats | IBigIntStats - ) => void - ): void; -} -declare interface LStatSync { - (path: PathLike, options?: undefined): IStats; - ( - path: PathLike, - options?: StatSyncOptions & { bigint?: false; throwIfNoEntry: false } - ): undefined | IStats; - ( - path: PathLike, - options: StatSyncOptions & { bigint: true; throwIfNoEntry: false } - ): undefined | IBigIntStats; - (path: PathLike, options?: StatSyncOptions & { bigint?: false }): IStats; - (path: PathLike, options: StatSyncOptions & { bigint: true }): IBigIntStats; - ( - path: PathLike, - options: StatSyncOptions & { bigint: boolean; throwIfNoEntry?: false } - ): IStats | IBigIntStats; - (path: PathLike, options?: StatSyncOptions): - | undefined - | IStats - | IBigIntStats; -} -declare class LogInfoPlugin { - constructor( - source: - | string - | AsyncSeriesBailHook< - [ResolveRequest, ResolveContext], - null | ResolveRequest - > - ); - source: - | string - | AsyncSeriesBailHook< - [ResolveRequest, ResolveContext], - null | ResolveRequest - >; - apply(resolver: Resolver): void; -} -declare interface ObjectEncodingOptions { - encoding?: - | null - | "ascii" - | "utf8" - | "utf-8" - | "utf16le" - | "utf-16le" - | "ucs2" - | "ucs-2" - | "base64" - | "base64url" - | "latin1" - | "binary" - | "hex"; -} -declare interface ParsedIdentifier { - request: string; - query: string; - fragment: string; - directory: boolean; - module: boolean; - file: boolean; - internal: boolean; -} -type PathLike = string | Buffer | URL_url; -type PathOrFileDescriptor = string | number | Buffer | URL_url; -type Plugin = - | undefined - | null - | false - | "" - | 0 - | { apply: (arg0: Resolver) => void } - | ((this: Resolver, arg1: Resolver) => void); -declare interface PnpApi { - resolveToUnqualified: ( - arg0: string, - arg1: string, - arg2: object - ) => null | string; -} -declare interface ReadFile { - ( - path: PathOrFileDescriptor, - options: - | undefined - | null - | ({ encoding?: null; flag?: string } & Abortable), - callback: (arg0: null | NodeJS.ErrnoException, arg1?: Buffer) => void - ): void; - ( - path: PathOrFileDescriptor, - options: - | ({ encoding: BufferEncoding; flag?: string } & Abortable) - | "ascii" - | "utf8" - | "utf-8" - | "utf16le" - | "utf-16le" - | "ucs2" - | "ucs-2" - | "base64" - | "base64url" - | "latin1" - | "binary" - | "hex", - callback: (arg0: null | NodeJS.ErrnoException, arg1?: string) => void - ): void; - ( - path: PathOrFileDescriptor, - options: - | undefined - | null - | "ascii" - | "utf8" - | "utf-8" - | "utf16le" - | "utf-16le" - | "ucs2" - | "ucs-2" - | "base64" - | "base64url" - | "latin1" - | "binary" - | "hex" - | (ObjectEncodingOptions & { flag?: string } & Abortable), - callback: ( - arg0: null | NodeJS.ErrnoException, - arg1?: string | Buffer - ) => void - ): void; - ( - path: PathOrFileDescriptor, - callback: (arg0: null | NodeJS.ErrnoException, arg1?: Buffer) => void - ): void; -} -declare interface ReadFileSync { - ( - path: PathOrFileDescriptor, - options?: null | { encoding?: null; flag?: string } - ): Buffer; - ( - path: PathOrFileDescriptor, - options: - | "ascii" - | "utf8" - | "utf-8" - | "utf16le" - | "utf-16le" - | "ucs2" - | "ucs-2" - | "base64" - | "base64url" - | "latin1" - | "binary" - | "hex" - | { encoding: BufferEncoding; flag?: string } - ): string; - ( - path: PathOrFileDescriptor, - options?: - | null - | "ascii" - | "utf8" - | "utf-8" - | "utf16le" - | "utf-16le" - | "ucs2" - | "ucs-2" - | "base64" - | "base64url" - | "latin1" - | "binary" - | "hex" - | (ObjectEncodingOptions & { flag?: string }) - ): string | Buffer; -} -declare interface Readdir { - ( - path: PathLike, - options: - | undefined - | null - | "ascii" - | "utf8" - | "utf-8" - | "utf16le" - | "utf-16le" - | "ucs2" - | "ucs-2" - | "base64" - | "base64url" - | "latin1" - | "binary" - | "hex" - | { - encoding: - | null - | "ascii" - | "utf8" - | "utf-8" - | "utf16le" - | "utf-16le" - | "ucs2" - | "ucs-2" - | "base64" - | "base64url" - | "latin1" - | "binary" - | "hex"; - withFileTypes?: false; - recursive?: boolean; - }, - callback: (arg0: null | NodeJS.ErrnoException, arg1?: string[]) => void - ): void; - ( - path: PathLike, - options: - | { encoding: "buffer"; withFileTypes?: false; recursive?: boolean } - | "buffer", - callback: (arg0: null | NodeJS.ErrnoException, arg1?: Buffer[]) => void - ): void; - ( - path: PathLike, - callback: (arg0: null | NodeJS.ErrnoException, arg1?: string[]) => void - ): void; - ( - path: PathLike, - options: - | undefined - | null - | "ascii" - | "utf8" - | "utf-8" - | "utf16le" - | "utf-16le" - | "ucs2" - | "ucs-2" - | "base64" - | "base64url" - | "latin1" - | "binary" - | "hex" - | (ObjectEncodingOptions & { - withFileTypes?: false; - recursive?: boolean; - }), - callback: ( - arg0: null | NodeJS.ErrnoException, - arg1?: string[] | Buffer[] - ) => void - ): void; - ( - path: PathLike, - options: ObjectEncodingOptions & { - withFileTypes: true; - recursive?: boolean; - }, - callback: (arg0: null | NodeJS.ErrnoException, arg1?: Dirent[]) => void - ): void; -} -declare interface ReaddirSync { - ( - path: PathLike, - options?: - | null - | "ascii" - | "utf8" - | "utf-8" - | "utf16le" - | "utf-16le" - | "ucs2" - | "ucs-2" - | "base64" - | "base64url" - | "latin1" - | "binary" - | "hex" - | { - encoding: - | null - | "ascii" - | "utf8" - | "utf-8" - | "utf16le" - | "utf-16le" - | "ucs2" - | "ucs-2" - | "base64" - | "base64url" - | "latin1" - | "binary" - | "hex"; - withFileTypes?: false; - recursive?: boolean; - } - ): string[]; - ( - path: PathLike, - options: - | "buffer" - | { encoding: "buffer"; withFileTypes?: false; recursive?: boolean } - ): Buffer[]; - ( - path: PathLike, - options?: - | null - | "ascii" - | "utf8" - | "utf-8" - | "utf16le" - | "utf-16le" - | "ucs2" - | "ucs-2" - | "base64" - | "base64url" - | "latin1" - | "binary" - | "hex" - | (ObjectEncodingOptions & { withFileTypes?: false; recursive?: boolean }) - ): string[] | Buffer[]; - ( - path: PathLike, - options: ObjectEncodingOptions & { - withFileTypes: true; - recursive?: boolean; - } - ): Dirent[]; -} -declare interface Readlink { - ( - path: PathLike, - options: EncodingOption, - callback: (arg0: null | NodeJS.ErrnoException, arg1?: string) => void - ): void; - ( - path: PathLike, - options: BufferEncodingOption, - callback: (arg0: null | NodeJS.ErrnoException, arg1?: Buffer) => void - ): void; - ( - path: PathLike, - options: EncodingOption, - callback: ( - arg0: null | NodeJS.ErrnoException, - arg1?: string | Buffer - ) => void - ): void; - ( - path: PathLike, - callback: (arg0: null | NodeJS.ErrnoException, arg1?: string) => void - ): void; -} -declare interface ReadlinkSync { - (path: PathLike, options?: EncodingOption): string; - (path: PathLike, options: BufferEncodingOption): Buffer; - (path: PathLike, options?: EncodingOption): string | Buffer; -} -declare interface RealPath { - ( - path: PathLike, - options: EncodingOption, - callback: (arg0: null | NodeJS.ErrnoException, arg1?: string) => void - ): void; - ( - path: PathLike, - options: BufferEncodingOption, - callback: (arg0: null | NodeJS.ErrnoException, arg1?: Buffer) => void - ): void; - ( - path: PathLike, - options: EncodingOption, - callback: ( - arg0: null | NodeJS.ErrnoException, - arg1?: string | Buffer - ) => void - ): void; - ( - path: PathLike, - callback: (arg0: null | NodeJS.ErrnoException, arg1?: string) => void - ): void; -} -declare interface RealPathSync { - (path: PathLike, options?: EncodingOption): string; - (path: PathLike, options: BufferEncodingOption): Buffer; - (path: PathLike, options?: EncodingOption): string | Buffer; -} -declare interface ResolveContext { - contextDependencies?: WriteOnlySet; - - /** - * files that was found on file system - */ - fileDependencies?: WriteOnlySet; - - /** - * dependencies that was not found on file system - */ - missingDependencies?: WriteOnlySet; - - /** - * set of hooks' calls. For instance, `resolve → parsedResolve → describedResolve`, - */ - stack?: Set; - - /** - * log function - */ - log?: (arg0: string) => void; - - /** - * yield result, if provided plugins can return several results - */ - yield?: (arg0: ResolveRequest) => void; -} -declare interface ResolveFunction { - (context: object, path: string, request: string): string | false; - (path: string, request: string): string | false; -} -declare interface ResolveFunctionAsync { - ( - context: object, - path: string, - request: string, - resolveContext: ResolveContext, - callback: ( - err: null | ErrorWithDetail, - res?: string | false, - req?: ResolveRequest - ) => void - ): void; - ( - context: object, - path: string, - request: string, - callback: ( - err: null | ErrorWithDetail, - res?: string | false, - req?: ResolveRequest - ) => void - ): void; - ( - path: string, - request: string, - resolveContext: ResolveContext, - callback: ( - err: null | ErrorWithDetail, - res?: string | false, - req?: ResolveRequest - ) => void - ): void; - ( - path: string, - request: string, - callback: ( - err: null | ErrorWithDetail, - res?: string | false, - req?: ResolveRequest - ) => void - ): void; -} -type ResolveOptionsOptionalFS = Omit< - ResolveOptionsResolverFactoryObject_2, - "fileSystem" -> & - Partial>; -declare interface ResolveOptionsResolverFactoryObject_1 { - alias: AliasOption[]; - fallback: AliasOption[]; - aliasFields: Set; - extensionAlias: ExtensionAliasOption[]; - cachePredicate: (arg0: ResolveRequest) => boolean; - cacheWithContext: boolean; - - /** - * A list of exports field condition names. - */ - conditionNames: Set; - descriptionFiles: string[]; - enforceExtension: boolean; - exportsFields: Set; - importsFields: Set; - extensions: Set; - fileSystem: FileSystem; - unsafeCache: false | object; - symlinks: boolean; - resolver?: Resolver; - modules: (string | string[])[]; - mainFields: { name: string[]; forceRelative: boolean }[]; - mainFiles: Set; - plugins: Plugin[]; - pnpApi: null | PnpApi; - roots: Set; - fullySpecified: boolean; - resolveToContext: boolean; - restrictions: Set; - preferRelative: boolean; - preferAbsolute: boolean; -} -declare interface ResolveOptionsResolverFactoryObject_2 { - /** - * A list of module alias configurations or an object which maps key to value - */ - alias?: AliasOptions | AliasOption[]; - - /** - * A list of module alias configurations or an object which maps key to value, applied only after modules option - */ - fallback?: AliasOptions | AliasOption[]; - - /** - * An object which maps extension to extension aliases - */ - extensionAlias?: ExtensionAliasOptions; - - /** - * A list of alias fields in description files - */ - aliasFields?: (string | string[])[]; - - /** - * A function which decides whether a request should be cached or not. An object is passed with at least `path` and `request` properties. - */ - cachePredicate?: (arg0: ResolveRequest) => boolean; - - /** - * Whether or not the unsafeCache should include request context as part of the cache key. - */ - cacheWithContext?: boolean; - - /** - * A list of description files to read from - */ - descriptionFiles?: string[]; - - /** - * A list of exports field condition names. - */ - conditionNames?: string[]; - - /** - * Enforce that a extension from extensions must be used - */ - enforceExtension?: boolean; - - /** - * A list of exports fields in description files - */ - exportsFields?: (string | string[])[]; - - /** - * A list of imports fields in description files - */ - importsFields?: (string | string[])[]; - - /** - * A list of extensions which should be tried for files - */ - extensions?: string[]; - - /** - * The file system which should be used - */ - fileSystem: FileSystem; - - /** - * Use this cache object to unsafely cache the successful requests - */ - unsafeCache?: boolean | object; - - /** - * Resolve symlinks to their symlinked location - */ - symlinks?: boolean; - - /** - * A prepared Resolver to which the plugins are attached - */ - resolver?: Resolver; - - /** - * A list of directories to resolve modules from, can be absolute path or folder name - */ - modules?: string | string[]; - - /** - * A list of main fields in description files - */ - mainFields?: ( - | string - | string[] - | { name: string | string[]; forceRelative: boolean } - )[]; - - /** - * A list of main files in directories - */ - mainFiles?: string[]; - - /** - * A list of additional resolve plugins which should be applied - */ - plugins?: Plugin[]; - - /** - * A PnP API that should be used - null is "never", undefined is "auto" - */ - pnpApi?: null | PnpApi; - - /** - * A list of root paths - */ - roots?: string[]; - - /** - * The request is already fully specified and no extensions or directories are resolved for it - */ - fullySpecified?: boolean; - - /** - * Resolve to a context instead of a file - */ - resolveToContext?: boolean; - - /** - * A list of resolve restrictions - */ - restrictions?: (string | RegExp)[]; - - /** - * Use only the sync constraints of the file system calls - */ - useSyncFileSystemCalls?: boolean; - - /** - * Prefer to resolve module requests as relative requests before falling back to modules - */ - preferRelative?: boolean; - - /** - * Prefer to resolve server-relative urls as absolute paths before falling back to resolve in roots - */ - preferAbsolute?: boolean; -} -type ResolveRequest = BaseResolveRequest & Partial; -declare abstract class Resolver { - fileSystem: FileSystem; - options: ResolveOptionsResolverFactoryObject_1; - hooks: KnownHooks; - ensureHook( - name: - | string - | AsyncSeriesBailHook< - [ResolveRequest, ResolveContext], - null | ResolveRequest - > - ): AsyncSeriesBailHook< - [ResolveRequest, ResolveContext], - null | ResolveRequest - >; - getHook( - name: - | string - | AsyncSeriesBailHook< - [ResolveRequest, ResolveContext], - null | ResolveRequest - > - ): AsyncSeriesBailHook< - [ResolveRequest, ResolveContext], - null | ResolveRequest - >; - resolveSync(context: object, path: string, request: string): string | false; - resolve( - context: object, - path: string, - request: string, - resolveContext: ResolveContext, - callback: ( - err: null | ErrorWithDetail, - res?: string | false, - req?: ResolveRequest - ) => void - ): void; - doResolve( - hook: AsyncSeriesBailHook< - [ResolveRequest, ResolveContext], - null | ResolveRequest - >, - request: ResolveRequest, - message: null | string, - resolveContext: ResolveContext, - callback: (err?: null | Error, result?: ResolveRequest) => void - ): void; - parse(identifier: string): ParsedIdentifier; - isModule(path: string): boolean; - isPrivate(path: string): boolean; - isDirectory(path: string): boolean; - join(path: string, request: string): string; - normalize(path: string): string; -} -declare interface Stat { - ( - path: PathLike, - callback: (arg0: null | NodeJS.ErrnoException, arg1?: IStats) => void - ): void; - ( - path: PathLike, - options: undefined | (StatOptions & { bigint?: false }), - callback: (arg0: null | NodeJS.ErrnoException, arg1?: IStats) => void - ): void; - ( - path: PathLike, - options: StatOptions & { bigint: true }, - callback: (arg0: null | NodeJS.ErrnoException, arg1?: IBigIntStats) => void - ): void; - ( - path: PathLike, - options: undefined | StatOptions, - callback: ( - arg0: null | NodeJS.ErrnoException, - arg1?: IStats | IBigIntStats - ) => void - ): void; -} -declare interface StatOptions { - bigint?: boolean; -} -declare interface StatSync { - (path: PathLike, options?: undefined): IStats; - ( - path: PathLike, - options?: StatSyncOptions & { bigint?: false; throwIfNoEntry: false } - ): undefined | IStats; - ( - path: PathLike, - options: StatSyncOptions & { bigint: true; throwIfNoEntry: false } - ): undefined | IBigIntStats; - (path: PathLike, options?: StatSyncOptions & { bigint?: false }): IStats; - (path: PathLike, options: StatSyncOptions & { bigint: true }): IBigIntStats; - ( - path: PathLike, - options: StatSyncOptions & { bigint: boolean; throwIfNoEntry?: false } - ): IStats | IBigIntStats; - (path: PathLike, options?: StatSyncOptions): - | undefined - | IStats - | IBigIntStats; -} -declare interface StatSyncOptions { - bigint?: boolean; - throwIfNoEntry?: boolean; -} -declare interface SyncFileSystem { - readFileSync: ReadFileSync; - readdirSync: ReaddirSync; - readJsonSync?: (arg0: PathOrFileDescriptor) => JsonObject; - readlinkSync: ReadlinkSync; - lstatSync?: LStatSync; - statSync: StatSync; - realpathSync?: RealPathSync; -} - -/** - * `URL` class is a global reference for `require('url').URL` - * https://nodejs.org/api/url.html#the-whatwg-url-api - */ -declare interface URL_url extends URL_Import {} -declare interface WriteOnlySet { - add: (item: T) => void; -} -declare function exports( - context: object, - path: string, - request: string, - resolveContext: ResolveContext, - callback: ( - err: null | ErrorWithDetail, - res?: string | false, - req?: ResolveRequest - ) => void -): void; -declare function exports( - context: object, - path: string, - request: string, - callback: ( - err: null | ErrorWithDetail, - res?: string | false, - req?: ResolveRequest - ) => void -): void; -declare function exports( - path: string, - request: string, - resolveContext: ResolveContext, - callback: ( - err: null | ErrorWithDetail, - res?: string | false, - req?: ResolveRequest - ) => void -): void; -declare function exports( - path: string, - request: string, - callback: ( - err: null | ErrorWithDetail, - res?: string | false, - req?: ResolveRequest - ) => void -): void; -declare namespace exports { - export const sync: ResolveFunction; - export function create( - options: ResolveOptionsOptionalFS - ): ResolveFunctionAsync; - export namespace create { - export const sync: (options: ResolveOptionsOptionalFS) => ResolveFunction; - } - export namespace ResolverFactory { - export let createResolver: ( - options: ResolveOptionsResolverFactoryObject_2 - ) => Resolver; - } - export const forEachBail: ( - array: T[], - iterator: Iterator, - callback: (err?: null | Error, result?: null | Z, i?: number) => void - ) => void; - export type ResolveCallback = ( - err: null | ErrorWithDetail, - res?: string | false, - req?: ResolveRequest - ) => void; - export { - CachedInputFileSystem, - CloneBasenamePlugin, - LogInfoPlugin, - ResolveOptionsOptionalFS, - PnpApi, - Resolver, - FileSystem, - ResolveContext, - ResolveRequest, - Plugin, - ResolveOptionsResolverFactoryObject_2 as ResolveOptions, - ResolveFunctionAsync, - ResolveFunction - }; -} - -export = exports; diff --git a/node_modules/eslint-import-resolver-typescript/README.md b/node_modules/eslint-import-resolver-typescript/README.md index 225552782b..e41bc64ab3 100644 --- a/node_modules/eslint-import-resolver-typescript/README.md +++ b/node_modules/eslint-import-resolver-typescript/README.md @@ -25,8 +25,12 @@ This means you can: - [Notice](#notice) - [Installation](#installation) + - [`eslint-plugin-import`](#eslint-plugin-import) + - [`eslint-plugin-import-x`](#eslint-plugin-import-x) - [Configuration](#configuration) -- [Options from `enhanced-resolve`](#options-from-enhanced-resolve) + - [`eslint.config.js`](#eslintconfigjs) + - [`.eslintrc`](#eslintrc) +- [Options from `rspack-resolver`](#options-from-rspack-resolver) - [`conditionNames`](#conditionnames) - [`extensions`](#extensions) - [`extensionAlias`](#extensionalias) @@ -47,6 +51,8 @@ If you're facing some problems on rules `import/default` or `import/named` from ## Installation +### `eslint-plugin-import` + ```sh # npm npm i -D eslint-plugin-import eslint-import-resolver-typescript @@ -58,7 +64,18 @@ pnpm i -D eslint-plugin-import eslint-import-resolver-typescript yarn add -D eslint-plugin-import eslint-import-resolver-typescript ``` -**Important when using `eslint-plugin-import-x` and `npm`**: Use `npm i -D eslint-plugin-import@eslint-plugin-import-x@latest eslint-import-resolver-typescript`, or you will end up with both `eslint-plugin-import` and `eslint-plugin-import-x` in your node_modules. +### `eslint-plugin-import-x` + +```sh +# npm +npm i -D eslint-plugin-import-x eslint-import-resolver-typescript + +# pnpm +pnpm i -D eslint-plugin-import-x eslint-import-resolver-typescript + +# yarn +yarn add -D eslint-plugin-import-x eslint-import-resolver-typescript +``` ## Configuration @@ -67,49 +84,52 @@ yarn add -D eslint-plugin-import eslint-import-resolver-typescript If you are using `eslint-plugin-import-x@>=4.5.0`, you can use import/require to reference `eslint-import-resolver-typescript` directly in your ESLint flat config: ```js -// eslint.config.js -const { - createTypeScriptImportResolver, -} = require('eslint-import-resolver-typescript') +// eslint.config.js, CommonJS is also supported +import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript' -module.exports = [{ - settings: { - "import-x/resolver-next": [ - createTypeScriptImportResolver({ - alwaysTryTypes: true, // always try to resolve types under `@types` directory even it doesn't contain any source code, like `@types/unist` +export default [ + { + settings: { + 'import-x/resolver-next': [ + createTypeScriptImportResolver({ + alwaysTryTypes: true, // always try to resolve types under `@types` directory even it doesn't contain any source code, like `@types/unist` - // Choose from one of the "project" configs below or omit to use /tsconfig.json by default + // Choose from one of the "project" configs below or omit to use /tsconfig.json by default - // use /path/to/folder/tsconfig.json - project: "path/to/folder", + // use /path/to/folder/tsconfig.json + project: 'path/to/folder', - // Multiple tsconfigs (Useful for monorepos) + // Multiple tsconfigs (Useful for monorepos) - // use a glob pattern - project: "packages/*/tsconfig.json", + // use a glob pattern + project: 'packages/*/tsconfig.json', - // use an array - project: [ - "packages/module-a/tsconfig.json", - "packages/module-b/tsconfig.json" - ], + // use an array + project: [ + 'packages/module-a/tsconfig.json', + 'packages/module-b/tsconfig.json', + ], - // use an array of glob patterns - project: [ - "packages/*/tsconfig.json", - "other-packages/*/tsconfig.json" - ] - }), - ] - } -}] + // use an array of glob patterns + project: [ + 'packages/*/tsconfig.json', + 'other-packages/*/tsconfig.json', + ], + + // use /jsconfig.json + project: 'jsconfig.json', + }), + ], + }, + }, +] ``` But if you are using `eslint-plugin-import` or the older version of `eslint-plugin-import-x`, you can't use require/import: ```js -// eslint.config.js -module.exports = [ +// eslint.config.js, CommonJS is also supported +export default [ { settings: { 'import/resolver': { @@ -137,6 +157,9 @@ module.exports = [ 'packages/*/tsconfig.json', 'other-packages/*/tsconfig.json', ], + + // use /jsconfig.json + project: 'jsconfig.json', }, }, }, @@ -153,11 +176,11 @@ Add the following to your `.eslintrc` config: "plugins": ["import"], "rules": { // turn on errors for missing imports - "import/no-unresolved": "error" + "import/no-unresolved": "error", }, "settings": { "import/parsers": { - "@typescript-eslint/parser": [".ts", ".tsx"] + "@typescript-eslint/parser": [".ts", ".tsx"], }, "import/resolver": { "typescript": { @@ -176,21 +199,24 @@ Add the following to your `.eslintrc` config: // use an array "project": [ "packages/module-a/tsconfig.json", - "packages/module-b/tsconfig.json" + "packages/module-b/tsconfig.json", ], // use an array of glob patterns "project": [ "packages/*/tsconfig.json", - "other-packages/*/tsconfig.json" - ] - } - } - } + "other-packages/*/tsconfig.json", + ], + + // use /jsconfig.json + "project": "jsconfig.json", + }, + }, + }, } ``` -## Options from [`enhanced-resolve`][] +## Options from [`rspack-resolver`][] ### `conditionNames` @@ -210,7 +236,7 @@ Default: "node", "node-addons", "browser", - "default" + "default", ] ``` @@ -227,7 +253,7 @@ Default: ".js", ".jsx", ".json", - ".node" + ".node", ] ``` @@ -242,11 +268,11 @@ Default: // `.tsx` can also be compiled as `.js` ".tsx", ".d.ts", - ".js" + ".js", ], ".jsx": [".tsx", ".d.ts", ".jsx"], ".cjs": [".cts", ".d.cts", ".cjs"], - ".mjs": [".mts", ".d.mts", ".mjs"] + ".mjs": [".mts", ".d.mts", ".mjs"], } ``` @@ -268,13 +294,13 @@ Default: "module", "jsnext:main", - "main" + "main", ] ``` ### Other options -You can pass through other options of [`enhanced-resolve`][] directly +You can pass through other options of [`rspack-resolver`][] directly ### Default options @@ -291,6 +317,8 @@ We have [GitHub Actions](https://github.com/import-js/eslint-import-resolver-typ If either fails, we won't be able to merge your PR until it's fixed. +[![Sponsors](https://raw.githubusercontent.com/1stG/static/master/sponsors.svg)](https://github.com/sponsors/JounQin) + ## Sponsors | 1stG | RxTS | UnTS | @@ -313,6 +341,6 @@ Detailed changes for each release are documented in [CHANGELOG.md](./CHANGELOG.m [`eslint-plugin-import`]: https://github.com/import-js/eslint-plugin-import [`eslint-plugin-import-x`]: https://github.com/un-ts/eslint-plugin-import-x -[`enhanced-resolve`]: https://github.com/webpack/enhanced-resolve +[`rspack-resolver`]: https://github.com/unrs/rspack-resolver [`typescript`]: https://www.typescriptlang.org [isc]: https://opensource.org/licenses/ISC diff --git a/node_modules/eslint-import-resolver-typescript/lib/constants.d.ts b/node_modules/eslint-import-resolver-typescript/lib/constants.d.ts new file mode 100644 index 0000000000..1b97e9a983 --- /dev/null +++ b/node_modules/eslint-import-resolver-typescript/lib/constants.d.ts @@ -0,0 +1,18 @@ +export declare const defaultConditionNames: string[]; +export declare const defaultExtensions: string[]; +export declare const defaultExtensionAlias: { + '.js': string[]; + '.jsx': string[]; + '.cjs': string[]; + '.mjs': string[]; +}; +export declare const defaultMainFields: string[]; +export declare const JS_EXT_PATTERN: RegExp; +export declare const IMPORT_RESOLVER_NAME = "eslint-import-resolver-typescript"; +export declare const interfaceVersion = 2; +export declare const DEFAULT_TSCONFIG = "tsconfig.json"; +export declare const DEFAULT_JSCONFIG = "jsconfig.json"; +export declare const DEFAULT_CONFIGS: string[]; +export declare const DEFAULT_TRY_PATHS: string[]; +export declare const MATCH_ALL = "**"; +export declare const DEFAULT_IGNORE: string; diff --git a/node_modules/eslint-import-resolver-typescript/lib/constants.js b/node_modules/eslint-import-resolver-typescript/lib/constants.js new file mode 100644 index 0000000000..dfd1128bbb --- /dev/null +++ b/node_modules/eslint-import-resolver-typescript/lib/constants.js @@ -0,0 +1,53 @@ +export const defaultConditionNames = [ + 'types', + 'import', + 'esm2020', + 'es2020', + 'es2015', + 'require', + 'node', + 'node-addons', + 'browser', + 'default', +]; +export const defaultExtensions = [ + '.ts', + '.tsx', + '.d.ts', + '.js', + '.jsx', + '.json', + '.node', +]; +export const defaultExtensionAlias = { + '.js': [ + '.ts', + '.tsx', + '.d.ts', + '.js', + ], + '.jsx': ['.tsx', '.d.ts', '.jsx'], + '.cjs': ['.cts', '.d.cts', '.cjs'], + '.mjs': ['.mts', '.d.mts', '.mjs'], +}; +export const defaultMainFields = [ + 'types', + 'typings', + 'fesm2020', + 'fesm2015', + 'esm2020', + 'es2020', + 'module', + 'jsnext:main', + 'main', +]; +export const JS_EXT_PATTERN = /\.(?:[cm]js|jsx?)$/; +export const IMPORT_RESOLVER_NAME = 'eslint-import-resolver-typescript'; +export const interfaceVersion = 2; +export const DEFAULT_TSCONFIG = 'tsconfig.json'; +export const DEFAULT_JSCONFIG = 'jsconfig.json'; +export const DEFAULT_CONFIGS = [DEFAULT_TSCONFIG, DEFAULT_JSCONFIG]; +export const DEFAULT_TRY_PATHS = ['', ...DEFAULT_CONFIGS]; +export const MATCH_ALL = '**'; +export const DEFAULT_IGNORE = [MATCH_ALL, 'node_modules', MATCH_ALL].join('/'); +//# sourceMappingURL=constants.js.map \ No newline at end of file diff --git a/node_modules/eslint-import-resolver-typescript/lib/constants.js.map b/node_modules/eslint-import-resolver-typescript/lib/constants.js.map new file mode 100644 index 0000000000..01c8aa9a46 --- /dev/null +++ b/node_modules/eslint-import-resolver-typescript/lib/constants.js.map @@ -0,0 +1 @@ +{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,OAAO;IACP,QAAQ;IAGR,SAAS;IACT,QAAQ;IACR,QAAQ;IAER,SAAS;IACT,MAAM;IACN,aAAa;IACb,SAAS;IACT,SAAS;CACV,CAAA;AAKD,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,KAAK;IACL,MAAM;IACN,OAAO;IACP,KAAK;IACL,MAAM;IACN,OAAO;IACP,OAAO;CACR,CAAA;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,KAAK,EAAE;QACL,KAAK;QAEL,MAAM;QACN,OAAO;QACP,KAAK;KACN;IACD,MAAM,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC;IACjC,MAAM,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC;IAClC,MAAM,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC;CACnC,CAAA;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,OAAO;IACP,SAAS;IAGT,UAAU;IACV,UAAU;IACV,SAAS;IACT,QAAQ;IAER,QAAQ;IACR,aAAa;IAEb,MAAM;CACP,CAAA;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,oBAAoB,CAAA;AAElD,MAAM,CAAC,MAAM,oBAAoB,GAAG,mCAAmC,CAAA;AAEvE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAA;AAEjC,MAAM,CAAC,MAAM,gBAAgB,GAAG,eAAe,CAAA;AAE/C,MAAM,CAAC,MAAM,gBAAgB,GAAG,eAAe,CAAA;AAE/C,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,CAAA;AAEnE,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAAE,EAAE,GAAG,eAAe,CAAC,CAAA;AAEzD,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,CAAA;AAE7B,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,SAAS,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA"} \ No newline at end of file diff --git a/node_modules/eslint-import-resolver-typescript/lib/helpers.d.ts b/node_modules/eslint-import-resolver-typescript/lib/helpers.d.ts new file mode 100644 index 0000000000..52c56ebf0d --- /dev/null +++ b/node_modules/eslint-import-resolver-typescript/lib/helpers.d.ts @@ -0,0 +1,6 @@ +export declare function mangleScopedPackage(moduleName: string): string; +export declare function removeQuerystring(id: string): string; +export declare const tryFile: (filename?: string[] | string, includeDir?: boolean, base?: string) => string; +export declare const sortProjectsByAffinity: (projects: string[], file: string) => string[]; +export declare const toGlobPath: (pathname: string) => string; +export declare const toNativePath: (pathname: string) => string; diff --git a/node_modules/eslint-import-resolver-typescript/lib/helpers.js b/node_modules/eslint-import-resolver-typescript/lib/helpers.js new file mode 100644 index 0000000000..ec11ab849c --- /dev/null +++ b/node_modules/eslint-import-resolver-typescript/lib/helpers.js @@ -0,0 +1,56 @@ +import fs from 'node:fs'; +import path from 'node:path'; +export function mangleScopedPackage(moduleName) { + if (moduleName.startsWith('@')) { + const replaceSlash = moduleName.replace('/', '__'); + if (replaceSlash !== moduleName) { + return replaceSlash.slice(1); + } + } + return moduleName; +} +export function removeQuerystring(id) { + const querystringIndex = id.lastIndexOf('?'); + if (querystringIndex !== -1) { + return id.slice(0, querystringIndex); + } + return id; +} +export const tryFile = (filename, includeDir = false, base = process.cwd()) => { + if (typeof filename === 'string') { + const filepath = path.resolve(base, filename); + return fs.existsSync(filepath) && + (includeDir || fs.statSync(filepath).isFile()) + ? filepath + : ''; + } + for (const file of filename ?? []) { + const filepath = tryFile(file, includeDir, base); + if (filepath) { + return filepath; + } + } + return ''; +}; +const computeAffinity = (projectDir, targetDir) => { + const a = projectDir.split(path.sep); + const b = targetDir.split(path.sep); + let lca = 0; + while (lca < a.length && lca < b.length && a[lca] === b[lca]) { + lca++; + } + return a.length - lca + (b.length - lca); +}; +export const sortProjectsByAffinity = (projects, file) => { + const fileDir = path.dirname(file); + return projects + .map(project => ({ + project, + affinity: computeAffinity(path.dirname(project), fileDir), + })) + .sort((a, b) => a.affinity - b.affinity) + .map(item => item.project); +}; +export const toGlobPath = (pathname) => pathname.replaceAll('\\', '/'); +export const toNativePath = (pathname) => '/' === path.sep ? pathname : pathname.replaceAll('/', '\\'); +//# sourceMappingURL=helpers.js.map \ No newline at end of file diff --git a/node_modules/eslint-import-resolver-typescript/lib/helpers.js.map b/node_modules/eslint-import-resolver-typescript/lib/helpers.js.map new file mode 100644 index 0000000000..ce3e3098ec --- /dev/null +++ b/node_modules/eslint-import-resolver-typescript/lib/helpers.js.map @@ -0,0 +1 @@ +{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"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"} \ No newline at end of file diff --git a/node_modules/eslint-import-resolver-typescript/lib/index.cjs b/node_modules/eslint-import-resolver-typescript/lib/index.cjs index 6ae3761cbd..68c9cb36d7 100644 --- a/node_modules/eslint-import-resolver-typescript/lib/index.cjs +++ b/node_modules/eslint-import-resolver-typescript/lib/index.cjs @@ -1,37 +1,15 @@ 'use strict'; -var fs = require('node:fs'); +var module$1 = require('node:module'); var path = require('node:path'); -var isNodeCoreModule = require('@nolyfill/is-core-module'); -var debug = require('debug'); -var enhancedResolve = require('enhanced-resolve'); var getTsconfig = require('get-tsconfig'); var isBunModule = require('is-bun-module'); -var stableHashExports = require('stable-hash'); +var rspackResolver = require('rspack-resolver'); +var stableHash = require('stable-hash'); +var fs = require('node:fs'); +var debug = require('debug'); var tinyglobby = require('tinyglobby'); -var __defProp = Object.defineProperty; -var __defProps = Object.defineProperties; -var __getOwnPropDescs = Object.getOwnPropertyDescriptors; -var __getOwnPropSymbols = Object.getOwnPropertySymbols; -var __hasOwnProp = Object.prototype.hasOwnProperty; -var __propIsEnum = Object.prototype.propertyIsEnumerable; -var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; -var __spreadValues = (a, b) => { - for (var prop in b || (b = {})) - if (__hasOwnProp.call(b, prop)) - __defNormalProp(a, prop, b[prop]); - if (__getOwnPropSymbols) - for (var prop of __getOwnPropSymbols(b)) { - if (__propIsEnum.call(b, prop)) - __defNormalProp(a, prop, b[prop]); - } - return a; -}; -var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); -const stableHash = stableHashExports.default || stableHashExports; -const IMPORTER_NAME = "eslint-import-resolver-typescript"; -const log = debug(IMPORTER_NAME); const defaultConditionNames = [ "types", "import", @@ -78,288 +56,349 @@ const defaultMainFields = [ "jsnext:main", "main" ]; -const interfaceVersion = 2; -const fileSystem = fs; const JS_EXT_PATTERN = /\.(?:[cm]js|jsx?)$/; -const RELATIVE_PATH_PATTERN = /^\.{1,2}(?:\/.*)?$/; -let previousOptionsHash; -let optionsHash; -let cachedOptions; -let prevCwd; -let mappersCachedOptions; -let mappers = []; -let resolverCachedOptions; -let cachedResolver; -function resolve(source, file, options, resolver = null) { - var _a, _b, _c, _d, _e; - if (!cachedOptions || previousOptionsHash !== (optionsHash = stableHash(options))) { - previousOptionsHash = optionsHash; - cachedOptions = __spreadProps(__spreadValues({}, options), { - conditionNames: (_a = options == null ? void 0 : options.conditionNames) != null ? _a : defaultConditionNames, - extensions: (_b = options == null ? void 0 : options.extensions) != null ? _b : defaultExtensions, - extensionAlias: (_c = options == null ? void 0 : options.extensionAlias) != null ? _c : defaultExtensionAlias, - mainFields: (_d = options == null ? void 0 : options.mainFields) != null ? _d : defaultMainFields, - fileSystem: new enhancedResolve.CachedInputFileSystem( - fileSystem, - 5 * 1e3 - ), - useSyncFileSystemCalls: true - }); - } - if (!resolver) { - if (!cachedResolver || resolverCachedOptions !== cachedOptions) { - cachedResolver = enhancedResolve.ResolverFactory.createResolver(cachedOptions); - resolverCachedOptions = cachedOptions; +const IMPORT_RESOLVER_NAME = "eslint-import-resolver-typescript"; +const interfaceVersion = 2; +const DEFAULT_TSCONFIG = "tsconfig.json"; +const DEFAULT_JSCONFIG = "jsconfig.json"; +const DEFAULT_CONFIGS = [DEFAULT_TSCONFIG, DEFAULT_JSCONFIG]; +const DEFAULT_TRY_PATHS = ["", ...DEFAULT_CONFIGS]; +const MATCH_ALL = "**"; +const DEFAULT_IGNORE = [MATCH_ALL, "node_modules", MATCH_ALL].join("/"); + +function mangleScopedPackage(moduleName) { + if (moduleName.startsWith("@")) { + const replaceSlash = moduleName.replace("/", "__"); + if (replaceSlash !== moduleName) { + return replaceSlash.slice(1); } - resolver = cachedResolver; } - log("looking for", source, "in", file); - source = removeQuerystring(source); - if (isNodeCoreModule(source) || isBunModule.isBunModule(source, (_e = process.versions.bun) != null ? _e : "latest")) { - log("matched core:", source); - return { - found: true, - path: null - }; + return moduleName; +} +function removeQuerystring(id) { + const querystringIndex = id.lastIndexOf("?"); + if (querystringIndex !== -1) { + return id.slice(0, querystringIndex); } - initMappers(cachedOptions); - const mappedPath = getMappedPath(source, file, cachedOptions.extensions, true); - if (mappedPath) { - log("matched ts path:", mappedPath); + return id; +} +const tryFile = (filename, includeDir = false, base = process.cwd()) => { + if (typeof filename === "string") { + const filepath = path.resolve(base, filename); + return fs.existsSync(filepath) && (includeDir || fs.statSync(filepath).isFile()) ? filepath : ""; } - let foundNodePath; - try { - foundNodePath = resolver.resolveSync( - {}, - path.dirname(path.resolve(file)), - mappedPath != null ? mappedPath : source - ) || null; - } catch (e) { - foundNodePath = null; + for (const file of filename != null ? filename : []) { + const filepath = tryFile(file, includeDir, base); + if (filepath) { + return filepath; + } } - if ((JS_EXT_PATTERN.test(foundNodePath) || cachedOptions.alwaysTryTypes && !foundNodePath) && !/^@types[/\\]/.test(source) && !path.isAbsolute(source) && !source.startsWith(".")) { - const definitelyTyped = resolve( - "@types" + path.sep + mangleScopedPackage(source), - file, - options + return ""; +}; +const computeAffinity = (projectDir, targetDir) => { + const a = projectDir.split(path.sep); + const b = targetDir.split(path.sep); + let lca = 0; + while (lca < a.length && lca < b.length && a[lca] === b[lca]) { + lca++; + } + return a.length - lca + (b.length - lca); +}; +const sortProjectsByAffinity = (projects, file) => { + const fileDir = path.dirname(file); + return projects.map((project) => ({ + project, + affinity: computeAffinity(path.dirname(project), fileDir) + })).sort((a, b) => a.affinity - b.affinity).map((item) => item.project); +}; +const toGlobPath = (pathname) => pathname.replaceAll("\\", "/"); +const toNativePath = (pathname) => "/" === path.sep ? pathname : pathname.replaceAll("/", "\\"); + +const log = debug(IMPORT_RESOLVER_NAME); + +var __defProp$1 = Object.defineProperty; +var __defProps$1 = Object.defineProperties; +var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors; +var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols; +var __hasOwnProp$1 = Object.prototype.hasOwnProperty; +var __propIsEnum$1 = Object.prototype.propertyIsEnumerable; +var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __spreadValues$1 = (a, b) => { + for (var prop in b || (b = {})) + if (__hasOwnProp$1.call(b, prop)) + __defNormalProp$1(a, prop, b[prop]); + if (__getOwnPropSymbols$1) + for (var prop of __getOwnPropSymbols$1(b)) { + if (__propIsEnum$1.call(b, prop)) + __defNormalProp$1(a, prop, b[prop]); + } + return a; +}; +var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b)); +exports.defaultConfigFile = void 0; +const configFileMapping = /* @__PURE__ */ new Map(); +let warned; +function normalizeOptions(options, cwd = process.cwd()) { + let { project, tsconfig, noWarnOnMultipleProjects } = options || (options = {}); + let { configFile, references } = tsconfig != null ? tsconfig : {}; + let ensured; + if (configFile) { + configFile = tryFile(configFile); + ensured = true; + } else if (project) { + log("original projects:", ...project); + project = (Array.isArray(project) ? project : [project]).map(toGlobPath); + if (project.some((p) => tinyglobby.isDynamicPattern(p))) { + project = tinyglobby.globSync(project, { + absolute: true, + cwd, + dot: true, + expandDirectories: false, + onlyFiles: false, + ignore: DEFAULT_IGNORE + }); + } + log("resolving projects:", ...project); + project = project.flatMap( + (p) => tryFile(DEFAULT_TRY_PATHS, false, toNativePath(p)) || [] ); - if (definitelyTyped.found) { - return definitelyTyped; + log("resolved projects:", ...project); + if (project.length === 1) { + configFile = project[0]; + ensured = true; + } + if (project.length <= 1) { + project = void 0; + } else if (!warned && !noWarnOnMultipleProjects) { + warned = true; + console.warn( + "Multiple projects found, consider using a single `tsconfig` with `references` to speed up, or use `noWarnOnMultipleProjects` to suppress this warning" + ); + } + } + if (!project && !configFile) { + configFile = exports.defaultConfigFile || (exports.defaultConfigFile = tryFile(DEFAULT_CONFIGS)); + ensured = true; + } + if (configFile) { + const cachedOptions = configFileMapping.get(configFile); + if (cachedOptions) { + log("using cached options for", configFile); + return cachedOptions; + } + } + if (!ensured && configFile && configFile !== exports.defaultConfigFile) { + configFile = tryFile(DEFAULT_TRY_PATHS, false, configFile); + } + options = __spreadProps$1(__spreadValues$1({ + conditionNames: defaultConditionNames, + extensions: defaultExtensions, + extensionAlias: defaultExtensionAlias, + mainFields: defaultMainFields + }, options), { + project, + tsconfig: { + references: references != null ? references : "auto", + configFile: configFile || "" } + }); + if (configFile) { + configFileMapping.set(configFile, options); } - if (foundNodePath) { - log("matched node path:", foundNodePath); + return options; +} + +var __defProp = Object.defineProperty; +var __defProps = Object.defineProperties; +var __getOwnPropDescs = Object.getOwnPropertyDescriptors; +var __getOwnPropSymbols = Object.getOwnPropertySymbols; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __propIsEnum = Object.prototype.propertyIsEnumerable; +var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __spreadValues = (a, b) => { + for (var prop in b || (b = {})) + if (__hasOwnProp.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + if (__getOwnPropSymbols) + for (var prop of __getOwnPropSymbols(b)) { + if (__propIsEnum.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + } + return a; +}; +var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); +const resolverCache = /* @__PURE__ */ new Map(); +const tsconfigCache = /* @__PURE__ */ new Map(); +const matcherCache = /* @__PURE__ */ new Map(); +const oxcResolve = (source, file, resolver) => { + const result = resolver.sync(path.dirname(file), source); + if (result.path) { return { found: true, - path: foundNodePath + path: result.path }; } - log("didn't find ", source); + if (result.error) { + log("oxc resolve error:", result.error); + } return { found: false }; -} -function createTypeScriptImportResolver(options) { - var _a, _b, _c, _d; - const resolver = enhancedResolve.ResolverFactory.createResolver(__spreadProps(__spreadValues({}, options), { - conditionNames: (_a = options == null ? void 0 : options.conditionNames) != null ? _a : defaultConditionNames, - extensions: (_b = options == null ? void 0 : options.extensions) != null ? _b : defaultExtensions, - extensionAlias: (_c = options == null ? void 0 : options.extensionAlias) != null ? _c : defaultExtensionAlias, - mainFields: (_d = options == null ? void 0 : options.mainFields) != null ? _d : defaultMainFields, - fileSystem: new enhancedResolve.CachedInputFileSystem(fileSystem, 5 * 1e3), - useSyncFileSystemCalls: true - })); - return { - interfaceVersion: 3, - name: IMPORTER_NAME, - resolve(source, file) { - return resolve(source, file, options, resolver); +}; +const resolve = (source, file, options, resolver) => { + var _a; + options || (options = {}); + let bunVersion = process.versions.bun; + if (bunVersion || options.bun) { + if (bunVersion ? module$1.isBuiltin(source) : isBunModule.isBunModule(source, bunVersion = "latest") || isBunModule.isSupportedNodeModule(source, bunVersion)) { + log("matched bun core:", source); + return { found: true, path: null }; } - }; -} -function removeQuerystring(id) { - const querystringIndex = id.lastIndexOf("?"); - if (querystringIndex >= 0) { - return id.slice(0, querystringIndex); + } else if (module$1.isBuiltin(source)) { + log("matched node core:", source); + return { found: true, path: null }; } - return id; -} -const isFile = (path2) => { - var _a; - try { - return !!(path2 && ((_a = fs.statSync(path2, { throwIfNoEntry: false })) == null ? void 0 : _a.isFile())); - } catch (e) { - return false; + if (process.versions.pnp && source === "pnpapi") { + return { + found: true, + path: module$1.findPnpApi(file).resolveToUnqualified(source, file, { considerBuiltins: false }) + }; } -}; -const isModule = (modulePath) => { - return !!modulePath && isFile(path.resolve(modulePath, "package.json")); -}; -function getMappedPath(source, file, extensions = defaultExtensions, retry) { - const originalExtensions = extensions; - extensions = ["", ...extensions]; - let paths = []; - if (RELATIVE_PATH_PATTERN.test(source)) { - const resolved = path.resolve(path.dirname(file), source); - if (isFile(resolved)) { - paths = [resolved]; + source = removeQuerystring(source); + if (!resolver) { + const optionsHash = stableHash.stableHash(options); + const cwd = process.cwd(); + options = normalizeOptions(options, cwd); + const cacheKey = `${optionsHash}:${cwd}`; + let cached = resolverCache.get(cacheKey); + if (!cached && !options.project) { + resolverCache.set(cacheKey, cached = new rspackResolver.ResolverFactory(options)); } - } else { - paths = [ - ...new Set( - mappers.filter(({ files }) => files.has(file)).map( - ({ mapperFn }) => mapperFn(source).map((item) => [ - ...extensions.map((ext) => `${item}${ext}`), - ...originalExtensions.map((ext) => `${item}/index${ext}`) - ]) - ).flat(2).map(toNativePathSeparator) - ) - ].filter((mappedPath) => { - try { - const stat = fs.statSync(mappedPath, { throwIfNoEntry: false }); - if (stat === void 0) - return false; - if (stat.isFile()) - return true; - if (stat.isDirectory()) { - return isModule(mappedPath); + resolver = cached; + } + options || (options = {}); + createResolver: + if (!resolver) { + const project = options.project; + for (const tsconfigPath of project) { + const resolverCached = resolverCache.get(tsconfigPath); + if (resolverCached) { + resolver = resolverCached; + break createResolver; + } + let tsconfigCached = tsconfigCache.get(tsconfigPath); + if (!tsconfigCached) { + tsconfigCache.set( + tsconfigPath, + tsconfigCached = getTsconfig.parseTsconfig(tsconfigPath) + ); + } + let matcherCached = matcherCache.get(tsconfigPath); + if (!matcherCached) { + matcherCache.set( + tsconfigPath, + matcherCached = getTsconfig.createFilesMatcher({ + config: tsconfigCached, + path: tsconfigPath + }) + ); } - } catch (e) { - return false; + const tsconfig = matcherCached(file); + if (!tsconfig) { + log("tsconfig", tsconfigPath, "does not match", file); + continue; + } + log("matched tsconfig at:", tsconfigPath, "for", file); + options = __spreadProps(__spreadValues({}, options), { + tsconfig: __spreadProps(__spreadValues({ + references: "auto" + }, options.tsconfig), { + configFile: tsconfigPath + }) + }); + resolver = new rspackResolver.ResolverFactory(options); + resolverCache.set(tsconfigPath, resolver); + break createResolver; } - return false; - }); - } - if (retry && paths.length === 0) { - const isJs = JS_EXT_PATTERN.test(source); - if (isJs) { - const jsExt = path.extname(source); - const tsExt = jsExt.replace("js", "ts"); - const basename = source.replace(JS_EXT_PATTERN, ""); - const resolved = getMappedPath(basename + tsExt, file) || getMappedPath( - basename + ".d" + (tsExt === ".tsx" ? ".ts" : tsExt), - file + log( + "no tsconfig matched", + file, + "with", + ...project, + ", trying from the the nearest one" ); - if (resolved) { - return resolved; - } - } - for (const ext of extensions) { - const resolved = (isJs ? null : getMappedPath(source + ext, file)) || getMappedPath(source + `/index${ext}`, file); - if (resolved) { - return resolved; - } - } - } - if (paths.length > 1) { - log("found multiple matching ts paths:", paths); - } - return paths[0]; -} -function initMappers(options) { - if (mappers.length > 0 && mappersCachedOptions === options && prevCwd === process.cwd()) { - return; - } - prevCwd = process.cwd(); - const configPaths = (typeof options.project === "string" ? [options.project] : Array.isArray(options.project) ? options.project : [process.cwd()]).map((config) => replacePathSeparator(config, path.sep, path.posix.sep)); - const defaultInclude = ["**/*"]; - const defaultIgnore = ["**/node_modules/**"]; - const projectPaths = [ - .../* @__PURE__ */ new Set([ - ...configPaths.filter((path2) => !tinyglobby.isDynamicPattern(path2)), - ...tinyglobby.globSync( - configPaths.filter((path2) => tinyglobby.isDynamicPattern(path2)), - { - absolute: true, - dot: true, - expandDirectories: false, - ignore: defaultIgnore + for (const p of sortProjectsByAffinity(project, file)) { + const resolved2 = resolve( + source, + file, + __spreadProps(__spreadValues({}, options), { project: p }), + resolver + ); + if (resolved2.found) { + return resolved2; } - ) - ]) - ]; - mappers = projectPaths.map((projectPath) => { - var _a, _b; - let tsconfigResult; - if (isFile(projectPath)) { - const { dir, base } = path.parse(projectPath); - tsconfigResult = getTsconfig.getTsconfig(dir, base); - } else { - tsconfigResult = getTsconfig.getTsconfig(projectPath); - } - if (!tsconfigResult) { - return void 0; - } - const mapperFn = getTsconfig.createPathsMatcher(tsconfigResult); - if (!mapperFn) { - return void 0; - } - const files = tsconfigResult.config.files === void 0 && tsconfigResult.config.include === void 0 ? ( - // Include everything if no files or include options - tinyglobby.globSync(defaultInclude, { - absolute: true, - cwd: path.dirname(tsconfigResult.path), - dot: true, - ignore: [ - ...(_a = tsconfigResult.config.exclude) != null ? _a : [], - ...defaultIgnore - ] - }) - ) : [ - // https://www.typescriptlang.org/tsconfig/#files - ...tsconfigResult.config.files !== void 0 && tsconfigResult.config.files.length > 0 ? tsconfigResult.config.files.map( - (file) => path.normalize( - path.resolve(path.dirname(tsconfigResult.path), file) - ) - ) : [], - // https://www.typescriptlang.org/tsconfig/#include - ...tsconfigResult.config.include !== void 0 && tsconfigResult.config.include.length > 0 ? tinyglobby.globSync(tsconfigResult.config.include, { - absolute: true, - cwd: path.dirname(tsconfigResult.path), - dot: true, - ignore: [ - ...(_b = tsconfigResult.config.exclude) != null ? _b : [], - ...defaultIgnore - ] - }) : [] - ]; - if (files.length === 0) { - return void 0; + } } + if (!resolver) { return { - files: new Set(files.map(toNativePathSeparator)), - mapperFn + found: false }; - }).filter(isDefined); - mappersCachedOptions = options; -} -function mangleScopedPackage(moduleName) { - if (moduleName.startsWith("@")) { - const replaceSlash = moduleName.replace(path.sep, "__"); - if (replaceSlash !== moduleName) { - return replaceSlash.slice(1); + } + const resolved = oxcResolve(source, file, resolver); + const foundPath = resolved.path; + if ((foundPath && JS_EXT_PATTERN.test(foundPath) || options.alwaysTryTypes !== false && !foundPath) && !/^@types[/\\]/.test(source) && !path.isAbsolute(source) && !source.startsWith(".")) { + const definitelyTyped = oxcResolve( + "@types/" + mangleScopedPackage(source), + file, + resolver + ); + if (definitelyTyped.found) { + return definitelyTyped; } } - return moduleName; -} -function replacePathSeparator(p, from, to) { - return from === to ? p : p.replaceAll(from, to); -} -function toNativePathSeparator(p) { - return replacePathSeparator( - p, - path[process.platform === "win32" ? "posix" : "win32"].sep, - path[process.platform === "win32" ? "win32" : "posix"].sep - ); -} -function isDefined(value) { - return value !== null && value !== void 0; -} + if (foundPath) { + log("matched path:", foundPath); + } else { + log( + "didn't find", + source, + "with", + ((_a = options.tsconfig) == null ? void 0 : _a.configFile) || options.project + ); + } + return resolved; +}; +const createTypeScriptImportResolver = (options) => { + options = normalizeOptions(options); + const resolver = options.project ? null : new rspackResolver.ResolverFactory(options); + return { + interfaceVersion: 3, + name: IMPORT_RESOLVER_NAME, + resolve(source, file) { + return resolve(source, file, options, resolver); + } + }; +}; +exports.DEFAULT_CONFIGS = DEFAULT_CONFIGS; +exports.DEFAULT_IGNORE = DEFAULT_IGNORE; +exports.DEFAULT_JSCONFIG = DEFAULT_JSCONFIG; +exports.DEFAULT_TRY_PATHS = DEFAULT_TRY_PATHS; +exports.DEFAULT_TSCONFIG = DEFAULT_TSCONFIG; +exports.IMPORT_RESOLVER_NAME = IMPORT_RESOLVER_NAME; +exports.JS_EXT_PATTERN = JS_EXT_PATTERN; +exports.MATCH_ALL = MATCH_ALL; exports.createTypeScriptImportResolver = createTypeScriptImportResolver; exports.defaultConditionNames = defaultConditionNames; exports.defaultExtensionAlias = defaultExtensionAlias; exports.defaultExtensions = defaultExtensions; exports.defaultMainFields = defaultMainFields; exports.interfaceVersion = interfaceVersion; +exports.mangleScopedPackage = mangleScopedPackage; +exports.normalizeOptions = normalizeOptions; +exports.removeQuerystring = removeQuerystring; exports.resolve = resolve; +exports.sortProjectsByAffinity = sortProjectsByAffinity; +exports.toGlobPath = toGlobPath; +exports.toNativePath = toNativePath; +exports.tryFile = tryFile; diff --git a/node_modules/eslint-import-resolver-typescript/lib/index.d.ts b/node_modules/eslint-import-resolver-typescript/lib/index.d.ts index 668d6163e3..cc9a7bc4e2 100644 --- a/node_modules/eslint-import-resolver-typescript/lib/index.d.ts +++ b/node_modules/eslint-import-resolver-typescript/lib/index.d.ts @@ -1,28 +1,13 @@ -import type { ResolveOptions, Resolver } from 'enhanced-resolve'; -export declare const defaultConditionNames: string[]; -export declare const defaultExtensions: string[]; -export declare const defaultExtensionAlias: { - '.js': string[]; - '.jsx': string[]; - '.cjs': string[]; - '.mjs': string[]; -}; -export declare const defaultMainFields: string[]; -export declare const interfaceVersion = 2; -export interface TsResolverOptions extends Omit { - alwaysTryTypes?: boolean; - project?: string[] | string; - extensions?: string[]; -} -export declare function resolve(source: string, file: string, options?: TsResolverOptions | null, resolver?: Resolver | null): { - found: boolean; - path?: string | null; -}; -export declare function createTypeScriptImportResolver(options?: TsResolverOptions | null): { +import type { ResolvedResult } from 'eslint-plugin-import-x/types.js'; +import { ResolverFactory } from 'rspack-resolver'; +import type { TypeScriptResolverOptions } from './types.js'; +export * from './constants.js'; +export * from './helpers.js'; +export * from './normalize-options.js'; +export type * from './types.js'; +export declare const resolve: (source: string, file: string, options?: TypeScriptResolverOptions | null, resolver?: ResolverFactory | null) => ResolvedResult; +export declare const createTypeScriptImportResolver: (options?: TypeScriptResolverOptions | null) => { interfaceVersion: number; name: string; - resolve(source: string, file: string): { - found: boolean; - path?: string | null | undefined; - }; + resolve(source: string, file: string): ResolvedResult; }; diff --git a/node_modules/eslint-import-resolver-typescript/lib/index.es2020.mjs b/node_modules/eslint-import-resolver-typescript/lib/index.es2020.mjs deleted file mode 100644 index 9102aa36b5..0000000000 --- a/node_modules/eslint-import-resolver-typescript/lib/index.es2020.mjs +++ /dev/null @@ -1,336 +0,0 @@ -import fs from 'node:fs'; -import path from 'node:path'; -import isNodeCoreModule from '@nolyfill/is-core-module'; -import debug from 'debug'; -import enhancedResolve from 'enhanced-resolve'; -import { getTsconfig, createPathsMatcher } from 'get-tsconfig'; -import { isBunModule } from 'is-bun-module'; -import stableHashExports from 'stable-hash'; -import { isDynamicPattern, globSync } from 'tinyglobby'; - -const stableHash = stableHashExports.default || stableHashExports; -const IMPORTER_NAME = "eslint-import-resolver-typescript"; -const log = debug(IMPORTER_NAME); -const defaultConditionNames = [ - "types", - "import", - // APF: https://angular.io/guide/angular-package-format - "esm2020", - "es2020", - "es2015", - "require", - "node", - "node-addons", - "browser", - "default" -]; -const defaultExtensions = [ - ".ts", - ".tsx", - ".d.ts", - ".js", - ".jsx", - ".json", - ".node" -]; -const defaultExtensionAlias = { - ".js": [ - ".ts", - // `.tsx` can also be compiled as `.js` - ".tsx", - ".d.ts", - ".js" - ], - ".jsx": [".tsx", ".d.ts", ".jsx"], - ".cjs": [".cts", ".d.cts", ".cjs"], - ".mjs": [".mts", ".d.mts", ".mjs"] -}; -const defaultMainFields = [ - "types", - "typings", - // APF: https://angular.io/guide/angular-package-format - "fesm2020", - "fesm2015", - "esm2020", - "es2020", - "module", - "jsnext:main", - "main" -]; -const interfaceVersion = 2; -const fileSystem = fs; -const JS_EXT_PATTERN = /\.(?:[cm]js|jsx?)$/; -const RELATIVE_PATH_PATTERN = /^\.{1,2}(?:\/.*)?$/; -let previousOptionsHash; -let optionsHash; -let cachedOptions; -let prevCwd; -let mappersCachedOptions; -let mappers = []; -let resolverCachedOptions; -let cachedResolver; -function resolve(source, file, options, resolver = null) { - if (!cachedOptions || previousOptionsHash !== (optionsHash = stableHash(options))) { - previousOptionsHash = optionsHash; - cachedOptions = { - ...options, - conditionNames: options?.conditionNames ?? defaultConditionNames, - extensions: options?.extensions ?? defaultExtensions, - extensionAlias: options?.extensionAlias ?? defaultExtensionAlias, - mainFields: options?.mainFields ?? defaultMainFields, - fileSystem: new enhancedResolve.CachedInputFileSystem( - fileSystem, - 5 * 1e3 - ), - useSyncFileSystemCalls: true - }; - } - if (!resolver) { - if (!cachedResolver || resolverCachedOptions !== cachedOptions) { - cachedResolver = enhancedResolve.ResolverFactory.createResolver(cachedOptions); - resolverCachedOptions = cachedOptions; - } - resolver = cachedResolver; - } - log("looking for", source, "in", file); - source = removeQuerystring(source); - if (isNodeCoreModule(source) || isBunModule(source, process.versions.bun ?? "latest")) { - log("matched core:", source); - return { - found: true, - path: null - }; - } - initMappers(cachedOptions); - const mappedPath = getMappedPath(source, file, cachedOptions.extensions, true); - if (mappedPath) { - log("matched ts path:", mappedPath); - } - let foundNodePath; - try { - foundNodePath = resolver.resolveSync( - {}, - path.dirname(path.resolve(file)), - mappedPath ?? source - ) || null; - } catch { - foundNodePath = null; - } - if ((JS_EXT_PATTERN.test(foundNodePath) || cachedOptions.alwaysTryTypes && !foundNodePath) && !/^@types[/\\]/.test(source) && !path.isAbsolute(source) && !source.startsWith(".")) { - const definitelyTyped = resolve( - "@types" + path.sep + mangleScopedPackage(source), - file, - options - ); - if (definitelyTyped.found) { - return definitelyTyped; - } - } - if (foundNodePath) { - log("matched node path:", foundNodePath); - return { - found: true, - path: foundNodePath - }; - } - log("didn't find ", source); - return { - found: false - }; -} -function createTypeScriptImportResolver(options) { - const resolver = enhancedResolve.ResolverFactory.createResolver({ - ...options, - conditionNames: options?.conditionNames ?? defaultConditionNames, - extensions: options?.extensions ?? defaultExtensions, - extensionAlias: options?.extensionAlias ?? defaultExtensionAlias, - mainFields: options?.mainFields ?? defaultMainFields, - fileSystem: new enhancedResolve.CachedInputFileSystem(fileSystem, 5 * 1e3), - useSyncFileSystemCalls: true - }); - return { - interfaceVersion: 3, - name: IMPORTER_NAME, - resolve(source, file) { - return resolve(source, file, options, resolver); - } - }; -} -function removeQuerystring(id) { - const querystringIndex = id.lastIndexOf("?"); - if (querystringIndex >= 0) { - return id.slice(0, querystringIndex); - } - return id; -} -const isFile = (path2) => { - try { - return !!(path2 && fs.statSync(path2, { throwIfNoEntry: false })?.isFile()); - } catch { - return false; - } -}; -const isModule = (modulePath) => { - return !!modulePath && isFile(path.resolve(modulePath, "package.json")); -}; -function getMappedPath(source, file, extensions = defaultExtensions, retry) { - const originalExtensions = extensions; - extensions = ["", ...extensions]; - let paths = []; - if (RELATIVE_PATH_PATTERN.test(source)) { - const resolved = path.resolve(path.dirname(file), source); - if (isFile(resolved)) { - paths = [resolved]; - } - } else { - paths = [ - ...new Set( - mappers.filter(({ files }) => files.has(file)).map( - ({ mapperFn }) => mapperFn(source).map((item) => [ - ...extensions.map((ext) => `${item}${ext}`), - ...originalExtensions.map((ext) => `${item}/index${ext}`) - ]) - ).flat(2).map(toNativePathSeparator) - ) - ].filter((mappedPath) => { - try { - const stat = fs.statSync(mappedPath, { throwIfNoEntry: false }); - if (stat === void 0) - return false; - if (stat.isFile()) - return true; - if (stat.isDirectory()) { - return isModule(mappedPath); - } - } catch { - return false; - } - return false; - }); - } - if (retry && paths.length === 0) { - const isJs = JS_EXT_PATTERN.test(source); - if (isJs) { - const jsExt = path.extname(source); - const tsExt = jsExt.replace("js", "ts"); - const basename = source.replace(JS_EXT_PATTERN, ""); - const resolved = getMappedPath(basename + tsExt, file) || getMappedPath( - basename + ".d" + (tsExt === ".tsx" ? ".ts" : tsExt), - file - ); - if (resolved) { - return resolved; - } - } - for (const ext of extensions) { - const resolved = (isJs ? null : getMappedPath(source + ext, file)) || getMappedPath(source + `/index${ext}`, file); - if (resolved) { - return resolved; - } - } - } - if (paths.length > 1) { - log("found multiple matching ts paths:", paths); - } - return paths[0]; -} -function initMappers(options) { - if (mappers.length > 0 && mappersCachedOptions === options && prevCwd === process.cwd()) { - return; - } - prevCwd = process.cwd(); - const configPaths = (typeof options.project === "string" ? [options.project] : Array.isArray(options.project) ? options.project : [process.cwd()]).map((config) => replacePathSeparator(config, path.sep, path.posix.sep)); - const defaultInclude = ["**/*"]; - const defaultIgnore = ["**/node_modules/**"]; - const projectPaths = [ - .../* @__PURE__ */ new Set([ - ...configPaths.filter((path2) => !isDynamicPattern(path2)), - ...globSync( - configPaths.filter((path2) => isDynamicPattern(path2)), - { - absolute: true, - dot: true, - expandDirectories: false, - ignore: defaultIgnore - } - ) - ]) - ]; - mappers = projectPaths.map((projectPath) => { - let tsconfigResult; - if (isFile(projectPath)) { - const { dir, base } = path.parse(projectPath); - tsconfigResult = getTsconfig(dir, base); - } else { - tsconfigResult = getTsconfig(projectPath); - } - if (!tsconfigResult) { - return void 0; - } - const mapperFn = createPathsMatcher(tsconfigResult); - if (!mapperFn) { - return void 0; - } - const files = tsconfigResult.config.files === void 0 && tsconfigResult.config.include === void 0 ? ( - // Include everything if no files or include options - globSync(defaultInclude, { - absolute: true, - cwd: path.dirname(tsconfigResult.path), - dot: true, - ignore: [ - ...tsconfigResult.config.exclude ?? [], - ...defaultIgnore - ] - }) - ) : [ - // https://www.typescriptlang.org/tsconfig/#files - ...tsconfigResult.config.files !== void 0 && tsconfigResult.config.files.length > 0 ? tsconfigResult.config.files.map( - (file) => path.normalize( - path.resolve(path.dirname(tsconfigResult.path), file) - ) - ) : [], - // https://www.typescriptlang.org/tsconfig/#include - ...tsconfigResult.config.include !== void 0 && tsconfigResult.config.include.length > 0 ? globSync(tsconfigResult.config.include, { - absolute: true, - cwd: path.dirname(tsconfigResult.path), - dot: true, - ignore: [ - ...tsconfigResult.config.exclude ?? [], - ...defaultIgnore - ] - }) : [] - ]; - if (files.length === 0) { - return void 0; - } - return { - files: new Set(files.map(toNativePathSeparator)), - mapperFn - }; - }).filter(isDefined); - mappersCachedOptions = options; -} -function mangleScopedPackage(moduleName) { - if (moduleName.startsWith("@")) { - const replaceSlash = moduleName.replace(path.sep, "__"); - if (replaceSlash !== moduleName) { - return replaceSlash.slice(1); - } - } - return moduleName; -} -function replacePathSeparator(p, from, to) { - return from === to ? p : p.replaceAll(from, to); -} -function toNativePathSeparator(p) { - return replacePathSeparator( - p, - path[process.platform === "win32" ? "posix" : "win32"].sep, - path[process.platform === "win32" ? "win32" : "posix"].sep - ); -} -function isDefined(value) { - return value !== null && value !== void 0; -} - -export { createTypeScriptImportResolver, defaultConditionNames, defaultExtensionAlias, defaultExtensions, defaultMainFields, interfaceVersion, resolve }; diff --git a/node_modules/eslint-import-resolver-typescript/lib/index.js b/node_modules/eslint-import-resolver-typescript/lib/index.js index 5eaa0f9693..0c2e64d188 100644 --- a/node_modules/eslint-import-resolver-typescript/lib/index.js +++ b/node_modules/eslint-import-resolver-typescript/lib/index.js @@ -1,335 +1,150 @@ -import fs from 'node:fs'; +import module from 'node:module'; import path from 'node:path'; -import isNodeCoreModule from '@nolyfill/is-core-module'; -import debug from 'debug'; -import enhancedResolve from 'enhanced-resolve'; -import { createPathsMatcher, getTsconfig } from 'get-tsconfig'; -import { isBunModule } from 'is-bun-module'; -import stableHashExports from 'stable-hash'; -import { globSync, isDynamicPattern } from 'tinyglobby'; -const stableHash = stableHashExports.default || stableHashExports; -const IMPORTER_NAME = 'eslint-import-resolver-typescript'; -const log = debug(IMPORTER_NAME); -export const defaultConditionNames = [ - 'types', - 'import', - 'esm2020', - 'es2020', - 'es2015', - 'require', - 'node', - 'node-addons', - 'browser', - 'default', -]; -export const defaultExtensions = [ - '.ts', - '.tsx', - '.d.ts', - '.js', - '.jsx', - '.json', - '.node', -]; -export const defaultExtensionAlias = { - '.js': [ - '.ts', - '.tsx', - '.d.ts', - '.js', - ], - '.jsx': ['.tsx', '.d.ts', '.jsx'], - '.cjs': ['.cts', '.d.cts', '.cjs'], - '.mjs': ['.mts', '.d.mts', '.mjs'], -}; -export const defaultMainFields = [ - 'types', - 'typings', - 'fesm2020', - 'fesm2015', - 'esm2020', - 'es2020', - 'module', - 'jsnext:main', - 'main', -]; -export const interfaceVersion = 2; -const fileSystem = fs; -const JS_EXT_PATTERN = /\.(?:[cm]js|jsx?)$/; -const RELATIVE_PATH_PATTERN = /^\.{1,2}(?:\/.*)?$/; -let previousOptionsHash; -let optionsHash; -let cachedOptions; -let prevCwd; -let mappersCachedOptions; -let mappers = []; -let resolverCachedOptions; -let cachedResolver; -export function resolve(source, file, options, resolver = null) { - if (!cachedOptions || - previousOptionsHash !== (optionsHash = stableHash(options))) { - previousOptionsHash = optionsHash; - cachedOptions = { - ...options, - conditionNames: options?.conditionNames ?? defaultConditionNames, - extensions: options?.extensions ?? defaultExtensions, - extensionAlias: options?.extensionAlias ?? defaultExtensionAlias, - mainFields: options?.mainFields ?? defaultMainFields, - fileSystem: new enhancedResolve.CachedInputFileSystem(fileSystem, 5 * 1000), - useSyncFileSystemCalls: true, +import { createFilesMatcher, parseTsconfig, } from 'get-tsconfig'; +import { isBunModule, isSupportedNodeModule } from 'is-bun-module'; +import { ResolverFactory } from 'rspack-resolver'; +import { stableHash } from 'stable-hash'; +import { IMPORT_RESOLVER_NAME, JS_EXT_PATTERN } from './constants.js'; +import { mangleScopedPackage, removeQuerystring, sortProjectsByAffinity, } from './helpers.js'; +import { log } from './logger.js'; +import { normalizeOptions } from './normalize-options.js'; +export * from './constants.js'; +export * from './helpers.js'; +export * from './normalize-options.js'; +const resolverCache = new Map(); +const tsconfigCache = new Map(); +const matcherCache = new Map(); +const oxcResolve = (source, file, resolver) => { + const result = resolver.sync(path.dirname(file), source); + if (result.path) { + return { + found: true, + path: result.path, }; } - if (!resolver) { - if (!cachedResolver || resolverCachedOptions !== cachedOptions) { - cachedResolver = - enhancedResolve.ResolverFactory.createResolver(cachedOptions); - resolverCachedOptions = cachedOptions; + if (result.error) { + log('oxc resolve error:', result.error); + } + return { + found: false, + }; +}; +export const resolve = (source, file, options, resolver) => { + options ||= {}; + let bunVersion = process.versions.bun; + if (bunVersion || options.bun) { + if (bunVersion + ? module.isBuiltin(source) + : isBunModule(source, (bunVersion = 'latest')) || + isSupportedNodeModule(source, bunVersion)) { + log('matched bun core:', source); + return { found: true, path: null }; } - resolver = cachedResolver; } - log('looking for', source, 'in', file); - source = removeQuerystring(source); - if (isNodeCoreModule(source) || - isBunModule(source, (process.versions.bun ?? 'latest'))) { - log('matched core:', source); + else if (module.isBuiltin(source)) { + log('matched node core:', source); + return { found: true, path: null }; + } + if (process.versions.pnp && source === 'pnpapi') { return { found: true, - path: null, + path: module + .findPnpApi(file) + .resolveToUnqualified(source, file, { considerBuiltins: false }), }; } - initMappers(cachedOptions); - const mappedPath = getMappedPath(source, file, cachedOptions.extensions, true); - if (mappedPath) { - log('matched ts path:', mappedPath); - } - let foundNodePath; - try { - foundNodePath = - resolver.resolveSync({}, path.dirname(path.resolve(file)), mappedPath ?? source) || null; + source = removeQuerystring(source); + if (!resolver) { + const optionsHash = stableHash(options); + const cwd = process.cwd(); + options = normalizeOptions(options, cwd); + const cacheKey = `${optionsHash}:${cwd}`; + let cached = resolverCache.get(cacheKey); + if (!cached && !options.project) { + resolverCache.set(cacheKey, (cached = new ResolverFactory(options))); + } + resolver = cached; + } + options ||= {}; + createResolver: if (!resolver) { + const project = options.project; + for (const tsconfigPath of project) { + const resolverCached = resolverCache.get(tsconfigPath); + if (resolverCached) { + resolver = resolverCached; + break createResolver; + } + let tsconfigCached = tsconfigCache.get(tsconfigPath); + if (!tsconfigCached) { + tsconfigCache.set(tsconfigPath, (tsconfigCached = parseTsconfig(tsconfigPath))); + } + let matcherCached = matcherCache.get(tsconfigPath); + if (!matcherCached) { + matcherCache.set(tsconfigPath, (matcherCached = createFilesMatcher({ + config: tsconfigCached, + path: tsconfigPath, + }))); + } + const tsconfig = matcherCached(file); + if (!tsconfig) { + log('tsconfig', tsconfigPath, 'does not match', file); + continue; + } + log('matched tsconfig at:', tsconfigPath, 'for', file); + options = { + ...options, + tsconfig: { + references: 'auto', + ...options.tsconfig, + configFile: tsconfigPath, + }, + }; + resolver = new ResolverFactory(options); + resolverCache.set(tsconfigPath, resolver); + break createResolver; + } + log('no tsconfig matched', file, 'with', ...project, ', trying from the the nearest one'); + for (const p of sortProjectsByAffinity(project, file)) { + const resolved = resolve(source, file, { ...options, project: p }, resolver); + if (resolved.found) { + return resolved; + } + } } - catch { - foundNodePath = null; + if (!resolver) { + return { + found: false, + }; } - if ((JS_EXT_PATTERN.test(foundNodePath) || - (cachedOptions.alwaysTryTypes && !foundNodePath)) && + const resolved = oxcResolve(source, file, resolver); + const foundPath = resolved.path; + if (((foundPath && JS_EXT_PATTERN.test(foundPath)) || + (options.alwaysTryTypes !== false && !foundPath)) && !/^@types[/\\]/.test(source) && !path.isAbsolute(source) && !source.startsWith('.')) { - const definitelyTyped = resolve('@types' + path.sep + mangleScopedPackage(source), file, options); + const definitelyTyped = oxcResolve('@types/' + mangleScopedPackage(source), file, resolver); if (definitelyTyped.found) { return definitelyTyped; } } - if (foundNodePath) { - log('matched node path:', foundNodePath); - return { - found: true, - path: foundNodePath, - }; + if (foundPath) { + log('matched path:', foundPath); } - log("didn't find ", source); - return { - found: false, - }; -} -export function createTypeScriptImportResolver(options) { - const resolver = enhancedResolve.ResolverFactory.createResolver({ - ...options, - conditionNames: options?.conditionNames ?? defaultConditionNames, - extensions: options?.extensions ?? defaultExtensions, - extensionAlias: options?.extensionAlias ?? defaultExtensionAlias, - mainFields: options?.mainFields ?? defaultMainFields, - fileSystem: new enhancedResolve.CachedInputFileSystem(fileSystem, 5 * 1000), - useSyncFileSystemCalls: true, - }); + else { + log("didn't find", source, 'with', options.tsconfig?.configFile || options.project); + } + return resolved; +}; +export const createTypeScriptImportResolver = (options) => { + options = normalizeOptions(options); + const resolver = options.project ? null : new ResolverFactory(options); return { interfaceVersion: 3, - name: IMPORTER_NAME, + name: IMPORT_RESOLVER_NAME, resolve(source, file) { return resolve(source, file, options, resolver); }, }; -} -function removeQuerystring(id) { - const querystringIndex = id.lastIndexOf('?'); - if (querystringIndex >= 0) { - return id.slice(0, querystringIndex); - } - return id; -} -const isFile = (path) => { - try { - return !!(path && fs.statSync(path, { throwIfNoEntry: false })?.isFile()); - } - catch { - return false; - } }; -const isModule = (modulePath) => { - return !!modulePath && isFile(path.resolve(modulePath, 'package.json')); -}; -function getMappedPath(source, file, extensions = defaultExtensions, retry) { - const originalExtensions = extensions; - extensions = ['', ...extensions]; - let paths = []; - if (RELATIVE_PATH_PATTERN.test(source)) { - const resolved = path.resolve(path.dirname(file), source); - if (isFile(resolved)) { - paths = [resolved]; - } - } - else { - paths = [ - ...new Set(mappers - .filter(({ files }) => files.has(file)) - .map(({ mapperFn }) => mapperFn(source).map(item => [ - ...extensions.map(ext => `${item}${ext}`), - ...originalExtensions.map(ext => `${item}/index${ext}`), - ])) - .flat(2) - .map(toNativePathSeparator)), - ].filter(mappedPath => { - try { - const stat = fs.statSync(mappedPath, { throwIfNoEntry: false }); - if (stat === undefined) - return false; - if (stat.isFile()) - return true; - if (stat.isDirectory()) { - return isModule(mappedPath); - } - } - catch { - return false; - } - return false; - }); - } - if (retry && paths.length === 0) { - const isJs = JS_EXT_PATTERN.test(source); - if (isJs) { - const jsExt = path.extname(source); - const tsExt = jsExt.replace('js', 'ts'); - const basename = source.replace(JS_EXT_PATTERN, ''); - const resolved = getMappedPath(basename + tsExt, file) || - getMappedPath(basename + '.d' + (tsExt === '.tsx' ? '.ts' : tsExt), file); - if (resolved) { - return resolved; - } - } - for (const ext of extensions) { - const resolved = (isJs ? null : getMappedPath(source + ext, file)) || - getMappedPath(source + `/index${ext}`, file); - if (resolved) { - return resolved; - } - } - } - if (paths.length > 1) { - log('found multiple matching ts paths:', paths); - } - return paths[0]; -} -function initMappers(options) { - if (mappers.length > 0 && - mappersCachedOptions === options && - prevCwd === process.cwd()) { - return; - } - prevCwd = process.cwd(); - const configPaths = (typeof options.project === 'string' - ? [options.project] - : Array.isArray(options.project) - ? options.project - : [process.cwd()]) - .map(config => replacePathSeparator(config, path.sep, path.posix.sep)); - const defaultInclude = ['**/*']; - const defaultIgnore = ['**/node_modules/**']; - const projectPaths = [ - ...new Set([ - ...configPaths.filter(path => !isDynamicPattern(path)), - ...globSync(configPaths.filter(path => isDynamicPattern(path)), { - absolute: true, - dot: true, - expandDirectories: false, - ignore: defaultIgnore, - }), - ]), - ]; - mappers = projectPaths - .map(projectPath => { - let tsconfigResult; - if (isFile(projectPath)) { - const { dir, base } = path.parse(projectPath); - tsconfigResult = getTsconfig(dir, base); - } - else { - tsconfigResult = getTsconfig(projectPath); - } - if (!tsconfigResult) { - return undefined; - } - const mapperFn = createPathsMatcher(tsconfigResult); - if (!mapperFn) { - return undefined; - } - const files = tsconfigResult.config.files === undefined && - tsconfigResult.config.include === undefined - ? - globSync(defaultInclude, { - absolute: true, - cwd: path.dirname(tsconfigResult.path), - dot: true, - ignore: [ - ...(tsconfigResult.config.exclude ?? []), - ...defaultIgnore, - ], - }) - : [ - ...(tsconfigResult.config.files !== undefined && - tsconfigResult.config.files.length > 0 - ? tsconfigResult.config.files.map(file => path.normalize(path.resolve(path.dirname(tsconfigResult.path), file))) - : []), - ...(tsconfigResult.config.include !== undefined && - tsconfigResult.config.include.length > 0 - ? globSync(tsconfigResult.config.include, { - absolute: true, - cwd: path.dirname(tsconfigResult.path), - dot: true, - ignore: [ - ...(tsconfigResult.config.exclude ?? []), - ...defaultIgnore, - ], - }) - : []), - ]; - if (files.length === 0) { - return undefined; - } - return { - files: new Set(files.map(toNativePathSeparator)), - mapperFn, - }; - }) - .filter(isDefined); - mappersCachedOptions = options; -} -function mangleScopedPackage(moduleName) { - if (moduleName.startsWith('@')) { - const replaceSlash = moduleName.replace(path.sep, '__'); - if (replaceSlash !== moduleName) { - return replaceSlash.slice(1); - } - } - return moduleName; -} -function replacePathSeparator(p, from, to) { - return from === to ? p : p.replaceAll(from, to); -} -function toNativePathSeparator(p) { - return replacePathSeparator(p, path[process.platform === 'win32' ? 'posix' : 'win32'].sep, path[process.platform === 'win32' ? 'win32' : 'posix'].sep); -} -function isDefined(value) { - return value !== null && value !== undefined; -} //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/node_modules/eslint-import-resolver-typescript/lib/index.js.map b/node_modules/eslint-import-resolver-typescript/lib/index.js.map index 1aeb48c1f0..ed4021ff11 100644 --- a/node_modules/eslint-import-resolver-typescript/lib/index.js.map +++ b/node_modules/eslint-import-resolver-typescript/lib/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,IAAI,MAAM,WAAW,CAAA;AAG5B,OAAO,EAGL,kBAAkB,EAClB,aAAa,GACd,MAAM,cAAc,CAAA;AACrB,OAAO,EAAgB,WAAW,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACrE,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAGzD,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,wBAAwB,CAAA;AAGtC,MAAM,aAAa,GAAG,IAAI,GAAG,EAA2B,CAAA;AAExD,MAAM,aAAa,GAAG,IAAI,GAAG,EAAgC,CAAA;AAE7D,MAAM,YAAY,GAAG,IAAI,GAAG,EAAuB,CAAA;AAEnD,MAAM,UAAU,GAAG,CACjB,MAAc,EACd,IAAY,EACZ,QAAyB,EACT,EAAE;IAClB,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAA;IACxD,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;QAChB,OAAO;YACL,KAAK,EAAE,IAAI;YACX,IAAI,EAAE,MAAM,CAAC,IAAI;SAClB,CAAA;IACH,CAAC;IACD,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,GAAG,CAAC,oBAAoB,EAAE,MAAM,CAAC,KAAK,CAAC,CAAA;IACzC,CAAC;IACD,OAAO;QACL,KAAK,EAAE,KAAK;KACb,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,CACrB,MAAc,EACd,IAAY,EACZ,OAA0C,EAC1C,QAAiC,EAEjB,EAAE;IAClB,OAAO,KAAK,EAAE,CAAA;IAEd,IAAI,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC,GAA0B,CAAA;IAG5D,IAAI,UAAU,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAC9B,IACE,UAAU;YACR,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC;YAC1B,CAAC,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,UAAU,GAAG,QAAQ,CAAC,CAAC;gBAC5C,qBAAqB,CAAC,MAAM,EAAE,UAAU,CAAC,EAC7C,CAAC;YACD,GAAG,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAA;YAChC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;QACpC,CAAC;IACH,CAAC;SAAM,IAAI,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;QAEpC,GAAG,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAA;QACjC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;IACpC,CAAC;IAED,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;QAChD,OAAO;YACL,KAAK,EAAE,IAAI;YACX,IAAI,EAAE,MAAM;iBACT,UAAU,CAAC,IAAI,CAAC;iBAChB,oBAAoB,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC;SACnE,CAAA;IACH,CAAC;IAED,MAAM,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAA;IAElC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,CAAC,CAAA;QACvC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;QACzB,OAAO,GAAG,gBAAgB,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;QAExC,MAAM,QAAQ,GAAG,GAAG,WAAW,IAAI,GAAG,EAAE,CAAA;QACxC,IAAI,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QACxC,IAAI,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YAChC,aAAa,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,MAAM,GAAG,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;QACtE,CAAC;QACD,QAAQ,GAAG,MAAM,CAAA;IACnB,CAAC;IAED,OAAO,KAAK,EAAE,CAAA;IAGd,cAAc,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC;QAE9B,MAAM,OAAO,GAAG,OAAO,CAAC,OAAmB,CAAA;QAC3C,KAAK,MAAM,YAAY,IAAI,OAAO,EAAE,CAAC;YACnC,MAAM,cAAc,GAAG,aAAa,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;YACtD,IAAI,cAAc,EAAE,CAAC;gBACnB,QAAQ,GAAG,cAAc,CAAA;gBACzB,MAAM,cAAc,CAAA;YACtB,CAAC;YACD,IAAI,cAAc,GAAG,aAAa,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;YACpD,IAAI,CAAC,cAAc,EAAE,CAAC;gBACpB,aAAa,CAAC,GAAG,CACf,YAAY,EACZ,CAAC,cAAc,GAAG,aAAa,CAAC,YAAY,CAAC,CAAC,CAC/C,CAAA;YACH,CAAC;YACD,IAAI,aAAa,GAAG,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;YAClD,IAAI,CAAC,aAAa,EAAE,CAAC;gBACnB,YAAY,CAAC,GAAG,CACd,YAAY,EACZ,CAAC,aAAa,GAAG,kBAAkB,CAAC;oBAClC,MAAM,EAAE,cAAc;oBACtB,IAAI,EAAE,YAAY;iBACnB,CAAC,CAAC,CACJ,CAAA;YACH,CAAC;YACD,MAAM,QAAQ,GAAG,aAAa,CAAC,IAAI,CAAC,CAAA;YACpC,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,GAAG,CAAC,UAAU,EAAE,YAAY,EAAE,gBAAgB,EAAE,IAAI,CAAC,CAAA;gBACrD,SAAQ;YACV,CAAC;YACD,GAAG,CAAC,sBAAsB,EAAE,YAAY,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;YACtD,OAAO,GAAG;gBACR,GAAG,OAAO;gBACV,QAAQ,EAAE;oBACR,UAAU,EAAE,MAAM;oBAClB,GAAG,OAAO,CAAC,QAAQ;oBACnB,UAAU,EAAE,YAAY;iBACzB;aACF,CAAA;YACD,QAAQ,GAAG,IAAI,eAAe,CAAC,OAAO,CAAC,CAAA;YACvC,aAAa,CAAC,GAAG,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAA;YACzC,MAAM,cAAc,CAAA;QACtB,CAAC;QAED,GAAG,CACD,qBAAqB,EACrB,IAAI,EACJ,MAAM,EACN,GAAG,OAAO,EACV,mCAAmC,CACpC,CAAA;QACD,KAAK,MAAM,CAAC,IAAI,sBAAsB,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC;YACtD,MAAM,QAAQ,GAAG,OAAO,CACtB,MAAM,EACN,IAAI,EACJ,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,EAC1B,QAAQ,CACT,CAAA;YACD,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;gBACnB,OAAO,QAAQ,CAAA;YACjB,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO;YACL,KAAK,EAAE,KAAK;SACb,CAAA;IACH,CAAC;IAED,MAAM,QAAQ,GAAG,UAAU,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAA;IAEnD,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAA;IAI/B,IACE,CAAC,CAAC,SAAS,IAAI,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC5C,CAAC,OAAO,CAAC,cAAc,KAAK,KAAK,IAAI,CAAC,SAAS,CAAC,CAAC;QACnD,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC;QAC5B,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;QACxB,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,EACvB,CAAC;QACD,MAAM,eAAe,GAAG,UAAU,CAChC,SAAS,GAAG,mBAAmB,CAAC,MAAM,CAAC,EACvC,IAAI,EACJ,QAAQ,CACT,CAAA;QAED,IAAI,eAAe,CAAC,KAAK,EAAE,CAAC;YAC1B,OAAO,eAAe,CAAA;QACxB,CAAC;IACH,CAAC;IAED,IAAI,SAAS,EAAE,CAAC;QACd,GAAG,CAAC,eAAe,EAAE,SAAS,CAAC,CAAA;IACjC,CAAC;SAAM,CAAC;QACN,GAAG,CACD,aAAa,EACb,MAAM,EACN,MAAM,EACN,OAAO,CAAC,QAAQ,EAAE,UAAU,IAAI,OAAO,CAAC,OAAO,CAChD,CAAA;IACH,CAAC;IAED,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAC5C,OAA0C,EAC1C,EAAE;IACF,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAA;IACnC,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,eAAe,CAAC,OAAO,CAAC,CAAA;IACtE,OAAO;QACL,gBAAgB,EAAE,CAAC;QACnB,IAAI,EAAE,oBAAoB;QAC1B,OAAO,CAAC,MAAc,EAAE,IAAY;YAClC,OAAO,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAA;QACjD,CAAC;KACF,CAAA;AACH,CAAC,CAAA"} \ No newline at end of file diff --git a/node_modules/eslint-import-resolver-typescript/lib/logger.d.ts b/node_modules/eslint-import-resolver-typescript/lib/logger.d.ts new file mode 100644 index 0000000000..a904de6aa4 --- /dev/null +++ b/node_modules/eslint-import-resolver-typescript/lib/logger.d.ts @@ -0,0 +1,2 @@ +import debug from 'debug'; +export declare const log: debug.Debugger; diff --git a/node_modules/eslint-import-resolver-typescript/lib/logger.js b/node_modules/eslint-import-resolver-typescript/lib/logger.js new file mode 100644 index 0000000000..d3775dd228 --- /dev/null +++ b/node_modules/eslint-import-resolver-typescript/lib/logger.js @@ -0,0 +1,4 @@ +import debug from 'debug'; +import { IMPORT_RESOLVER_NAME } from './constants.js'; +export const log = debug(IMPORT_RESOLVER_NAME); +//# sourceMappingURL=logger.js.map \ No newline at end of file diff --git a/node_modules/eslint-import-resolver-typescript/lib/logger.js.map b/node_modules/eslint-import-resolver-typescript/lib/logger.js.map new file mode 100644 index 0000000000..0755e14d97 --- /dev/null +++ b/node_modules/eslint-import-resolver-typescript/lib/logger.js.map @@ -0,0 +1 @@ +{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAErD,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,CAAC,oBAAoB,CAAC,CAAA"} \ No newline at end of file diff --git a/node_modules/eslint-import-resolver-typescript/lib/normalize-options.d.ts b/node_modules/eslint-import-resolver-typescript/lib/normalize-options.d.ts new file mode 100644 index 0000000000..82f029718c --- /dev/null +++ b/node_modules/eslint-import-resolver-typescript/lib/normalize-options.d.ts @@ -0,0 +1,3 @@ +import type { TypeScriptResolverOptions } from './types.js'; +export declare let defaultConfigFile: string; +export declare function normalizeOptions(options?: TypeScriptResolverOptions | null, cwd?: string): TypeScriptResolverOptions; diff --git a/node_modules/eslint-import-resolver-typescript/lib/normalize-options.js b/node_modules/eslint-import-resolver-typescript/lib/normalize-options.js new file mode 100644 index 0000000000..e16e2eee88 --- /dev/null +++ b/node_modules/eslint-import-resolver-typescript/lib/normalize-options.js @@ -0,0 +1,75 @@ +import { globSync, isDynamicPattern } from 'tinyglobby'; +import { DEFAULT_CONFIGS, DEFAULT_IGNORE, DEFAULT_TRY_PATHS, defaultConditionNames, defaultExtensionAlias, defaultExtensions, defaultMainFields, } from './constants.js'; +import { toGlobPath, toNativePath, tryFile } from './helpers.js'; +import { log } from './logger.js'; +export let defaultConfigFile; +const configFileMapping = new Map(); +let warned; +export function normalizeOptions(options, cwd = process.cwd()) { + let { project, tsconfig, noWarnOnMultipleProjects } = (options ||= {}); + let { configFile, references } = tsconfig ?? {}; + let ensured; + if (configFile) { + configFile = tryFile(configFile); + ensured = true; + } + else if (project) { + log('original projects:', ...project); + project = (Array.isArray(project) ? project : [project]).map(toGlobPath); + if (project.some(p => isDynamicPattern(p))) { + project = globSync(project, { + absolute: true, + cwd, + dot: true, + expandDirectories: false, + onlyFiles: false, + ignore: DEFAULT_IGNORE, + }); + } + log('resolving projects:', ...project); + project = project.flatMap(p => tryFile(DEFAULT_TRY_PATHS, false, toNativePath(p)) || []); + log('resolved projects:', ...project); + if (project.length === 1) { + configFile = project[0]; + ensured = true; + } + if (project.length <= 1) { + project = undefined; + } + else if (!warned && !noWarnOnMultipleProjects) { + warned = true; + console.warn('Multiple projects found, consider using a single `tsconfig` with `references` to speed up, or use `noWarnOnMultipleProjects` to suppress this warning'); + } + } + if (!project && !configFile) { + configFile = defaultConfigFile ||= tryFile(DEFAULT_CONFIGS); + ensured = true; + } + if (configFile) { + const cachedOptions = configFileMapping.get(configFile); + if (cachedOptions) { + log('using cached options for', configFile); + return cachedOptions; + } + } + if (!ensured && configFile && configFile !== defaultConfigFile) { + configFile = tryFile(DEFAULT_TRY_PATHS, false, configFile); + } + options = { + conditionNames: defaultConditionNames, + extensions: defaultExtensions, + extensionAlias: defaultExtensionAlias, + mainFields: defaultMainFields, + ...options, + project, + tsconfig: { + references: references ?? 'auto', + configFile: configFile || '', + }, + }; + if (configFile) { + configFileMapping.set(configFile, options); + } + return options; +} +//# sourceMappingURL=normalize-options.js.map \ No newline at end of file diff --git a/node_modules/eslint-import-resolver-typescript/lib/normalize-options.js.map b/node_modules/eslint-import-resolver-typescript/lib/normalize-options.js.map new file mode 100644 index 0000000000..9f07948cec --- /dev/null +++ b/node_modules/eslint-import-resolver-typescript/lib/normalize-options.js.map @@ -0,0 +1 @@ +{"version":3,"file":"normalize-options.js","sourceRoot":"","sources":["../src/normalize-options.ts"],"names":[],"mappings":"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"} \ No newline at end of file diff --git a/node_modules/eslint-import-resolver-typescript/lib/types.d.ts b/node_modules/eslint-import-resolver-typescript/lib/types.d.ts new file mode 100644 index 0000000000..c9f9c273e2 --- /dev/null +++ b/node_modules/eslint-import-resolver-typescript/lib/types.d.ts @@ -0,0 +1,7 @@ +import type { NapiResolveOptions } from 'rspack-resolver'; +export interface TypeScriptResolverOptions extends NapiResolveOptions { + project?: string[] | string; + alwaysTryTypes?: boolean; + bun?: boolean; + noWarnOnMultipleProjects?: boolean; +} diff --git a/node_modules/eslint-import-resolver-typescript/lib/types.js b/node_modules/eslint-import-resolver-typescript/lib/types.js new file mode 100644 index 0000000000..718fd38ae4 --- /dev/null +++ b/node_modules/eslint-import-resolver-typescript/lib/types.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/node_modules/eslint-import-resolver-typescript/lib/types.js.map b/node_modules/eslint-import-resolver-typescript/lib/types.js.map new file mode 100644 index 0000000000..c768b79002 --- /dev/null +++ b/node_modules/eslint-import-resolver-typescript/lib/types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/node_modules/eslint-import-resolver-typescript/package.json b/node_modules/eslint-import-resolver-typescript/package.json index 758c4c91eb..c9988b80f1 100644 --- a/node_modules/eslint-import-resolver-typescript/package.json +++ b/node_modules/eslint-import-resolver-typescript/package.json @@ -1,6 +1,6 @@ { "name": "eslint-import-resolver-typescript", - "version": "3.8.3", + "version": "4.1.1", "type": "module", "description": "This plugin adds `TypeScript` support to `eslint-plugin-import`", "repository": "git+https://github.com/import-js/eslint-import-resolver-typescript", @@ -10,28 +10,22 @@ ], "funding": "https://opencollective.com/unts/projects/eslint-import-resolver-ts", "license": "ISC", - "packageManager": "yarn@4.0.2", "engines": { - "node": "^14.18.0 || >=16.0.0" + "node": "^16.17.0 || >=18.6.0" }, "main": "lib/index.cjs", "module": "lib/index.js", "exports": { ".": { "types": "./lib/index.d.ts", - "es2020": "./lib/index.es2020.mjs", - "fesm2020": "./lib/index.es2020.mjs", - "import": "./lib/index.js", - "require": "./lib/index.cjs" + "require": "./lib/index.cjs", + "default": "./lib/index.js" }, "./package.json": "./package.json" }, - "es2020": "lib/index.es2020.mjs", - "fesm2020": "lib/index.es2020.mjs", "types": "lib/index.d.ts", "files": [ "lib", - "shim.d.ts", "!**/*.tsbuildinfo" ], "keywords": [ @@ -41,30 +35,6 @@ "resolver", "plugin" ], - "scripts": { - "build": "run-p 'build:*'", - "build:r": "r -f cjs,es2020", - "build:ts": "tsc -b", - "lint": "run-p 'lint:*'", - "lint:es": "eslint src --cache -f friendly", - "lint:tsc": "tsc --noEmit", - "prepare": "simple-git-hooks", - "release": "changeset publish", - "test": "run-p 'test:*'", - "test:dotInclude": "eslint --ext ts,tsx tests/dotInclude --ignore-pattern \"!.dot\"", - "test:dotPaths": "eslint --ext ts,tsx tests/dotPaths --ignore-pattern \"!.dot\"", - "test:dotProject": "eslint --ext ts,tsx tests/dotProject --ignore-pattern \"!.dot\"", - "test:importXResolverV3": "eslint --config=tests/importXResolverV3/eslint.config.js tests/importXResolverV3", - "test:multipleEslintrcs": "eslint --ext ts,tsx tests/multipleEslintrcs", - "test:multipleTsconfigs": "eslint --ext ts,tsx tests/multipleTsconfigs", - "test:withJsExtension": "node tests/withJsExtension/test.js && eslint --ext ts,tsx tests/withJsExtension", - "test:withJsconfig": "eslint --ext js tests/withJsconfig", - "test:withPaths": "eslint --ext ts,tsx tests/withPaths", - "test:withPathsAndNestedBaseUrl": "eslint --ext ts,tsx tests/withPathsAndNestedBaseUrl", - "test:withQuerystring": "eslint --ext ts,tsx tests/withQuerystring", - "test:withoutPaths": "eslint --ext ts,tsx tests/withoutPaths", - "typecov": "type-coverage" - }, "peerDependencies": { "eslint": "*", "eslint-plugin-import": "*", @@ -79,52 +49,11 @@ } }, "dependencies": { - "@nolyfill/is-core-module": "1.0.39", - "debug": "^4.3.7", - "enhanced-resolve": "^5.15.0", + "debug": "^4.4.0", "get-tsconfig": "^4.10.0", - "is-bun-module": "^1.0.2", - "stable-hash": "^0.0.4", + "is-bun-module": "^1.3.0", + "rspack-resolver": "^1.1.2", + "stable-hash": "^0.0.5", "tinyglobby": "^0.2.12" - }, - "devDependencies": { - "@1stg/eslint-config": "7.0.1", - "@1stg/lib-config": "^12.0.1", - "@changesets/changelog-github": "^0.5.0", - "@changesets/cli": "^2.27.12", - "@commitlint/cli": "^17.8.1", - "@mozilla/glean": "^3.0.0", - "@pkgr/rollup": "^4.1.3", - "@types/debug": "^4.1.12", - "@types/node": "^18.19.74", - "@types/unist": "^2.0.11", - "dummy.js": "link:dummy.js", - "eslint": "^8.57.1", - "eslint-import-resolver-typescript": "link:.", - "eslint-plugin-import": "npm:eslint-plugin-i@^2.29.1", - "eslint-plugin-import-x": "^4.5.0", - "lint-staged": "^13.3.0", - "npm-run-all2": "^5.0.2", - "prettier": "^2.8.8", - "react": "^18.3.1", - "simple-git-hooks": "^2.11.1", - "size-limit": "^11.0.0", - "size-limit-preset-node-lib": "^0.3.0", - "type-coverage": "^2.27.0", - "typescript": "^5.3.2" - }, - "resolutions": { - "eslint-import-resolver-typescript": "link:.", - "prettier": "^2.8.8" - }, - "typeCoverage": { - "atLeast": 100, - "cache": true, - "detail": true, - "ignoreAsAssertion": true, - "ignoreNonNullAssertion": true, - "ignoreCatch": true, - "strict": true, - "update": true } -} +} \ No newline at end of file diff --git a/node_modules/is-bun-module/README.md b/node_modules/is-bun-module/README.md index d02822883d..25840571e4 100644 --- a/node_modules/is-bun-module/README.md +++ b/node_modules/is-bun-module/README.md @@ -26,3 +26,4 @@ isSupportedNodeModule("node:http2", "1.0.0"); // false, added in 1.0.13 - **Only Bun v1.0.0+ is supported** - You can also pass `latest` as Bun version - Inspired by [is-core-module](https://github.com/inspect-js/is-core-module) and made for [eslint-import-resolver-typescript](https://github.com/import-js/eslint-import-resolver-typescript) +- Runtime-independent diff --git a/node_modules/is-bun-module/dist/cjs/index.d.ts b/node_modules/is-bun-module/dist/cjs/index.d.ts index 33ef238e63..ad262a1f31 100644 --- a/node_modules/is-bun-module/dist/cjs/index.d.ts +++ b/node_modules/is-bun-module/dist/cjs/index.d.ts @@ -1,4 +1,6 @@ -type SemVerStringified = `${number}.${number}.${number}`; +type SemVerBaseStringified = `${bigint}.${bigint}.${bigint}`; +type SemVerStringifiedWithReleaseName = `${SemVerBaseStringified}-${string}`; +type SemVerStringified = SemVerBaseStringified | SemVerStringifiedWithReleaseName; type Version = SemVerStringified | "latest"; declare const MINIMUM_BUN_VERSION = "1.0.0"; declare function isBunModule(moduleName: string, bunVersion?: Version): boolean; diff --git a/node_modules/is-bun-module/dist/cjs/index.js b/node_modules/is-bun-module/dist/cjs/index.js index 5702b23de0..db1f15a1ce 100644 --- a/node_modules/is-bun-module/dist/cjs/index.js +++ b/node_modules/is-bun-module/dist/cjs/index.js @@ -43,7 +43,8 @@ var bun_modules_default = { "bun:ffi": true, "bun:jsc": true, "bun:sqlite": true, - "bun:test": true + "bun:test": true, + "bun:wrap": true }; // src/assets/node-modules.json @@ -95,22 +96,32 @@ function isSupportedNodeModule(moduleName, bunVersion) { return checkModule(moduleName.replace(/^node:/, ""), node_modules_default, bunVersion); } function checkModule(moduleName, modules, bunVersion) { + var _a; if (typeof moduleName !== "string") throw new TypeError("Module name must be a string"); if (!(moduleName in modules)) return false; - if (bunVersion != null && !isVersion(bunVersion)) { - throw new TypeError("Bun version must be a string like 1.0.0 or 'latest' or undefined"); + let targetBunVersion; + if (bunVersion) { + targetBunVersion = toSemVerStringified(bunVersion); + if (!targetBunVersion) { + throw new TypeError("Bun version must be a string like 1.0.0 or 'latest'"); + } + } else { + if (typeof process === "undefined" || !((_a = process.versions) == null ? void 0 : _a.bun)) { + throw new Error("Bun version is not provided and cannot be detected"); + } + targetBunVersion = process.versions.bun; } - const targetBunVersion = bunVersion ? bunVersion === "latest" ? "999.999.999" : bunVersion : typeof process !== "undefined" && process.versions.bun; - if (!targetBunVersion) throw "Bun version is not provided and cannot be detected"; if (import_semver.default.lt(targetBunVersion, MINIMUM_BUN_VERSION)) { - throw `Bun version must be at least ${MINIMUM_BUN_VERSION}`; + throw new RangeError(`Bun version must be at least ${MINIMUM_BUN_VERSION}`); } const versionRange = modules[moduleName]; if (typeof versionRange === "boolean") return versionRange; return import_semver.default.satisfies(targetBunVersion, versionRange); } -function isVersion(input) { - return typeof input === "string" && (input === "latest" || Boolean(input.match(/^(?:\d+\.){2}\d+$/))); +function toSemVerStringified(input) { + if (typeof input !== "string") return; + if (input === "latest") return "999.999.999"; + if (import_semver.default.valid(input)) return input; } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { diff --git a/node_modules/is-bun-module/dist/esm/index.d.mts b/node_modules/is-bun-module/dist/esm/index.d.mts index 33ef238e63..ad262a1f31 100644 --- a/node_modules/is-bun-module/dist/esm/index.d.mts +++ b/node_modules/is-bun-module/dist/esm/index.d.mts @@ -1,4 +1,6 @@ -type SemVerStringified = `${number}.${number}.${number}`; +type SemVerBaseStringified = `${bigint}.${bigint}.${bigint}`; +type SemVerStringifiedWithReleaseName = `${SemVerBaseStringified}-${string}`; +type SemVerStringified = SemVerBaseStringified | SemVerStringifiedWithReleaseName; type Version = SemVerStringified | "latest"; declare const MINIMUM_BUN_VERSION = "1.0.0"; declare function isBunModule(moduleName: string, bunVersion?: Version): boolean; diff --git a/node_modules/is-bun-module/dist/esm/index.mjs b/node_modules/is-bun-module/dist/esm/index.mjs index 18ef7284a8..ceddb43402 100644 --- a/node_modules/is-bun-module/dist/esm/index.mjs +++ b/node_modules/is-bun-module/dist/esm/index.mjs @@ -7,7 +7,8 @@ var bun_modules_default = { "bun:ffi": true, "bun:jsc": true, "bun:sqlite": true, - "bun:test": true + "bun:test": true, + "bun:wrap": true }; // src/assets/node-modules.json @@ -59,22 +60,32 @@ function isSupportedNodeModule(moduleName, bunVersion) { return checkModule(moduleName.replace(/^node:/, ""), node_modules_default, bunVersion); } function checkModule(moduleName, modules, bunVersion) { + var _a; if (typeof moduleName !== "string") throw new TypeError("Module name must be a string"); if (!(moduleName in modules)) return false; - if (bunVersion != null && !isVersion(bunVersion)) { - throw new TypeError("Bun version must be a string like 1.0.0 or 'latest' or undefined"); + let targetBunVersion; + if (bunVersion) { + targetBunVersion = toSemVerStringified(bunVersion); + if (!targetBunVersion) { + throw new TypeError("Bun version must be a string like 1.0.0 or 'latest'"); + } + } else { + if (typeof process === "undefined" || !((_a = process.versions) == null ? void 0 : _a.bun)) { + throw new Error("Bun version is not provided and cannot be detected"); + } + targetBunVersion = process.versions.bun; } - const targetBunVersion = bunVersion ? bunVersion === "latest" ? "999.999.999" : bunVersion : typeof process !== "undefined" && process.versions.bun; - if (!targetBunVersion) throw "Bun version is not provided and cannot be detected"; if (semver.lt(targetBunVersion, MINIMUM_BUN_VERSION)) { - throw `Bun version must be at least ${MINIMUM_BUN_VERSION}`; + throw new RangeError(`Bun version must be at least ${MINIMUM_BUN_VERSION}`); } const versionRange = modules[moduleName]; if (typeof versionRange === "boolean") return versionRange; return semver.satisfies(targetBunVersion, versionRange); } -function isVersion(input) { - return typeof input === "string" && (input === "latest" || Boolean(input.match(/^(?:\d+\.){2}\d+$/))); +function toSemVerStringified(input) { + if (typeof input !== "string") return; + if (input === "latest") return "999.999.999"; + if (semver.valid(input)) return input; } export { MINIMUM_BUN_VERSION, diff --git a/node_modules/is-bun-module/package.json b/node_modules/is-bun-module/package.json index e1e839a358..9005b69906 100644 --- a/node_modules/is-bun-module/package.json +++ b/node_modules/is-bun-module/package.json @@ -2,7 +2,7 @@ "name": "is-bun-module", "author": "SunsetTechuila ", "description": "Is this specifier a Bun core module or supported Node one?", - "version": "1.1.0", + "version": "1.3.0", "license": "MIT", "files": [ "dist/**/*" @@ -12,12 +12,12 @@ "exports": { ".": { "import": { - "default": "./dist/esm/index.mjs", - "types": "./dist/esm/index.d.mts" + "types": "./dist/esm/index.d.mts", + "default": "./dist/esm/index.mjs" }, "require": { - "default": "./dist/cjs/index.js", - "types": "./dist/cjs/index.d.ts" + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.js" } }, "./package.json": "./package.json" @@ -35,7 +35,36 @@ "dependencies", "bun" ], + "scripts": { + "build": "bun --bun tsup", + "check-all": "bun --bun concurrently --kill-others=failure 'bun run test' 'bun lint' 'bun type-check' 'bun format:check'", + "test": "bun test", + "format": "bun format:base --write", + "format:check": "bun format:base --check", + "format:base": "bun --bun prettier . --cache", + "lint": "bun --bun eslint . --cache", + "type-check": "bun --bun tsc", + "publish": "bun --bun semantic-release" + }, "dependencies": { "semver": "^7.6.3" + }, + "devDependencies": { + "@commitlint/cli": "^19.6.0", + "@commitlint/config-conventional": "^19.6.0", + "@eslint/js": "^9.15.0", + "@semantic-release/exec": "^6.0.3", + "@types/bun": "^1.1.14", + "@types/eslint__js": "^8.42.3", + "@types/semver": "^7.5.8", + "concurrently": "^9.1.0", + "eslint": "^9.15.0", + "eslint-config-prettier": "^9.1.0", + "husky": "^9.1.7", + "prettier": "^3.4.0", + "semantic-release": "^24.2.0", + "tsup": "^8.3.5", + "typescript": "^5.7.2", + "typescript-eslint": "^8.16.0" } } diff --git a/node_modules/rspack-resolver/README.md b/node_modules/rspack-resolver/README.md new file mode 100644 index 0000000000..880557a47c --- /dev/null +++ b/node_modules/rspack-resolver/README.md @@ -0,0 +1,39 @@ +# Rspack Resolver Napi Binding + +See + +* `index.d.ts` for `resolveSync` and `ResolverFactory` API. +* [README.md](https://github.com/unrs/rspack-resolver#rspack-resolver) for options. + +## API + +`resolve(directory, specifier)` - resolve `specifier` at an absolute path to a `directory`. + +### `directory` + +An **absolute** path to a directory where the specifier is resolved against. + +For CommonJS modules, it is the `__dirname` variable that contains the absolute path to the folder containing current module. + +For ECMAScript modules, it is the value of `import.meta.url`. + +Behavior is undefined when given a path to a file. + +### `specifier` + +The string passed to `require` or `import`, i.e. `require("specifier")` or `import "specifier"` + +## ESM Example + +```javascript +import path from 'path'; +import resolve, { ResolverFactory } from './index.js'; +import assert from 'assert'; + +// `resolve` +assert(resolve.sync(process.cwd(), "./index.js").path, path.join(cwd, 'index.js')); + +// `ResolverFactory` +const resolver = new ResolverFactory(); +assert(resolver.sync(process.cwd(), "./index.js").path, path.join(cwd, 'index.js')); +``` diff --git a/node_modules/rspack-resolver/browser.js b/node_modules/rspack-resolver/browser.js new file mode 100644 index 0000000000..196fe9a137 --- /dev/null +++ b/node_modules/rspack-resolver/browser.js @@ -0,0 +1 @@ +export * from '@unrs/rspack-resolver-binding-wasm32-wasi' diff --git a/node_modules/rspack-resolver/index.d.ts b/node_modules/rspack-resolver/index.d.ts new file mode 100644 index 0000000000..c0d903d0e5 --- /dev/null +++ b/node_modules/rspack-resolver/index.d.ts @@ -0,0 +1,226 @@ +/* auto-generated by NAPI-RS */ +/* eslint-disable */ +export declare class ResolverFactory { + constructor(options?: NapiResolveOptions | undefined | null) + static default(): ResolverFactory + /** Clone the resolver using the same underlying cache. */ + cloneWithOptions(options: NapiResolveOptions): ResolverFactory + /** Clear the underlying cache. */ + clearCache(): void + /** Synchronously resolve `specifier` at an absolute path to a `directory`. */ + sync(directory: string, request: string): ResolveResult + /** Asynchronously resolve `specifier` at an absolute path to a `directory`. */ + async(directory: string, request: string): Promise +} + +export declare const enum EnforceExtension { + Auto = 0, + Enabled = 1, + Disabled = 2 +} + +/** + * Module Resolution Options + * + * Options are directly ported from [enhanced-resolve](https://github.com/webpack/enhanced-resolve#resolver-options). + * + * See [webpack resolve](https://webpack.js.org/configuration/resolve/) for information and examples + */ +export interface NapiResolveOptions { + /** + * Path to TypeScript configuration file. + * + * Default `None` + */ + tsconfig?: TsconfigOptions + /** + * Alias for [ResolveOptions::alias] and [ResolveOptions::fallback]. + * + * For the second value of the tuple, `None -> AliasValue::Ignore`, Some(String) -> + * AliasValue::Path(String)` + * Create aliases to import or require certain modules more easily. + * A trailing $ can also be added to the given object's keys to signify an exact match. + */ + alias?: Record> + /** + * A list of alias fields in description files. + * Specify a field, such as `browser`, to be parsed according to [this specification](https://github.com/defunctzombie/package-browser-field-spec). + * Can be a path to json object such as `["path", "to", "exports"]`. + * + * Default `[]` + */ + aliasFields?: (string | string[])[] + /** + * Condition names for exports field which defines entry points of a package. + * The key order in the exports field is significant. During condition matching, earlier entries have higher priority and take precedence over later entries. + * + * Default `[]` + */ + conditionNames?: Array + /** + * The JSON files to use for descriptions. (There was once a `bower.json`.) + * + * Default `["package.json"]` + */ + descriptionFiles?: Array + /** + * If true, it will not allow extension-less files. + * So by default `require('./foo')` works if `./foo` has a `.js` extension, + * but with this enabled only `require('./foo.js')` will work. + * + * Default to `true` when [ResolveOptions::extensions] contains an empty string. + * Use `Some(false)` to disable the behavior. + * See + * + * Default None, which is the same as `Some(false)` when the above empty rule is not applied. + */ + enforceExtension?: EnforceExtension + /** + * A list of exports fields in description files. + * Can be a path to json object such as `["path", "to", "exports"]`. + * + * Default `[["exports"]]`. + */ + exportsFields?: (string | string[])[] + /** + * Fields from `package.json` which are used to provide the internal requests of a package + * (requests starting with # are considered internal). + * + * Can be a path to a JSON object such as `["path", "to", "imports"]`. + * + * Default `[["imports"]]`. + */ + importsFields?: (string | string[])[] + /** + * An object which maps extension to extension aliases. + * + * Default `{}` + */ + extensionAlias?: Record> + /** + * Attempt to resolve these extensions in order. + * If multiple files share the same name but have different extensions, + * will resolve the one with the extension listed first in the array and skip the rest. + * + * Default `[".js", ".json", ".node"]` + */ + extensions?: Array + /** + * Redirect module requests when normal resolving fails. + * + * Default `[]` + */ + fallback?: Record> + /** + * Request passed to resolve is already fully specified and extensions or main files are not resolved for it (they are still resolved for internal requests). + * + * See also webpack configuration [resolve.fullySpecified](https://webpack.js.org/configuration/module/#resolvefullyspecified) + * + * Default `false` + */ + fullySpecified?: boolean + /** + * A list of main fields in description files + * + * Default `["main"]`. + */ + mainFields?: string | string[] + /** + * The filename to be used while resolving directories. + * + * Default `["index"]` + */ + mainFiles?: Array + /** + * A list of directories to resolve modules from, can be absolute path or folder name. + * + * Default `["node_modules"]` + */ + modules?: string | string[] + /** + * Resolve to a context instead of a file. + * + * Default `false` + */ + resolveToContext?: boolean + /** + * Prefer to resolve module requests as relative requests instead of using modules from node_modules directories. + * + * Default `false` + */ + preferRelative?: boolean + /** + * Prefer to resolve server-relative urls as absolute paths before falling back to resolve in ResolveOptions::roots. + * + * Default `false` + */ + preferAbsolute?: boolean + /** + * A list of resolve restrictions to restrict the paths that a request can be resolved on. + * + * Default `[]` + */ + restrictions?: Array + /** + * A list of directories where requests of server-relative URLs (starting with '/') are resolved. + * On non-Windows systems these requests are resolved as an absolute path first. + * + * Default `[]` + */ + roots?: Array + /** + * Whether to resolve symlinks to their symlinked location. + * When enabled, symlinked resources are resolved to their real path, not their symlinked location. + * Note that this may cause module resolution to fail when using tools that symlink packages (like npm link). + * + * Default `true` + */ + symlinks?: boolean + /** + * Whether to parse [module.builtinModules](https://nodejs.org/api/module.html#modulebuiltinmodules) or not. + * For example, "zlib" will throw [crate::ResolveError::Builtin] when set to true. + * + * Default `false` + */ + builtinModules?: boolean +} + +export interface ResolveResult { + path?: string + error?: string + /** "type" field in the package.json file */ + moduleType?: string +} + +/** + * Alias Value for [ResolveOptions::alias] and [ResolveOptions::fallback]. + * Use struct because napi don't support structured union now + */ +export interface Restriction { + path?: string + regex?: string +} + +export declare function sync(path: string, request: string): ResolveResult + +/** + * Tsconfig Options + * + * Derived from [tsconfig-paths-webpack-plugin](https://github.com/dividab/tsconfig-paths-webpack-plugin#options) + */ +export interface TsconfigOptions { + /** + * Allows you to specify where to find the TypeScript configuration file. + * You may provide + * * a relative path to the configuration file. It will be resolved relative to cwd. + * * an absolute path to the configuration file. + */ + configFile: string + /** + * Support for Typescript Project References. + * + * * `'auto'`: use the `references` field from tsconfig of `config_file`. + * * `string[]`: manually provided relative or absolute path. + */ + references?: 'auto' | string[] +} diff --git a/node_modules/rspack-resolver/index.js b/node_modules/rspack-resolver/index.js new file mode 100644 index 0000000000..ea87446e7c --- /dev/null +++ b/node_modules/rspack-resolver/index.js @@ -0,0 +1,375 @@ +// prettier-ignore +/* eslint-disable */ +// @ts-nocheck +/* auto-generated by NAPI-RS */ + +const { createRequire } = require('node:module') +require = createRequire(__filename) + +const { readFileSync } = require('node:fs') +let nativeBinding = null +const loadErrors = [] + +const isMusl = () => { + let musl = false + if (process.platform === 'linux') { + musl = isMuslFromFilesystem() + if (musl === null) { + musl = isMuslFromReport() + } + if (musl === null) { + musl = isMuslFromChildProcess() + } + } + return musl +} + +const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-') + +const isMuslFromFilesystem = () => { + try { + return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl') + } catch { + return null + } +} + +const isMuslFromReport = () => { + const report = typeof process.report.getReport === 'function' ? process.report.getReport() : null + if (!report) { + return null + } + if (report.header && report.header.glibcVersionRuntime) { + return false + } + if (Array.isArray(report.sharedObjects)) { + if (report.sharedObjects.some(isFileMusl)) { + return true + } + } + return false +} + +const isMuslFromChildProcess = () => { + try { + return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl') + } catch (e) { + // If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false + return false + } +} + +function requireNative() { + if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) { + try { + nativeBinding = require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH); + } catch (err) { + loadErrors.push(err); + } + } else if (process.platform === 'android') { + if (process.arch === 'arm64') { + try { + return require('./resolver.android-arm64.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@unrs/rspack-resolver-binding-android-arm64') + } catch (e) { + loadErrors.push(e) + } + + } else if (process.arch === 'arm') { + try { + return require('./resolver.android-arm-eabi.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@unrs/rspack-resolver-binding-android-arm-eabi') + } catch (e) { + loadErrors.push(e) + } + + } else { + loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`)) + } + } else if (process.platform === 'win32') { + if (process.arch === 'x64') { + try { + return require('./resolver.win32-x64-msvc.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@unrs/rspack-resolver-binding-win32-x64-msvc') + } catch (e) { + loadErrors.push(e) + } + + } else if (process.arch === 'ia32') { + try { + return require('./resolver.win32-ia32-msvc.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@unrs/rspack-resolver-binding-win32-ia32-msvc') + } catch (e) { + loadErrors.push(e) + } + + } else if (process.arch === 'arm64') { + try { + return require('./resolver.win32-arm64-msvc.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@unrs/rspack-resolver-binding-win32-arm64-msvc') + } catch (e) { + loadErrors.push(e) + } + + } else { + loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`)) + } + } else if (process.platform === 'darwin') { + try { + return require('./resolver.darwin-universal.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@unrs/rspack-resolver-binding-darwin-universal') + } catch (e) { + loadErrors.push(e) + } + + if (process.arch === 'x64') { + try { + return require('./resolver.darwin-x64.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@unrs/rspack-resolver-binding-darwin-x64') + } catch (e) { + loadErrors.push(e) + } + + } else if (process.arch === 'arm64') { + try { + return require('./resolver.darwin-arm64.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@unrs/rspack-resolver-binding-darwin-arm64') + } catch (e) { + loadErrors.push(e) + } + + } else { + loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`)) + } + } else if (process.platform === 'freebsd') { + if (process.arch === 'x64') { + try { + return require('./resolver.freebsd-x64.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@unrs/rspack-resolver-binding-freebsd-x64') + } catch (e) { + loadErrors.push(e) + } + + } else if (process.arch === 'arm64') { + try { + return require('./resolver.freebsd-arm64.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@unrs/rspack-resolver-binding-freebsd-arm64') + } catch (e) { + loadErrors.push(e) + } + + } else { + loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`)) + } + } else if (process.platform === 'linux') { + if (process.arch === 'x64') { + if (isMusl()) { + try { + return require('./resolver.linux-x64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@unrs/rspack-resolver-binding-linux-x64-musl') + } catch (e) { + loadErrors.push(e) + } + + } else { + try { + return require('./resolver.linux-x64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@unrs/rspack-resolver-binding-linux-x64-gnu') + } catch (e) { + loadErrors.push(e) + } + + } + } else if (process.arch === 'arm64') { + if (isMusl()) { + try { + return require('./resolver.linux-arm64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@unrs/rspack-resolver-binding-linux-arm64-musl') + } catch (e) { + loadErrors.push(e) + } + + } else { + try { + return require('./resolver.linux-arm64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@unrs/rspack-resolver-binding-linux-arm64-gnu') + } catch (e) { + loadErrors.push(e) + } + + } + } else if (process.arch === 'arm') { + if (isMusl()) { + try { + return require('./resolver.linux-arm-musleabihf.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@unrs/rspack-resolver-binding-linux-arm-musleabihf') + } catch (e) { + loadErrors.push(e) + } + + } else { + try { + return require('./resolver.linux-arm-gnueabihf.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@unrs/rspack-resolver-binding-linux-arm-gnueabihf') + } catch (e) { + loadErrors.push(e) + } + + } + } else if (process.arch === 'riscv64') { + if (isMusl()) { + try { + return require('./resolver.linux-riscv64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@unrs/rspack-resolver-binding-linux-riscv64-musl') + } catch (e) { + loadErrors.push(e) + } + + } else { + try { + return require('./resolver.linux-riscv64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@unrs/rspack-resolver-binding-linux-riscv64-gnu') + } catch (e) { + loadErrors.push(e) + } + + } + } else if (process.arch === 'ppc64') { + try { + return require('./resolver.linux-ppc64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@unrs/rspack-resolver-binding-linux-ppc64-gnu') + } catch (e) { + loadErrors.push(e) + } + + } else if (process.arch === 's390x') { + try { + return require('./resolver.linux-s390x-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@unrs/rspack-resolver-binding-linux-s390x-gnu') + } catch (e) { + loadErrors.push(e) + } + + } else { + loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`)) + } + } else { + loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`)) + } +} + +nativeBinding = requireNative() + +if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) { + try { + nativeBinding = require('./resolver.wasi.cjs') + } catch (err) { + if (process.env.NAPI_RS_FORCE_WASI) { + loadErrors.push(err) + } + } + if (!nativeBinding) { + try { + nativeBinding = require('@unrs/rspack-resolver-binding-wasm32-wasi') + } catch (err) { + if (process.env.NAPI_RS_FORCE_WASI) { + loadErrors.push(err) + } + } + } +} + +if (!nativeBinding) { + if (loadErrors.length > 0) { + // TODO Link to documentation with potential fixes + // - The package owner could build/publish bindings for this arch + // - The user may need to bundle the correct files + // - The user may need to re-install node_modules to get new packages + throw new Error('Failed to load native binding', { cause: loadErrors }) + } + throw new Error(`Failed to load native binding`) +} + +module.exports.ResolverFactory = nativeBinding.ResolverFactory +module.exports.EnforceExtension = nativeBinding.EnforceExtension +module.exports.sync = nativeBinding.sync diff --git a/node_modules/rspack-resolver/package.json b/node_modules/rspack-resolver/package.json new file mode 100644 index 0000000000..483e94cf93 --- /dev/null +++ b/node_modules/rspack-resolver/package.json @@ -0,0 +1,60 @@ +{ + "name": "rspack-resolver", + "version": "1.1.2", + "description": "Oxc Resolver Node API with PNP support", + "main": "index.js", + "browser": "browser.js", + "files": [ + "index.d.ts", + "index.js", + "browser.js" + ], + "license": "MIT", + "homepage": "https://github.com/unrs/rspack-resolver", + "repository": { + "type": "git", + "url": "git+https://github.com/unrs/rspack-resolver.git" + }, + "publishConfig": { + "registry": "https://registry.npmjs.org/", + "access": "public" + }, + "napi": { + "binaryName": "resolver", + "packageName": "@unrs/rspack-resolver-binding", + "wasm": { + "browser": { + "fs": true + } + }, + "targets": [ + "x86_64-pc-windows-msvc", + "aarch64-pc-windows-msvc", + "x86_64-unknown-linux-gnu", + "x86_64-unknown-linux-musl", + "x86_64-unknown-freebsd", + "aarch64-unknown-linux-gnu", + "aarch64-unknown-linux-musl", + "armv7-unknown-linux-gnueabihf", + "x86_64-apple-darwin", + "aarch64-apple-darwin", + "wasm32-wasip1-threads" + ] + }, + "funding": { + "url": "https://github.com/sponsors/JounQin" + }, + "optionalDependencies": { + "@unrs/rspack-resolver-binding-win32-x64-msvc": "1.1.2", + "@unrs/rspack-resolver-binding-win32-arm64-msvc": "1.1.2", + "@unrs/rspack-resolver-binding-linux-x64-gnu": "1.1.2", + "@unrs/rspack-resolver-binding-linux-x64-musl": "1.1.2", + "@unrs/rspack-resolver-binding-freebsd-x64": "1.1.2", + "@unrs/rspack-resolver-binding-linux-arm64-gnu": "1.1.2", + "@unrs/rspack-resolver-binding-linux-arm64-musl": "1.1.2", + "@unrs/rspack-resolver-binding-linux-arm-gnueabihf": "1.1.2", + "@unrs/rspack-resolver-binding-darwin-x64": "1.1.2", + "@unrs/rspack-resolver-binding-darwin-arm64": "1.1.2", + "@unrs/rspack-resolver-binding-wasm32-wasi": "1.1.2" + } +} \ No newline at end of file diff --git a/node_modules/stable-hash/dist/index.d.ts b/node_modules/stable-hash/dist/index.d.ts index 89f0d09954..db08bdae90 100644 --- a/node_modules/stable-hash/dist/index.d.ts +++ b/node_modules/stable-hash/dist/index.d.ts @@ -1 +1,2 @@ -export default function stableHash(arg: any): string; +export declare function stableHash(arg: any): string; +export default stableHash; diff --git a/node_modules/stable-hash/dist/index.js b/node_modules/stable-hash/dist/index.js index 44df1e4210..2074d0766f 100644 --- a/node_modules/stable-hash/dist/index.js +++ b/node_modules/stable-hash/dist/index.js @@ -1 +1 @@ -var u=Object.defineProperty;var r=t=>u(t,"__esModule",{value:!0});var y=(t,i)=>{r(t);for(var s in i)u(t,s,{get:i[s],enumerable:!0})};y(exports,{default:()=>c});const o=new WeakMap;let b=0;function c(t){const i=typeof t,s=t&&t.constructor,f=s==Date;if(Object(t)===t&&!f&&s!=RegExp){let e=o.get(t);if(e)return e;e=++b+"~",o.set(t,e);let n;if(s==Array){for(e="@",n=0;nu(t,"__esModule",{value:!0});var y=(t,o)=>{r(t);for(var s in o)u(t,s,{get:o[s],enumerable:!0})};y(exports,{default:()=>b,stableHash:()=>c});const i=new WeakMap;let p=0;function c(t){const o=typeof t,s=t&&t.constructor,f=s==Date;if(Object(t)===t&&!f&&s!=RegExp){let e=i.get(t);if(e)return e;e=++p+"~",i.set(t,e);let n;if(s==Array){for(e="@",n=0;n warningLamp.on()); -``` - -It's required to pass a name to identify the plugin/reason. - -You may receive arguments: - -``` js -myCar.hooks.accelerate.tap("LoggerPlugin", newSpeed => console.log(`Accelerating to ${newSpeed}`)); -``` - -For sync hooks, `tap` is the only valid method to add a plugin. Async hooks also support async plugins: - -``` js -myCar.hooks.calculateRoutes.tapPromise("GoogleMapsPlugin", (source, target, routesList) => { - // return a promise - return google.maps.findRoute(source, target).then(route => { - routesList.add(route); - }); -}); -myCar.hooks.calculateRoutes.tapAsync("BingMapsPlugin", (source, target, routesList, callback) => { - bing.findRoute(source, target, (err, route) => { - if(err) return callback(err); - routesList.add(route); - // call the callback - callback(); - }); -}); - -// You can still use sync plugins -myCar.hooks.calculateRoutes.tap("CachedRoutesPlugin", (source, target, routesList) => { - const cachedRoute = cache.get(source, target); - if(cachedRoute) - routesList.add(cachedRoute); -}) -``` -The class declaring these hooks need to call them: - -``` js -class Car { - /** - * You won't get returned value from SyncHook or AsyncParallelHook, - * to do that, use SyncWaterfallHook and AsyncSeriesWaterfallHook respectively - **/ - - setSpeed(newSpeed) { - // following call returns undefined even when you returned values - this.hooks.accelerate.call(newSpeed); - } - - useNavigationSystemPromise(source, target) { - const routesList = new List(); - return this.hooks.calculateRoutes.promise(source, target, routesList).then((res) => { - // res is undefined for AsyncParallelHook - return routesList.getRoutes(); - }); - } - - useNavigationSystemAsync(source, target, callback) { - const routesList = new List(); - this.hooks.calculateRoutes.callAsync(source, target, routesList, err => { - if(err) return callback(err); - callback(null, routesList.getRoutes()); - }); - } -} -``` - -The Hook will compile a method with the most efficient way of running your plugins. It generates code depending on: -* The number of registered plugins (none, one, many) -* The kind of registered plugins (sync, async, promise) -* The used call method (sync, async, promise) -* The number of arguments -* Whether interception is used - -This ensures fastest possible execution. - -## Hook types - -Each hook can be tapped with one or several functions. How they are executed depends on the hook type: - -* Basic hook (without “Waterfall”, “Bail” or “Loop” in its name). This hook simply calls every function it tapped in a row. - -* __Waterfall__. A waterfall hook also calls each tapped function in a row. Unlike the basic hook, it passes a return value from each function to the next function. - -* __Bail__. A bail hook allows exiting early. When any of the tapped function returns anything, the bail hook will stop executing the remaining ones. - -* __Loop__. When a plugin in a loop hook returns a non-undefined value the hook will restart from the first plugin. It will loop until all plugins return undefined. - -Additionally, hooks can be synchronous or asynchronous. To reflect this, there’re “Sync”, “AsyncSeries”, and “AsyncParallel” hook classes: - -* __Sync__. A sync hook can only be tapped with synchronous functions (using `myHook.tap()`). - -* __AsyncSeries__. An async-series hook can be tapped with synchronous, callback-based and promise-based functions (using `myHook.tap()`, `myHook.tapAsync()` and `myHook.tapPromise()`). They call each async method in a row. - -* __AsyncParallel__. An async-parallel hook can also be tapped with synchronous, callback-based and promise-based functions (using `myHook.tap()`, `myHook.tapAsync()` and `myHook.tapPromise()`). However, they run each async method in parallel. - -The hook type is reflected in its class name. E.g., `AsyncSeriesWaterfallHook` allows asynchronous functions and runs them in series, passing each function’s return value into the next function. - - -## Interception - -All Hooks offer an additional interception API: - -``` js -myCar.hooks.calculateRoutes.intercept({ - call: (source, target, routesList) => { - console.log("Starting to calculate routes"); - }, - register: (tapInfo) => { - // tapInfo = { type: "promise", name: "GoogleMapsPlugin", fn: ... } - console.log(`${tapInfo.name} is doing its job`); - return tapInfo; // may return a new tapInfo object - } -}) -``` - -**call**: `(...args) => void` Adding `call` to your interceptor will trigger when hooks are triggered. You have access to the hooks arguments. - -**tap**: `(tap: Tap) => void` Adding `tap` to your interceptor will trigger when a plugin taps into a hook. Provided is the `Tap` object. `Tap` object can't be changed. - -**loop**: `(...args) => void` Adding `loop` to your interceptor will trigger for each loop of a looping hook. - -**register**: `(tap: Tap) => Tap | undefined` Adding `register` to your interceptor will trigger for each added `Tap` and allows to modify it. - -## Context - -Plugins and interceptors can opt-in to access an optional `context` object, which can be used to pass arbitrary values to subsequent plugins and interceptors. - -``` js -myCar.hooks.accelerate.intercept({ - context: true, - tap: (context, tapInfo) => { - // tapInfo = { type: "sync", name: "NoisePlugin", fn: ... } - console.log(`${tapInfo.name} is doing it's job`); - - // `context` starts as an empty object if at least one plugin uses `context: true`. - // If no plugins use `context: true`, then `context` is undefined. - if (context) { - // Arbitrary properties can be added to `context`, which plugins can then access. - context.hasMuffler = true; - } - } -}); - -myCar.hooks.accelerate.tap({ - name: "NoisePlugin", - context: true -}, (context, newSpeed) => { - if (context && context.hasMuffler) { - console.log("Silence..."); - } else { - console.log("Vroom!"); - } -}); -``` - -## HookMap - -A HookMap is a helper class for a Map with Hooks - -``` js -const keyedHook = new HookMap(key => new SyncHook(["arg"])) -``` - -``` js -keyedHook.for("some-key").tap("MyPlugin", (arg) => { /* ... */ }); -keyedHook.for("some-key").tapAsync("MyPlugin", (arg, callback) => { /* ... */ }); -keyedHook.for("some-key").tapPromise("MyPlugin", (arg) => { /* ... */ }); -``` - -``` js -const hook = keyedHook.get("some-key"); -if(hook !== undefined) { - hook.callAsync("arg", err => { /* ... */ }); -} -``` - -## Hook/HookMap interface - -Public: - -``` ts -interface Hook { - tap: (name: string | Tap, fn: (context?, ...args) => Result) => void, - tapAsync: (name: string | Tap, fn: (context?, ...args, callback: (err, result: Result) => void) => void) => void, - tapPromise: (name: string | Tap, fn: (context?, ...args) => Promise) => void, - intercept: (interceptor: HookInterceptor) => void -} - -interface HookInterceptor { - call: (context?, ...args) => void, - loop: (context?, ...args) => void, - tap: (context?, tap: Tap) => void, - register: (tap: Tap) => Tap, - context: boolean -} - -interface HookMap { - for: (key: any) => Hook, - intercept: (interceptor: HookMapInterceptor) => void -} - -interface HookMapInterceptor { - factory: (key: any, hook: Hook) => Hook -} - -interface Tap { - name: string, - type: string - fn: Function, - stage: number, - context: boolean, - before?: string | Array -} -``` - -Protected (only for the class containing the hook): - -``` ts -interface Hook { - isUsed: () => boolean, - call: (...args) => Result, - promise: (...args) => Promise, - callAsync: (...args, callback: (err, result: Result) => void) => void, -} - -interface HookMap { - get: (key: any) => Hook | undefined, - for: (key: any) => Hook -} -``` - -## MultiHook - -A helper Hook-like class to redirect taps to multiple other hooks: - -``` js -const { MultiHook } = require("tapable"); - -this.hooks.allHooks = new MultiHook([this.hooks.hookA, this.hooks.hookB]); -``` diff --git a/node_modules/tapable/lib/AsyncParallelBailHook.js b/node_modules/tapable/lib/AsyncParallelBailHook.js deleted file mode 100644 index 45eca33c89..0000000000 --- a/node_modules/tapable/lib/AsyncParallelBailHook.js +++ /dev/null @@ -1,85 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ -"use strict"; - -const Hook = require("./Hook"); -const HookCodeFactory = require("./HookCodeFactory"); - -class AsyncParallelBailHookCodeFactory extends HookCodeFactory { - content({ onError, onResult, onDone }) { - let code = ""; - code += `var _results = new Array(${this.options.taps.length});\n`; - code += "var _checkDone = function() {\n"; - code += "for(var i = 0; i < _results.length; i++) {\n"; - code += "var item = _results[i];\n"; - code += "if(item === undefined) return false;\n"; - code += "if(item.result !== undefined) {\n"; - code += onResult("item.result"); - code += "return true;\n"; - code += "}\n"; - code += "if(item.error) {\n"; - code += onError("item.error"); - code += "return true;\n"; - code += "}\n"; - code += "}\n"; - code += "return false;\n"; - code += "}\n"; - code += this.callTapsParallel({ - onError: (i, err, done, doneBreak) => { - let code = ""; - code += `if(${i} < _results.length && ((_results.length = ${i + - 1}), (_results[${i}] = { error: ${err} }), _checkDone())) {\n`; - code += doneBreak(true); - code += "} else {\n"; - code += done(); - code += "}\n"; - return code; - }, - onResult: (i, result, done, doneBreak) => { - let code = ""; - code += `if(${i} < _results.length && (${result} !== undefined && (_results.length = ${i + - 1}), (_results[${i}] = { result: ${result} }), _checkDone())) {\n`; - code += doneBreak(true); - code += "} else {\n"; - code += done(); - code += "}\n"; - return code; - }, - onTap: (i, run, done, doneBreak) => { - let code = ""; - if (i > 0) { - code += `if(${i} >= _results.length) {\n`; - code += done(); - code += "} else {\n"; - } - code += run(); - if (i > 0) code += "}\n"; - return code; - }, - onDone - }); - return code; - } -} - -const factory = new AsyncParallelBailHookCodeFactory(); - -const COMPILE = function(options) { - factory.setup(this, options); - return factory.create(options); -}; - -function AsyncParallelBailHook(args = [], name = undefined) { - const hook = new Hook(args, name); - hook.constructor = AsyncParallelBailHook; - hook.compile = COMPILE; - hook._call = undefined; - hook.call = undefined; - return hook; -} - -AsyncParallelBailHook.prototype = null; - -module.exports = AsyncParallelBailHook; diff --git a/node_modules/tapable/lib/AsyncParallelHook.js b/node_modules/tapable/lib/AsyncParallelHook.js deleted file mode 100644 index b7a36314dc..0000000000 --- a/node_modules/tapable/lib/AsyncParallelHook.js +++ /dev/null @@ -1,37 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ -"use strict"; - -const Hook = require("./Hook"); -const HookCodeFactory = require("./HookCodeFactory"); - -class AsyncParallelHookCodeFactory extends HookCodeFactory { - content({ onError, onDone }) { - return this.callTapsParallel({ - onError: (i, err, done, doneBreak) => onError(err) + doneBreak(true), - onDone - }); - } -} - -const factory = new AsyncParallelHookCodeFactory(); - -const COMPILE = function(options) { - factory.setup(this, options); - return factory.create(options); -}; - -function AsyncParallelHook(args = [], name = undefined) { - const hook = new Hook(args, name); - hook.constructor = AsyncParallelHook; - hook.compile = COMPILE; - hook._call = undefined; - hook.call = undefined; - return hook; -} - -AsyncParallelHook.prototype = null; - -module.exports = AsyncParallelHook; diff --git a/node_modules/tapable/lib/AsyncSeriesBailHook.js b/node_modules/tapable/lib/AsyncSeriesBailHook.js deleted file mode 100644 index 5df66dfb78..0000000000 --- a/node_modules/tapable/lib/AsyncSeriesBailHook.js +++ /dev/null @@ -1,42 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ -"use strict"; - -const Hook = require("./Hook"); -const HookCodeFactory = require("./HookCodeFactory"); - -class AsyncSeriesBailHookCodeFactory extends HookCodeFactory { - content({ onError, onResult, resultReturns, onDone }) { - return this.callTapsSeries({ - onError: (i, err, next, doneBreak) => onError(err) + doneBreak(true), - onResult: (i, result, next) => - `if(${result} !== undefined) {\n${onResult( - result - )}\n} else {\n${next()}}\n`, - resultReturns, - onDone - }); - } -} - -const factory = new AsyncSeriesBailHookCodeFactory(); - -const COMPILE = function(options) { - factory.setup(this, options); - return factory.create(options); -}; - -function AsyncSeriesBailHook(args = [], name = undefined) { - const hook = new Hook(args, name); - hook.constructor = AsyncSeriesBailHook; - hook.compile = COMPILE; - hook._call = undefined; - hook.call = undefined; - return hook; -} - -AsyncSeriesBailHook.prototype = null; - -module.exports = AsyncSeriesBailHook; diff --git a/node_modules/tapable/lib/AsyncSeriesHook.js b/node_modules/tapable/lib/AsyncSeriesHook.js deleted file mode 100644 index 3edad00517..0000000000 --- a/node_modules/tapable/lib/AsyncSeriesHook.js +++ /dev/null @@ -1,37 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ -"use strict"; - -const Hook = require("./Hook"); -const HookCodeFactory = require("./HookCodeFactory"); - -class AsyncSeriesHookCodeFactory extends HookCodeFactory { - content({ onError, onDone }) { - return this.callTapsSeries({ - onError: (i, err, next, doneBreak) => onError(err) + doneBreak(true), - onDone - }); - } -} - -const factory = new AsyncSeriesHookCodeFactory(); - -const COMPILE = function(options) { - factory.setup(this, options); - return factory.create(options); -}; - -function AsyncSeriesHook(args = [], name = undefined) { - const hook = new Hook(args, name); - hook.constructor = AsyncSeriesHook; - hook.compile = COMPILE; - hook._call = undefined; - hook.call = undefined; - return hook; -} - -AsyncSeriesHook.prototype = null; - -module.exports = AsyncSeriesHook; diff --git a/node_modules/tapable/lib/AsyncSeriesLoopHook.js b/node_modules/tapable/lib/AsyncSeriesLoopHook.js deleted file mode 100644 index fb5f067e2c..0000000000 --- a/node_modules/tapable/lib/AsyncSeriesLoopHook.js +++ /dev/null @@ -1,37 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ -"use strict"; - -const Hook = require("./Hook"); -const HookCodeFactory = require("./HookCodeFactory"); - -class AsyncSeriesLoopHookCodeFactory extends HookCodeFactory { - content({ onError, onDone }) { - return this.callTapsLooping({ - onError: (i, err, next, doneBreak) => onError(err) + doneBreak(true), - onDone - }); - } -} - -const factory = new AsyncSeriesLoopHookCodeFactory(); - -const COMPILE = function(options) { - factory.setup(this, options); - return factory.create(options); -}; - -function AsyncSeriesLoopHook(args = [], name = undefined) { - const hook = new Hook(args, name); - hook.constructor = AsyncSeriesLoopHook; - hook.compile = COMPILE; - hook._call = undefined; - hook.call = undefined; - return hook; -} - -AsyncSeriesLoopHook.prototype = null; - -module.exports = AsyncSeriesLoopHook; diff --git a/node_modules/tapable/lib/AsyncSeriesWaterfallHook.js b/node_modules/tapable/lib/AsyncSeriesWaterfallHook.js deleted file mode 100644 index 910b536f74..0000000000 --- a/node_modules/tapable/lib/AsyncSeriesWaterfallHook.js +++ /dev/null @@ -1,47 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ -"use strict"; - -const Hook = require("./Hook"); -const HookCodeFactory = require("./HookCodeFactory"); - -class AsyncSeriesWaterfallHookCodeFactory extends HookCodeFactory { - content({ onError, onResult, onDone }) { - return this.callTapsSeries({ - onError: (i, err, next, doneBreak) => onError(err) + doneBreak(true), - onResult: (i, result, next) => { - let code = ""; - code += `if(${result} !== undefined) {\n`; - code += `${this._args[0]} = ${result};\n`; - code += `}\n`; - code += next(); - return code; - }, - onDone: () => onResult(this._args[0]) - }); - } -} - -const factory = new AsyncSeriesWaterfallHookCodeFactory(); - -const COMPILE = function(options) { - factory.setup(this, options); - return factory.create(options); -}; - -function AsyncSeriesWaterfallHook(args = [], name = undefined) { - if (args.length < 1) - throw new Error("Waterfall hooks must have at least one argument"); - const hook = new Hook(args, name); - hook.constructor = AsyncSeriesWaterfallHook; - hook.compile = COMPILE; - hook._call = undefined; - hook.call = undefined; - return hook; -} - -AsyncSeriesWaterfallHook.prototype = null; - -module.exports = AsyncSeriesWaterfallHook; diff --git a/node_modules/tapable/lib/Hook.js b/node_modules/tapable/lib/Hook.js deleted file mode 100644 index db04426f05..0000000000 --- a/node_modules/tapable/lib/Hook.js +++ /dev/null @@ -1,175 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ -"use strict"; - -const util = require("util"); - -const deprecateContext = util.deprecate(() => {}, -"Hook.context is deprecated and will be removed"); - -const CALL_DELEGATE = function(...args) { - this.call = this._createCall("sync"); - return this.call(...args); -}; -const CALL_ASYNC_DELEGATE = function(...args) { - this.callAsync = this._createCall("async"); - return this.callAsync(...args); -}; -const PROMISE_DELEGATE = function(...args) { - this.promise = this._createCall("promise"); - return this.promise(...args); -}; - -class Hook { - constructor(args = [], name = undefined) { - this._args = args; - this.name = name; - this.taps = []; - this.interceptors = []; - this._call = CALL_DELEGATE; - this.call = CALL_DELEGATE; - this._callAsync = CALL_ASYNC_DELEGATE; - this.callAsync = CALL_ASYNC_DELEGATE; - this._promise = PROMISE_DELEGATE; - this.promise = PROMISE_DELEGATE; - this._x = undefined; - - this.compile = this.compile; - this.tap = this.tap; - this.tapAsync = this.tapAsync; - this.tapPromise = this.tapPromise; - } - - compile(options) { - throw new Error("Abstract: should be overridden"); - } - - _createCall(type) { - return this.compile({ - taps: this.taps, - interceptors: this.interceptors, - args: this._args, - type: type - }); - } - - _tap(type, options, fn) { - if (typeof options === "string") { - options = { - name: options.trim() - }; - } else if (typeof options !== "object" || options === null) { - throw new Error("Invalid tap options"); - } - if (typeof options.name !== "string" || options.name === "") { - throw new Error("Missing name for tap"); - } - if (typeof options.context !== "undefined") { - deprecateContext(); - } - options = Object.assign({ type, fn }, options); - options = this._runRegisterInterceptors(options); - this._insert(options); - } - - tap(options, fn) { - this._tap("sync", options, fn); - } - - tapAsync(options, fn) { - this._tap("async", options, fn); - } - - tapPromise(options, fn) { - this._tap("promise", options, fn); - } - - _runRegisterInterceptors(options) { - for (const interceptor of this.interceptors) { - if (interceptor.register) { - const newOptions = interceptor.register(options); - if (newOptions !== undefined) { - options = newOptions; - } - } - } - return options; - } - - withOptions(options) { - const mergeOptions = opt => - Object.assign({}, options, typeof opt === "string" ? { name: opt } : opt); - - return { - name: this.name, - tap: (opt, fn) => this.tap(mergeOptions(opt), fn), - tapAsync: (opt, fn) => this.tapAsync(mergeOptions(opt), fn), - tapPromise: (opt, fn) => this.tapPromise(mergeOptions(opt), fn), - intercept: interceptor => this.intercept(interceptor), - isUsed: () => this.isUsed(), - withOptions: opt => this.withOptions(mergeOptions(opt)) - }; - } - - isUsed() { - return this.taps.length > 0 || this.interceptors.length > 0; - } - - intercept(interceptor) { - this._resetCompilation(); - this.interceptors.push(Object.assign({}, interceptor)); - if (interceptor.register) { - for (let i = 0; i < this.taps.length; i++) { - this.taps[i] = interceptor.register(this.taps[i]); - } - } - } - - _resetCompilation() { - this.call = this._call; - this.callAsync = this._callAsync; - this.promise = this._promise; - } - - _insert(item) { - this._resetCompilation(); - let before; - if (typeof item.before === "string") { - before = new Set([item.before]); - } else if (Array.isArray(item.before)) { - before = new Set(item.before); - } - let stage = 0; - if (typeof item.stage === "number") { - stage = item.stage; - } - let i = this.taps.length; - while (i > 0) { - i--; - const x = this.taps[i]; - this.taps[i + 1] = x; - const xStage = x.stage || 0; - if (before) { - if (before.has(x.name)) { - before.delete(x.name); - continue; - } - if (before.size > 0) { - continue; - } - } - if (xStage > stage) { - continue; - } - i++; - break; - } - this.taps[i] = item; - } -} - -Object.setPrototypeOf(Hook.prototype, null); - -module.exports = Hook; diff --git a/node_modules/tapable/lib/HookCodeFactory.js b/node_modules/tapable/lib/HookCodeFactory.js deleted file mode 100644 index c9f53402e8..0000000000 --- a/node_modules/tapable/lib/HookCodeFactory.js +++ /dev/null @@ -1,468 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ -"use strict"; - -class HookCodeFactory { - constructor(config) { - this.config = config; - this.options = undefined; - this._args = undefined; - } - - create(options) { - this.init(options); - let fn; - switch (this.options.type) { - case "sync": - fn = new Function( - this.args(), - '"use strict";\n' + - this.header() + - this.contentWithInterceptors({ - onError: err => `throw ${err};\n`, - onResult: result => `return ${result};\n`, - resultReturns: true, - onDone: () => "", - rethrowIfPossible: true - }) - ); - break; - case "async": - fn = new Function( - this.args({ - after: "_callback" - }), - '"use strict";\n' + - this.header() + - this.contentWithInterceptors({ - onError: err => `_callback(${err});\n`, - onResult: result => `_callback(null, ${result});\n`, - onDone: () => "_callback();\n" - }) - ); - break; - case "promise": - let errorHelperUsed = false; - const content = this.contentWithInterceptors({ - onError: err => { - errorHelperUsed = true; - return `_error(${err});\n`; - }, - onResult: result => `_resolve(${result});\n`, - onDone: () => "_resolve();\n" - }); - let code = ""; - code += '"use strict";\n'; - code += this.header(); - code += "return new Promise((function(_resolve, _reject) {\n"; - if (errorHelperUsed) { - code += "var _sync = true;\n"; - code += "function _error(_err) {\n"; - code += "if(_sync)\n"; - code += - "_resolve(Promise.resolve().then((function() { throw _err; })));\n"; - code += "else\n"; - code += "_reject(_err);\n"; - code += "};\n"; - } - code += content; - if (errorHelperUsed) { - code += "_sync = false;\n"; - } - code += "}));\n"; - fn = new Function(this.args(), code); - break; - } - this.deinit(); - return fn; - } - - setup(instance, options) { - instance._x = options.taps.map(t => t.fn); - } - - /** - * @param {{ type: "sync" | "promise" | "async", taps: Array, interceptors: Array }} options - */ - init(options) { - this.options = options; - this._args = options.args.slice(); - } - - deinit() { - this.options = undefined; - this._args = undefined; - } - - contentWithInterceptors(options) { - if (this.options.interceptors.length > 0) { - const onError = options.onError; - const onResult = options.onResult; - const onDone = options.onDone; - let code = ""; - for (let i = 0; i < this.options.interceptors.length; i++) { - const interceptor = this.options.interceptors[i]; - if (interceptor.call) { - code += `${this.getInterceptor(i)}.call(${this.args({ - before: interceptor.context ? "_context" : undefined - })});\n`; - } - } - code += this.content( - Object.assign(options, { - onError: - onError && - (err => { - let code = ""; - for (let i = 0; i < this.options.interceptors.length; i++) { - const interceptor = this.options.interceptors[i]; - if (interceptor.error) { - code += `${this.getInterceptor(i)}.error(${err});\n`; - } - } - code += onError(err); - return code; - }), - onResult: - onResult && - (result => { - let code = ""; - for (let i = 0; i < this.options.interceptors.length; i++) { - const interceptor = this.options.interceptors[i]; - if (interceptor.result) { - code += `${this.getInterceptor(i)}.result(${result});\n`; - } - } - code += onResult(result); - return code; - }), - onDone: - onDone && - (() => { - let code = ""; - for (let i = 0; i < this.options.interceptors.length; i++) { - const interceptor = this.options.interceptors[i]; - if (interceptor.done) { - code += `${this.getInterceptor(i)}.done();\n`; - } - } - code += onDone(); - return code; - }) - }) - ); - return code; - } else { - return this.content(options); - } - } - - header() { - let code = ""; - if (this.needContext()) { - code += "var _context = {};\n"; - } else { - code += "var _context;\n"; - } - code += "var _x = this._x;\n"; - if (this.options.interceptors.length > 0) { - code += "var _taps = this.taps;\n"; - code += "var _interceptors = this.interceptors;\n"; - } - return code; - } - - needContext() { - for (const tap of this.options.taps) if (tap.context) return true; - return false; - } - - callTap(tapIndex, { onError, onResult, onDone, rethrowIfPossible }) { - let code = ""; - let hasTapCached = false; - for (let i = 0; i < this.options.interceptors.length; i++) { - const interceptor = this.options.interceptors[i]; - if (interceptor.tap) { - if (!hasTapCached) { - code += `var _tap${tapIndex} = ${this.getTap(tapIndex)};\n`; - hasTapCached = true; - } - code += `${this.getInterceptor(i)}.tap(${ - interceptor.context ? "_context, " : "" - }_tap${tapIndex});\n`; - } - } - code += `var _fn${tapIndex} = ${this.getTapFn(tapIndex)};\n`; - const tap = this.options.taps[tapIndex]; - switch (tap.type) { - case "sync": - if (!rethrowIfPossible) { - code += `var _hasError${tapIndex} = false;\n`; - code += "try {\n"; - } - if (onResult) { - code += `var _result${tapIndex} = _fn${tapIndex}(${this.args({ - before: tap.context ? "_context" : undefined - })});\n`; - } else { - code += `_fn${tapIndex}(${this.args({ - before: tap.context ? "_context" : undefined - })});\n`; - } - if (!rethrowIfPossible) { - code += "} catch(_err) {\n"; - code += `_hasError${tapIndex} = true;\n`; - code += onError("_err"); - code += "}\n"; - code += `if(!_hasError${tapIndex}) {\n`; - } - if (onResult) { - code += onResult(`_result${tapIndex}`); - } - if (onDone) { - code += onDone(); - } - if (!rethrowIfPossible) { - code += "}\n"; - } - break; - case "async": - let cbCode = ""; - if (onResult) - cbCode += `(function(_err${tapIndex}, _result${tapIndex}) {\n`; - else cbCode += `(function(_err${tapIndex}) {\n`; - cbCode += `if(_err${tapIndex}) {\n`; - cbCode += onError(`_err${tapIndex}`); - cbCode += "} else {\n"; - if (onResult) { - cbCode += onResult(`_result${tapIndex}`); - } - if (onDone) { - cbCode += onDone(); - } - cbCode += "}\n"; - cbCode += "})"; - code += `_fn${tapIndex}(${this.args({ - before: tap.context ? "_context" : undefined, - after: cbCode - })});\n`; - break; - case "promise": - code += `var _hasResult${tapIndex} = false;\n`; - code += `var _promise${tapIndex} = _fn${tapIndex}(${this.args({ - before: tap.context ? "_context" : undefined - })});\n`; - code += `if (!_promise${tapIndex} || !_promise${tapIndex}.then)\n`; - code += ` throw new Error('Tap function (tapPromise) did not return promise (returned ' + _promise${tapIndex} + ')');\n`; - code += `_promise${tapIndex}.then((function(_result${tapIndex}) {\n`; - code += `_hasResult${tapIndex} = true;\n`; - if (onResult) { - code += onResult(`_result${tapIndex}`); - } - if (onDone) { - code += onDone(); - } - code += `}), function(_err${tapIndex}) {\n`; - code += `if(_hasResult${tapIndex}) throw _err${tapIndex};\n`; - code += onError(`_err${tapIndex}`); - code += "});\n"; - break; - } - return code; - } - - callTapsSeries({ - onError, - onResult, - resultReturns, - onDone, - doneReturns, - rethrowIfPossible - }) { - if (this.options.taps.length === 0) return onDone(); - const firstAsync = this.options.taps.findIndex(t => t.type !== "sync"); - const somethingReturns = resultReturns || doneReturns; - let code = ""; - let current = onDone; - let unrollCounter = 0; - for (let j = this.options.taps.length - 1; j >= 0; j--) { - const i = j; - const unroll = - current !== onDone && - (this.options.taps[i].type !== "sync" || unrollCounter++ > 20); - if (unroll) { - unrollCounter = 0; - code += `function _next${i}() {\n`; - code += current(); - code += `}\n`; - current = () => `${somethingReturns ? "return " : ""}_next${i}();\n`; - } - const done = current; - const doneBreak = skipDone => { - if (skipDone) return ""; - return onDone(); - }; - const content = this.callTap(i, { - onError: error => onError(i, error, done, doneBreak), - onResult: - onResult && - (result => { - return onResult(i, result, done, doneBreak); - }), - onDone: !onResult && done, - rethrowIfPossible: - rethrowIfPossible && (firstAsync < 0 || i < firstAsync) - }); - current = () => content; - } - code += current(); - return code; - } - - callTapsLooping({ onError, onDone, rethrowIfPossible }) { - if (this.options.taps.length === 0) return onDone(); - const syncOnly = this.options.taps.every(t => t.type === "sync"); - let code = ""; - if (!syncOnly) { - code += "var _looper = (function() {\n"; - code += "var _loopAsync = false;\n"; - } - code += "var _loop;\n"; - code += "do {\n"; - code += "_loop = false;\n"; - for (let i = 0; i < this.options.interceptors.length; i++) { - const interceptor = this.options.interceptors[i]; - if (interceptor.loop) { - code += `${this.getInterceptor(i)}.loop(${this.args({ - before: interceptor.context ? "_context" : undefined - })});\n`; - } - } - code += this.callTapsSeries({ - onError, - onResult: (i, result, next, doneBreak) => { - let code = ""; - code += `if(${result} !== undefined) {\n`; - code += "_loop = true;\n"; - if (!syncOnly) code += "if(_loopAsync) _looper();\n"; - code += doneBreak(true); - code += `} else {\n`; - code += next(); - code += `}\n`; - return code; - }, - onDone: - onDone && - (() => { - let code = ""; - code += "if(!_loop) {\n"; - code += onDone(); - code += "}\n"; - return code; - }), - rethrowIfPossible: rethrowIfPossible && syncOnly - }); - code += "} while(_loop);\n"; - if (!syncOnly) { - code += "_loopAsync = true;\n"; - code += "});\n"; - code += "_looper();\n"; - } - return code; - } - - callTapsParallel({ - onError, - onResult, - onDone, - rethrowIfPossible, - onTap = (i, run) => run() - }) { - if (this.options.taps.length <= 1) { - return this.callTapsSeries({ - onError, - onResult, - onDone, - rethrowIfPossible - }); - } - let code = ""; - code += "do {\n"; - code += `var _counter = ${this.options.taps.length};\n`; - if (onDone) { - code += "var _done = (function() {\n"; - code += onDone(); - code += "});\n"; - } - for (let i = 0; i < this.options.taps.length; i++) { - const done = () => { - if (onDone) return "if(--_counter === 0) _done();\n"; - else return "--_counter;"; - }; - const doneBreak = skipDone => { - if (skipDone || !onDone) return "_counter = 0;\n"; - else return "_counter = 0;\n_done();\n"; - }; - code += "if(_counter <= 0) break;\n"; - code += onTap( - i, - () => - this.callTap(i, { - onError: error => { - let code = ""; - code += "if(_counter > 0) {\n"; - code += onError(i, error, done, doneBreak); - code += "}\n"; - return code; - }, - onResult: - onResult && - (result => { - let code = ""; - code += "if(_counter > 0) {\n"; - code += onResult(i, result, done, doneBreak); - code += "}\n"; - return code; - }), - onDone: - !onResult && - (() => { - return done(); - }), - rethrowIfPossible - }), - done, - doneBreak - ); - } - code += "} while(false);\n"; - return code; - } - - args({ before, after } = {}) { - let allArgs = this._args; - if (before) allArgs = [before].concat(allArgs); - if (after) allArgs = allArgs.concat(after); - if (allArgs.length === 0) { - return ""; - } else { - return allArgs.join(", "); - } - } - - getTapFn(idx) { - return `_x[${idx}]`; - } - - getTap(idx) { - return `_taps[${idx}]`; - } - - getInterceptor(idx) { - return `_interceptors[${idx}]`; - } -} - -module.exports = HookCodeFactory; diff --git a/node_modules/tapable/lib/HookMap.js b/node_modules/tapable/lib/HookMap.js deleted file mode 100644 index 129ad6ab5b..0000000000 --- a/node_modules/tapable/lib/HookMap.js +++ /dev/null @@ -1,61 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ -"use strict"; - -const util = require("util"); - -const defaultFactory = (key, hook) => hook; - -class HookMap { - constructor(factory, name = undefined) { - this._map = new Map(); - this.name = name; - this._factory = factory; - this._interceptors = []; - } - - get(key) { - return this._map.get(key); - } - - for(key) { - const hook = this.get(key); - if (hook !== undefined) { - return hook; - } - let newHook = this._factory(key); - const interceptors = this._interceptors; - for (let i = 0; i < interceptors.length; i++) { - newHook = interceptors[i].factory(key, newHook); - } - this._map.set(key, newHook); - return newHook; - } - - intercept(interceptor) { - this._interceptors.push( - Object.assign( - { - factory: defaultFactory - }, - interceptor - ) - ); - } -} - -HookMap.prototype.tap = util.deprecate(function(key, options, fn) { - return this.for(key).tap(options, fn); -}, "HookMap#tap(key,…) is deprecated. Use HookMap#for(key).tap(…) instead."); - -HookMap.prototype.tapAsync = util.deprecate(function(key, options, fn) { - return this.for(key).tapAsync(options, fn); -}, "HookMap#tapAsync(key,…) is deprecated. Use HookMap#for(key).tapAsync(…) instead."); - -HookMap.prototype.tapPromise = util.deprecate(function(key, options, fn) { - return this.for(key).tapPromise(options, fn); -}, "HookMap#tapPromise(key,…) is deprecated. Use HookMap#for(key).tapPromise(…) instead."); - -module.exports = HookMap; diff --git a/node_modules/tapable/lib/MultiHook.js b/node_modules/tapable/lib/MultiHook.js deleted file mode 100644 index e4fc2cea1b..0000000000 --- a/node_modules/tapable/lib/MultiHook.js +++ /dev/null @@ -1,54 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ -"use strict"; - -const Hook = require("./Hook"); - -class MultiHook { - constructor(hooks, name = undefined) { - this.hooks = hooks; - this.name = name; - } - - tap(options, fn) { - for (const hook of this.hooks) { - hook.tap(options, fn); - } - } - - tapAsync(options, fn) { - for (const hook of this.hooks) { - hook.tapAsync(options, fn); - } - } - - tapPromise(options, fn) { - for (const hook of this.hooks) { - hook.tapPromise(options, fn); - } - } - - isUsed() { - for (const hook of this.hooks) { - if (hook.isUsed()) return true; - } - return false; - } - - intercept(interceptor) { - for (const hook of this.hooks) { - hook.intercept(interceptor); - } - } - - withOptions(options) { - return new MultiHook( - this.hooks.map(h => h.withOptions(options)), - this.name - ); - } -} - -module.exports = MultiHook; diff --git a/node_modules/tapable/lib/SyncBailHook.js b/node_modules/tapable/lib/SyncBailHook.js deleted file mode 100644 index bdd5b45301..0000000000 --- a/node_modules/tapable/lib/SyncBailHook.js +++ /dev/null @@ -1,51 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ -"use strict"; - -const Hook = require("./Hook"); -const HookCodeFactory = require("./HookCodeFactory"); - -class SyncBailHookCodeFactory extends HookCodeFactory { - content({ onError, onResult, resultReturns, onDone, rethrowIfPossible }) { - return this.callTapsSeries({ - onError: (i, err) => onError(err), - onResult: (i, result, next) => - `if(${result} !== undefined) {\n${onResult( - result - )};\n} else {\n${next()}}\n`, - resultReturns, - onDone, - rethrowIfPossible - }); - } -} - -const factory = new SyncBailHookCodeFactory(); - -const TAP_ASYNC = () => { - throw new Error("tapAsync is not supported on a SyncBailHook"); -}; - -const TAP_PROMISE = () => { - throw new Error("tapPromise is not supported on a SyncBailHook"); -}; - -const COMPILE = function(options) { - factory.setup(this, options); - return factory.create(options); -}; - -function SyncBailHook(args = [], name = undefined) { - const hook = new Hook(args, name); - hook.constructor = SyncBailHook; - hook.tapAsync = TAP_ASYNC; - hook.tapPromise = TAP_PROMISE; - hook.compile = COMPILE; - return hook; -} - -SyncBailHook.prototype = null; - -module.exports = SyncBailHook; diff --git a/node_modules/tapable/lib/SyncHook.js b/node_modules/tapable/lib/SyncHook.js deleted file mode 100644 index e2512be141..0000000000 --- a/node_modules/tapable/lib/SyncHook.js +++ /dev/null @@ -1,46 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ -"use strict"; - -const Hook = require("./Hook"); -const HookCodeFactory = require("./HookCodeFactory"); - -class SyncHookCodeFactory extends HookCodeFactory { - content({ onError, onDone, rethrowIfPossible }) { - return this.callTapsSeries({ - onError: (i, err) => onError(err), - onDone, - rethrowIfPossible - }); - } -} - -const factory = new SyncHookCodeFactory(); - -const TAP_ASYNC = () => { - throw new Error("tapAsync is not supported on a SyncHook"); -}; - -const TAP_PROMISE = () => { - throw new Error("tapPromise is not supported on a SyncHook"); -}; - -const COMPILE = function(options) { - factory.setup(this, options); - return factory.create(options); -}; - -function SyncHook(args = [], name = undefined) { - const hook = new Hook(args, name); - hook.constructor = SyncHook; - hook.tapAsync = TAP_ASYNC; - hook.tapPromise = TAP_PROMISE; - hook.compile = COMPILE; - return hook; -} - -SyncHook.prototype = null; - -module.exports = SyncHook; diff --git a/node_modules/tapable/lib/SyncLoopHook.js b/node_modules/tapable/lib/SyncLoopHook.js deleted file mode 100644 index be0e4fd4f2..0000000000 --- a/node_modules/tapable/lib/SyncLoopHook.js +++ /dev/null @@ -1,46 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ -"use strict"; - -const Hook = require("./Hook"); -const HookCodeFactory = require("./HookCodeFactory"); - -class SyncLoopHookCodeFactory extends HookCodeFactory { - content({ onError, onDone, rethrowIfPossible }) { - return this.callTapsLooping({ - onError: (i, err) => onError(err), - onDone, - rethrowIfPossible - }); - } -} - -const factory = new SyncLoopHookCodeFactory(); - -const TAP_ASYNC = () => { - throw new Error("tapAsync is not supported on a SyncLoopHook"); -}; - -const TAP_PROMISE = () => { - throw new Error("tapPromise is not supported on a SyncLoopHook"); -}; - -const COMPILE = function(options) { - factory.setup(this, options); - return factory.create(options); -}; - -function SyncLoopHook(args = [], name = undefined) { - const hook = new Hook(args, name); - hook.constructor = SyncLoopHook; - hook.tapAsync = TAP_ASYNC; - hook.tapPromise = TAP_PROMISE; - hook.compile = COMPILE; - return hook; -} - -SyncLoopHook.prototype = null; - -module.exports = SyncLoopHook; diff --git a/node_modules/tapable/lib/SyncWaterfallHook.js b/node_modules/tapable/lib/SyncWaterfallHook.js deleted file mode 100644 index c878b7fef6..0000000000 --- a/node_modules/tapable/lib/SyncWaterfallHook.js +++ /dev/null @@ -1,57 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ -"use strict"; - -const Hook = require("./Hook"); -const HookCodeFactory = require("./HookCodeFactory"); - -class SyncWaterfallHookCodeFactory extends HookCodeFactory { - content({ onError, onResult, resultReturns, rethrowIfPossible }) { - return this.callTapsSeries({ - onError: (i, err) => onError(err), - onResult: (i, result, next) => { - let code = ""; - code += `if(${result} !== undefined) {\n`; - code += `${this._args[0]} = ${result};\n`; - code += `}\n`; - code += next(); - return code; - }, - onDone: () => onResult(this._args[0]), - doneReturns: resultReturns, - rethrowIfPossible - }); - } -} - -const factory = new SyncWaterfallHookCodeFactory(); - -const TAP_ASYNC = () => { - throw new Error("tapAsync is not supported on a SyncWaterfallHook"); -}; - -const TAP_PROMISE = () => { - throw new Error("tapPromise is not supported on a SyncWaterfallHook"); -}; - -const COMPILE = function(options) { - factory.setup(this, options); - return factory.create(options); -}; - -function SyncWaterfallHook(args = [], name = undefined) { - if (args.length < 1) - throw new Error("Waterfall hooks must have at least one argument"); - const hook = new Hook(args, name); - hook.constructor = SyncWaterfallHook; - hook.tapAsync = TAP_ASYNC; - hook.tapPromise = TAP_PROMISE; - hook.compile = COMPILE; - return hook; -} - -SyncWaterfallHook.prototype = null; - -module.exports = SyncWaterfallHook; diff --git a/node_modules/tapable/lib/index.js b/node_modules/tapable/lib/index.js deleted file mode 100644 index 0a94a5365d..0000000000 --- a/node_modules/tapable/lib/index.js +++ /dev/null @@ -1,19 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ -"use strict"; - -exports.__esModule = true; -exports.SyncHook = require("./SyncHook"); -exports.SyncBailHook = require("./SyncBailHook"); -exports.SyncWaterfallHook = require("./SyncWaterfallHook"); -exports.SyncLoopHook = require("./SyncLoopHook"); -exports.AsyncParallelHook = require("./AsyncParallelHook"); -exports.AsyncParallelBailHook = require("./AsyncParallelBailHook"); -exports.AsyncSeriesHook = require("./AsyncSeriesHook"); -exports.AsyncSeriesBailHook = require("./AsyncSeriesBailHook"); -exports.AsyncSeriesLoopHook = require("./AsyncSeriesLoopHook"); -exports.AsyncSeriesWaterfallHook = require("./AsyncSeriesWaterfallHook"); -exports.HookMap = require("./HookMap"); -exports.MultiHook = require("./MultiHook"); diff --git a/node_modules/tapable/lib/util-browser.js b/node_modules/tapable/lib/util-browser.js deleted file mode 100644 index ee4fb9a05d..0000000000 --- a/node_modules/tapable/lib/util-browser.js +++ /dev/null @@ -1,16 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ -"use strict"; - -exports.deprecate = (fn, msg) => { - let once = true; - return function() { - if (once) { - console.warn("DeprecationWarning: " + msg); - once = false; - } - return fn.apply(this, arguments); - }; -}; diff --git a/node_modules/tapable/package.json b/node_modules/tapable/package.json deleted file mode 100644 index 3c13120b72..0000000000 --- a/node_modules/tapable/package.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "name": "tapable", - "version": "2.2.1", - "author": "Tobias Koppers @sokra", - "description": "Just a little module for plugins.", - "license": "MIT", - "homepage": "https://github.com/webpack/tapable", - "repository": { - "type": "git", - "url": "http://github.com/webpack/tapable.git" - }, - "devDependencies": { - "@babel/core": "^7.4.4", - "@babel/preset-env": "^7.4.4", - "babel-jest": "^24.8.0", - "codecov": "^3.5.0", - "jest": "^24.8.0", - "prettier": "^1.17.1" - }, - "engines": { - "node": ">=6" - }, - "files": [ - "lib", - "!lib/__tests__", - "tapable.d.ts" - ], - "main": "lib/index.js", - "types": "./tapable.d.ts", - "browser": { - "util": "./lib/util-browser.js" - }, - "scripts": { - "test": "jest", - "travis": "yarn pretty-lint && jest --coverage && codecov", - "pretty-lint": "prettier --check lib/*.js lib/__tests__/*.js", - "pretty": "prettier --loglevel warn --write lib/*.js lib/__tests__/*.js" - }, - "jest": { - "transform": { - "__tests__[\\\\/].+\\.js$": "babel-jest" - } - } -} diff --git a/node_modules/tapable/tapable.d.ts b/node_modules/tapable/tapable.d.ts deleted file mode 100644 index 0201c9a820..0000000000 --- a/node_modules/tapable/tapable.d.ts +++ /dev/null @@ -1,116 +0,0 @@ -type FixedSizeArray = T extends 0 - ? void[] - : ReadonlyArray & { - 0: U; - length: T; - }; -type Measure = T extends 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 - ? T - : never; -type Append = { - 0: [U]; - 1: [T[0], U]; - 2: [T[0], T[1], U]; - 3: [T[0], T[1], T[2], U]; - 4: [T[0], T[1], T[2], T[3], U]; - 5: [T[0], T[1], T[2], T[3], T[4], U]; - 6: [T[0], T[1], T[2], T[3], T[4], T[5], U]; - 7: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], U]; - 8: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], T[7], U]; -}[Measure]; -type AsArray = T extends any[] ? T : [T]; - -declare class UnsetAdditionalOptions { - _UnsetAdditionalOptions: true -} -type IfSet = X extends UnsetAdditionalOptions ? {} : X; - -type Callback = (error: E | null, result?: T) => void; -type InnerCallback = (error?: E | null | false, result?: T) => void; - -type FullTap = Tap & { - type: "sync" | "async" | "promise", - fn: Function -} - -type Tap = TapOptions & { - name: string; -}; - -type TapOptions = { - before?: string; - stage?: number; -}; - -interface HookInterceptor { - name?: string; - tap?: (tap: FullTap & IfSet) => void; - call?: (...args: any[]) => void; - loop?: (...args: any[]) => void; - error?: (err: Error) => void; - result?: (result: R) => void; - done?: () => void; - register?: (tap: FullTap & IfSet) => FullTap & IfSet; -} - -type ArgumentNames = FixedSizeArray; - -declare class Hook { - constructor(args?: ArgumentNames>, name?: string); - name: string | undefined; - taps: FullTap[]; - intercept(interceptor: HookInterceptor): void; - isUsed(): boolean; - callAsync(...args: Append, Callback>): void; - promise(...args: AsArray): Promise; - tap(options: string | Tap & IfSet, fn: (...args: AsArray) => R): void; - withOptions(options: TapOptions & IfSet): Omit; -} - -export class SyncHook extends Hook { - call(...args: AsArray): R; -} - -export class SyncBailHook extends SyncHook {} -export class SyncLoopHook extends SyncHook {} -export class SyncWaterfallHook extends SyncHook[0], AdditionalOptions> {} - -declare class AsyncHook extends Hook { - tapAsync( - options: string | Tap & IfSet, - fn: (...args: Append, InnerCallback>) => void - ): void; - tapPromise( - options: string | Tap & IfSet, - fn: (...args: AsArray) => Promise - ): void; -} - -export class AsyncParallelHook extends AsyncHook {} -export class AsyncParallelBailHook extends AsyncHook {} -export class AsyncSeriesHook extends AsyncHook {} -export class AsyncSeriesBailHook extends AsyncHook {} -export class AsyncSeriesLoopHook extends AsyncHook {} -export class AsyncSeriesWaterfallHook extends AsyncHook[0], AdditionalOptions> {} - -type HookFactory = (key: any, hook?: H) => H; - -interface HookMapInterceptor { - factory?: HookFactory; -} - -export class HookMap { - constructor(factory: HookFactory, name?: string); - name: string | undefined; - get(key: any): H | undefined; - for(key: any): H; - intercept(interceptor: HookMapInterceptor): void; -} - -export class MultiHook { - constructor(hooks: H[], name?: string); - name: string | undefined; - tap(options: string | Tap, fn?: Function): void; - tapAsync(options: string | Tap, fn?: Function): void; - tapPromise(options: string | Tap, fn?: Function): void; -} diff --git a/package-lock.json b/package-lock.json index ce9f90131f..71adc441d3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -61,7 +61,7 @@ "@typescript-eslint/parser": "^8.26.1", "ava": "^5.3.1", "eslint": "^8.57.1", - "eslint-import-resolver-typescript": "^3.8.3", + "eslint-import-resolver-typescript": "^4.1.1", "eslint-plugin-filenames": "^1.3.2", "eslint-plugin-github": "^5.1.8", "eslint-plugin-import": "2.29.1", @@ -770,6 +770,58 @@ "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==", "license": "0BSD" }, + "node_modules/@emnapi/core": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.3.1.tgz", + "integrity": "sha512-pVGjBIt1Y6gg3EJN8jTcfpP/+uuRksIo055oE/OBkDNcjZqVbfkWCksG1Jp4yZnj3iKWyWX8fdG/j6UDYPbFog==", + "dev": true, + "optional": true, + "dependencies": { + "@emnapi/wasi-threads": "1.0.1", + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/core/node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "dev": true, + "optional": true + }, + "node_modules/@emnapi/runtime": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.3.1.tgz", + "integrity": "sha512-kEBmG8KyqtxJZv+ygbEim+KCGtIq1fC22Ms3S4ziXmYKm8uyoLX0MHONVKwp+9opg390VaKRNt4a7A9NwmpNhw==", + "dev": true, + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/runtime/node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "dev": true, + "optional": true + }, + "node_modules/@emnapi/wasi-threads": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.0.1.tgz", + "integrity": "sha512-iIBu7mwkq4UQGeMEM8bLwNK962nXdhodeScX4slfQnRhEMMzvYivHhutCIk8uojvmASXXPC2WNEjwxFWk72Oqw==", + "dev": true, + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/wasi-threads/node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "dev": true, + "optional": true + }, "node_modules/@eslint-community/eslint-utils": { "version": "4.4.0", "dev": true, @@ -1039,6 +1091,18 @@ "node": ">=18" } }, + "node_modules/@napi-rs/wasm-runtime": { + "version": "0.2.7", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-0.2.7.tgz", + "integrity": "sha512-5yximcFK5FNompXfJFoWanu5l8v1hNGqNHh9du1xETp9HWk/B/PzvchX55WYOPaIeNglG8++68AAiauBAtbnzw==", + "dev": true, + "optional": true, + "dependencies": { + "@emnapi/core": "^1.3.1", + "@emnapi/runtime": "^1.3.1", + "@tybys/wasm-util": "^0.9.0" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "license": "MIT", @@ -1068,15 +1132,6 @@ "node": ">= 8" } }, - "node_modules/@nolyfill/is-core-module": { - "version": "1.0.39", - "resolved": "https://registry.npmjs.org/@nolyfill/is-core-module/-/is-core-module-1.0.39.tgz", - "integrity": "sha512-nn5ozdjYQpUCZlWGuxcJY/KpxkWQs4DcbMCmKojjyrYDEAGy4Ce19NN4v5MduafTwJlbKc99UA8YhSVqq9yPZA==", - "dev": true, - "engines": { - "node": ">=12.4.0" - } - }, "node_modules/@octokit/app": { "version": "15.1.4", "resolved": "https://registry.npmjs.org/@octokit/app/-/app-15.1.4.tgz", @@ -1828,6 +1883,23 @@ "integrity": "sha512-DE427ROAphMQzU4ENbliGYrBSYPXF+TtLg9S8vzeA+OF4ZKzoDdzfL8sxuMUGS/lgRhM6j1URSk9ghf7Xo1tyA==", "dev": true }, + "node_modules/@tybys/wasm-util": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.9.0.tgz", + "integrity": "sha512-6+7nlbMVX/PVDCwaIQ8nTOPveOcFLSt8GcXdx8hD0bt39uWxYT88uXzqTd4fTvqta7oeUJqudepapKNt2DYJFw==", + "dev": true, + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@tybys/wasm-util/node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "dev": true, + "optional": true + }, "node_modules/@types/adm-zip": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/@types/adm-zip/-/adm-zip-0.5.7.tgz", @@ -2554,6 +2626,152 @@ "dev": true, "license": "ISC" }, + "node_modules/@unrs/rspack-resolver-binding-darwin-arm64": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@unrs/rspack-resolver-binding-darwin-arm64/-/rspack-resolver-binding-darwin-arm64-1.1.2.tgz", + "integrity": "sha512-bQx2L40UF5XxsXwkD26PzuspqUbUswWVbmclmUC+c83Cv/EFrFJ1JaZj5Q5jyYglKGOtyIWY/hXTCdWRN9vT0Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@unrs/rspack-resolver-binding-darwin-x64": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@unrs/rspack-resolver-binding-darwin-x64/-/rspack-resolver-binding-darwin-x64-1.1.2.tgz", + "integrity": "sha512-dMi9a7//BsuPTnhWEDxmdKZ6wxQlPnAob8VSjefGbKX/a+pHfTaX1pm/jv2VPdarP96IIjCKPatJS/TtLQeGQA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@unrs/rspack-resolver-binding-freebsd-x64": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@unrs/rspack-resolver-binding-freebsd-x64/-/rspack-resolver-binding-freebsd-x64-1.1.2.tgz", + "integrity": "sha512-RiBZQ+LSORQObfhV1yH7jGz+4sN3SDYtV53jgc8tUVvqdqVDaUm1KA3zHLffmoiYNGrYkE3sSreGC+FVpsB4Vg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@unrs/rspack-resolver-binding-linux-arm-gnueabihf": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@unrs/rspack-resolver-binding-linux-arm-gnueabihf/-/rspack-resolver-binding-linux-arm-gnueabihf-1.1.2.tgz", + "integrity": "sha512-IyKIFBtOvuPCJt1WPx9e9ovTGhZzrIbW11vWzw4aPmx3VShE+YcMpAldqQubdCep0UVKZyFt+2hQDQZwFiJ4jg==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@unrs/rspack-resolver-binding-linux-arm64-gnu": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@unrs/rspack-resolver-binding-linux-arm64-gnu/-/rspack-resolver-binding-linux-arm64-gnu-1.1.2.tgz", + "integrity": "sha512-RfYtlCtJrv5i6TO4dSlpbyOJX9Zbhmkqrr9hjDfr6YyE5KD0ywLRzw8UjXsohxG1XWgRpb2tvPuRYtURJwbqWg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@unrs/rspack-resolver-binding-linux-arm64-musl": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@unrs/rspack-resolver-binding-linux-arm64-musl/-/rspack-resolver-binding-linux-arm64-musl-1.1.2.tgz", + "integrity": "sha512-MaITzkoqsn1Rm3+YnplubgAQEfOt+2jHfFvuFhXseUfcfbxe8Zyc3TM7LKwgv7mRVjIl+/yYN5JqL0cjbnhAnQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@unrs/rspack-resolver-binding-linux-x64-gnu": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@unrs/rspack-resolver-binding-linux-x64-gnu/-/rspack-resolver-binding-linux-x64-gnu-1.1.2.tgz", + "integrity": "sha512-Nu981XmzQqis/uB3j4Gi3p5BYCd/zReU5zbJmjMrEH7IIRH0dxZpdOmS/+KwEk6ao7Xd8P2D2gDHpHD/QTp0aQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@unrs/rspack-resolver-binding-linux-x64-musl": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@unrs/rspack-resolver-binding-linux-x64-musl/-/rspack-resolver-binding-linux-x64-musl-1.1.2.tgz", + "integrity": "sha512-xJupeDvaRpV0ADMuG1dY9jkOjhUzTqtykvchiU2NldSD+nafSUcMWnoqzNUx7HGiqbTMOw9d9xT8ZiFs+6ZFyQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@unrs/rspack-resolver-binding-wasm32-wasi": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@unrs/rspack-resolver-binding-wasm32-wasi/-/rspack-resolver-binding-wasm32-wasi-1.1.2.tgz", + "integrity": "sha512-un6X/xInks+KEgGpIHFV8BdoODHRohaDRvOwtjq+FXuoI4Ga0P6sLRvf4rPSZDvoMnqUhZtVNG0jG9oxOnrrLQ==", + "cpu": [ + "wasm32" + ], + "dev": true, + "optional": true, + "dependencies": { + "@napi-rs/wasm-runtime": "^0.2.7" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@unrs/rspack-resolver-binding-win32-arm64-msvc": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@unrs/rspack-resolver-binding-win32-arm64-msvc/-/rspack-resolver-binding-win32-arm64-msvc-1.1.2.tgz", + "integrity": "sha512-2lCFkeT1HYUb/OOStBS1m67aZOf9BQxRA+Wf/xs94CGgzmoQt7H4V/BrkB/GSGKsudXjkiwt2oHNkHiowAS90A==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@unrs/rspack-resolver-binding-win32-x64-msvc": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@unrs/rspack-resolver-binding-win32-x64-msvc/-/rspack-resolver-binding-win32-x64-msvc-1.1.2.tgz", + "integrity": "sha512-EYfya5HCQ/8Yfy7rvAAX2rGytu81+d/CIhNCbZfNKLQ690/qFsdEeTXRsMQW1afHoluMM50PsjPYu8ndy8fSQg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ] + }, "node_modules/abort-controller": { "version": "3.0.0", "license": "MIT", @@ -3696,10 +3914,9 @@ } }, "node_modules/debug": { - "version": "4.3.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", - "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==", - "license": "MIT", + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", + "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", "dependencies": { "ms": "^2.1.3" }, @@ -3876,19 +4093,6 @@ "version": "8.0.0", "license": "MIT" }, - "node_modules/enhanced-resolve": { - "version": "5.17.1", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.17.1.tgz", - "integrity": "sha512-LMHl3dXhTcfv8gM4kEzIUeTQ+7fpdA0l2tUf34BddXPkz2A5xJ5L/Pchd5BL6rdccM9QGvu0sWZzK1Z1t4wwyg==", - "dev": true, - "dependencies": { - "graceful-fs": "^4.2.4", - "tapable": "^2.2.0" - }, - "engines": { - "node": ">=10.13.0" - } - }, "node_modules/es-abstract": { "version": "1.23.3", "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.23.3.tgz", @@ -4124,22 +4328,20 @@ } }, "node_modules/eslint-import-resolver-typescript": { - "version": "3.8.3", - "resolved": "https://registry.npmjs.org/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-3.8.3.tgz", - "integrity": "sha512-A0bu4Ks2QqDWNpeEgTQMPTngaMhuDu4yv6xpftBMAf+1ziXnpx+eSR1WRfoPTe2BAiAjHFZ7kSNx1fvr5g5pmQ==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-4.1.1.tgz", + "integrity": "sha512-91As8PwH6xjPwndAbvhTuZ3DUfdl4HttocWRyaLOd5T4uUo6km8EDO7Sve4jzH50V1wbgql2nOFbE3GGfARJag==", "dev": true, - "license": "ISC", "dependencies": { - "@nolyfill/is-core-module": "1.0.39", - "debug": "^4.3.7", - "enhanced-resolve": "^5.15.0", + "debug": "^4.4.0", "get-tsconfig": "^4.10.0", - "is-bun-module": "^1.0.2", - "stable-hash": "^0.0.4", + "is-bun-module": "^1.3.0", + "rspack-resolver": "^1.1.2", + "stable-hash": "^0.0.5", "tinyglobby": "^0.2.12" }, "engines": { - "node": "^14.18.0 || >=16.0.0" + "node": "^16.17.0 || >=18.6.0" }, "funding": { "url": "https://opencollective.com/unts/projects/eslint-import-resolver-ts" @@ -5566,9 +5768,9 @@ } }, "node_modules/is-bun-module": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-bun-module/-/is-bun-module-1.1.0.tgz", - "integrity": "sha512-4mTAVPlrXpaN3jtF0lsnPCMGnq4+qZjVIKq0HCpfcqf8OC1SM5oATCIAPM5V5FN05qp2NNnFndphmdZS9CV3hA==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/is-bun-module/-/is-bun-module-1.3.0.tgz", + "integrity": "sha512-DgXeu5UWI0IsMQundYb5UAOzm6G2eVnarJ0byP6Tm55iZNKceD59LNPA2L4VvsScTtHcw0yEkVwSf7PC+QoLSA==", "dev": true, "dependencies": { "semver": "^7.6.3" @@ -7148,6 +7350,28 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/rspack-resolver": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/rspack-resolver/-/rspack-resolver-1.1.2.tgz", + "integrity": "sha512-eHhz+9JWHFdbl/CVVqEP6kviLFZqw1s0MWxLdsGMtUKUspSO3SERptPohmrUIC9jT1bGV9Bd3+r8AmWbdfNAzQ==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/JounQin" + }, + "optionalDependencies": { + "@unrs/rspack-resolver-binding-darwin-arm64": "1.1.2", + "@unrs/rspack-resolver-binding-darwin-x64": "1.1.2", + "@unrs/rspack-resolver-binding-freebsd-x64": "1.1.2", + "@unrs/rspack-resolver-binding-linux-arm-gnueabihf": "1.1.2", + "@unrs/rspack-resolver-binding-linux-arm64-gnu": "1.1.2", + "@unrs/rspack-resolver-binding-linux-arm64-musl": "1.1.2", + "@unrs/rspack-resolver-binding-linux-x64-gnu": "1.1.2", + "@unrs/rspack-resolver-binding-linux-x64-musl": "1.1.2", + "@unrs/rspack-resolver-binding-wasm32-wasi": "1.1.2", + "@unrs/rspack-resolver-binding-win32-arm64-msvc": "1.1.2", + "@unrs/rspack-resolver-binding-win32-x64-msvc": "1.1.2" + } + }, "node_modules/run-parallel": { "version": "1.2.0", "funding": [ @@ -7408,11 +7632,10 @@ "license": "BSD-3-Clause" }, "node_modules/stable-hash": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/stable-hash/-/stable-hash-0.0.4.tgz", - "integrity": "sha512-LjdcbuBeLcdETCrPn9i8AYAZ1eCtu4ECAWtP7UleOiZ9LzVxRzzUZEoZ8zB24nhkQnDWyET0I+3sWokSDS3E7g==", - "dev": true, - "license": "MIT" + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/stable-hash/-/stable-hash-0.0.5.tgz", + "integrity": "sha512-+L3ccpzibovGXFK+Ap/f8LOS0ahMrHTf3xu7mMLSpEGU0EO9ucaysSylKo9eRDFNhWve/y275iPmIZ4z39a9iA==", + "dev": true }, "node_modules/stack-utils": { "version": "2.0.6", @@ -7716,15 +7939,6 @@ "dev": true, "license": "0BSD" }, - "node_modules/tapable": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", - "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==", - "dev": true, - "engines": { - "node": ">=6" - } - }, "node_modules/tar-stream": { "version": "3.1.7", "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-3.1.7.tgz", diff --git a/package.json b/package.json index 10d8e01771..8520f2fd31 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "@typescript-eslint/parser": "^8.26.1", "ava": "^5.3.1", "eslint": "^8.57.1", - "eslint-import-resolver-typescript": "^3.8.3", + "eslint-import-resolver-typescript": "^4.1.1", "eslint-plugin-filenames": "^1.3.2", "eslint-plugin-github": "^5.1.8", "eslint-plugin-import": "2.29.1",