node-ejs-renderer/node_modules/@babel/preset-env/lib/normalize-options.js.map

1 line
18 KiB
Plaintext
Raw Normal View History

2024-06-09 13:55:01 -04:00
{"version":3,"names":["_semver","require","_pluginsCompatData","_moduleTransformations","_options","_helperValidatorOption","_babel7Plugins","corejs3Polyfills","JSON","parse","readFileSync","resolve","v","OptionValidator","allPluginsList","Object","keys","pluginsList","modulePlugins","moduleTransformations","map","m","getValidIncludesAndExcludes","type","corejs","set","Set","add","babel7","corejs2Polyfills","Array","from","flatMap","array","fn","prototype","concat","apply","normalizePluginName","plugin","replace","exports","expandIncludesAndExcludes","filterList","length","filterableItems","invalidFilters","selectedPlugins","filter","re","RegExp","e","push","items","item","test","invariant","join","checkDuplicateIncludeExcludes","include","exclude","duplicates","opt","indexOf","normalizeTargets","targets","isArray","browsers","assign","validateModulesOption","modulesOpt","ModulesOption","auto","toString","false","validateUseBuiltInsOption","builtInsOpt","UseBuiltInsOption","normalizeCoreJSOption","useBuiltIns","proposals","rawVersion","undefined","console","warn","version","Boolean","semver","coerce","String","major","RangeError","normalizeOptions","opts","validateTopLevelOptions","TopLevelOptions","validateBooleanOption","loose","spec","bugfixes","configPath","validateStringOption","process","cwd","debug","forceAllTransforms","ignoreBrowserslistConfig","modules","shippedProposals","browserslistEnv"],"sources":["../src/normalize-options.ts"],"sourcesContent":["import semver, { type SemVer } from \"semver\";\nimport corejs3Polyfills from \"core-js-compat/data.json\" with { type: \"json\" };\nimport { plugins as pluginsList } from \"./plugins-compat-data.ts\";\nimport moduleTransformations from \"./module-transformations.ts\";\nimport {\n TopLevelOptions,\n ModulesOption,\n UseBuiltInsOption,\n} from \"./options.ts\";\nimport { OptionValidator } from \"@babel/helper-validator-option\";\n\n// TODO(Babel 8): Remove this\nimport babel7 from \"./polyfills/babel-7-plugins.cjs\";\n\nimport type {\n BuiltInsOption,\n CorejsOption,\n ModuleOption,\n Options,\n PluginListOption,\n} from \"./types.ts\";\n\nconst v = new OptionValidator(PACKAGE_JSON.name);\n\nconst allPluginsList = Object.keys(pluginsList);\n\n// NOTE: Since module plugins are handled separately compared to other plugins (via the \"modules\" option) it\n// should only be possible to exclude and not include module plugins, otherwise it's possible that preset-env\n// will add a module plugin twice.\nconst modulePlugins = [\n \"transform-dynamic-import\",\n ...Object.keys(moduleTransformations).map(m => moduleTransformations[m]),\n];\n\nconst getValidIncludesAndExcludes = (\n type: \"include\" | \"exclude\",\n corejs: number | false,\n) => {\n const set = new Set(allPluginsList);\n if (type === \"exclude\") modulePlugins.map(set.add, set);\n if (corejs) {\n if (!process.env.BABEL_8_BREAKING && corejs === 2) {\n Object.keys(babel7.corejs2Polyfills).map(set.add, set);\n set.add(\"web.timers\").add(\"web.immediate\").add(\"web.dom.iterable\");\n } else {\n Object.keys(corejs3Polyfills).map(set.add, set);\n }\n }\n return Array.from(set);\n};\n\nfunction flatMap<T, U>(array: Array<T>, fn: (item: T) => Array<U>): Array<U> {\n return Array.prototype.concat.apply([], array.map(fn));\n}\n\nexport const normalizePluginName = (plugin: string) =>\n plugin.replace(/^(@babel\\/|babel-)(plugin-)?/, \"\");\n\nconst expandIncludesAndExcludes = (\n filterList: PluginListOption = [],\n type: \"include\" | \"exclude\",\n corejs: number | false,\n) => {\n if (filterList.length === 0) return [];\n\n const filterableItems = getValidIncludesAndExcludes(type, corejs);\n\n const invalidFilters: PluginListOption = [];\n const selectedPlugins = flatMap(filterList, filter => {\n let re: RegExp;\n if (typeof filter === \"string\") {\n try {\n re = new RegExp(`^${normalizePluginName(filter)}$`);\n } catch (e) {\n invalidFilters.push(filter);\n return [];\n }\n } else {\n re = filter;\n }\n cons