summaryrefslogtreecommitdiff
path: root/node_modules/@babel/helper-define-polyfill-provider/lib/normalize-options.js
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2026-05-18 23:10:59 +0800
committerlittleblack111 <littleblack11111@gmail.com>2026-05-18 23:41:44 +0800
commitfc87c009806dcc98867f6b58efe29b042aa01dee (patch)
tree8f59b3f4a5b66e9dfef2d40c8d318e258a521228 /node_modules/@babel/helper-define-polyfill-provider/lib/normalize-options.js
parent3336b2356ee6152d9c6ae59bd9b87ccbc0958407 (diff)
node: updatemain
Diffstat (limited to 'node_modules/@babel/helper-define-polyfill-provider/lib/normalize-options.js')
-rw-r--r--node_modules/@babel/helper-define-polyfill-provider/lib/normalize-options.js70
1 files changed, 0 insertions, 70 deletions
diff --git a/node_modules/@babel/helper-define-polyfill-provider/lib/normalize-options.js b/node_modules/@babel/helper-define-polyfill-provider/lib/normalize-options.js
deleted file mode 100644
index 16b196a9..00000000
--- a/node_modules/@babel/helper-define-polyfill-provider/lib/normalize-options.js
+++ /dev/null
@@ -1,70 +0,0 @@
-"use strict";
-
-exports.__esModule = true;
-exports.applyMissingDependenciesDefaults = applyMissingDependenciesDefaults;
-exports.validateIncludeExclude = validateIncludeExclude;
-var _utils = require("./utils");
-function patternToRegExp(pattern) {
- if (pattern instanceof RegExp) return pattern;
- try {
- return new RegExp(`^${pattern}$`);
- } catch (_unused) {
- return null;
- }
-}
-function buildUnusedError(label, unused) {
- if (!unused.length) return "";
- return ` - The following "${label}" patterns didn't match any polyfill:\n` + unused.map(original => ` ${String(original)}\n`).join("");
-}
-function buldDuplicatesError(duplicates) {
- if (!duplicates.size) return "";
- return ` - The following polyfills were matched both by "include" and "exclude" patterns:\n` + Array.from(duplicates, name => ` ${name}\n`).join("");
-}
-function validateIncludeExclude(provider, polyfills, includePatterns, excludePatterns) {
- let current;
- const filter = pattern => {
- const regexp = patternToRegExp(pattern);
- if (!regexp) return false;
- let matched = false;
- for (const polyfill of polyfills.keys()) {
- if (regexp.test(polyfill)) {
- matched = true;
- current.add(polyfill);
- }
- }
- return !matched;
- };
-
- // prettier-ignore
- const include = current = new Set();
- const unusedInclude = Array.from(includePatterns).filter(filter);
-
- // prettier-ignore
- const exclude = current = new Set();
- const unusedExclude = Array.from(excludePatterns).filter(filter);
- const duplicates = (0, _utils.intersection)(include, exclude);
- if (duplicates.size > 0 || unusedInclude.length > 0 || unusedExclude.length > 0) {
- throw new Error(`Error while validating the "${provider}" provider options:\n` + buildUnusedError("include", unusedInclude) + buildUnusedError("exclude", unusedExclude) + buldDuplicatesError(duplicates));
- }
- return {
- include,
- exclude
- };
-}
-function applyMissingDependenciesDefaults(options, babelApi) {
- const {
- missingDependencies = {}
- } = options;
- if (missingDependencies === false) return false;
- const caller = babelApi.caller(caller => caller == null ? void 0 : caller.name);
- const {
- log = "deferred",
- inject = caller === "rollup-plugin-babel" ? "throw" : "import",
- all = false
- } = missingDependencies;
- return {
- log,
- inject,
- all
- };
-} \ No newline at end of file