hexo/node_modules/@babel/preset-env/lib/normalize-options.js.map

1 line
16 KiB
Plaintext
Raw Normal View History

2023-09-25 15:58:56 +08:00
{"version":3,"names":["_semver","require","_corejs2BuiltIns","_coreJsCompat","_pluginsCompatData","_moduleTransformations","_options","_helperValidatorOption","corejs2DefaultWebIncludes","v","OptionValidator","allPluginsList","Object","keys","pluginsList","modulePlugins","moduleTransformations","map","m","getValidIncludesAndExcludes","type","corejs","Array","from","Set","corejs2Polyfills","corejs3Polyfills","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","bugfixes","validateBooleanOption","configPath","validateStringOption","process","cwd","debug","forceAllTransforms","ignoreBrowserslistConfig","loose","modules","shippedProposals","spec","browserslistEnv"],"sources":["../src/normalize-options.ts"],"sourcesContent":["import semver, { type SemVer } from \"semver\";\nimport corejs2Polyfills from \"@babel/compat-data/corejs2-built-ins\";\n// @ts-expect-error Fixme: TS can not infer types from ../data/core-js-compat.js\n// but we can't import core-js-compat/data.json because JSON imports do\n// not work on Node 14\nimport corejs3Polyfills from \"../data/core-js-compat\";\nimport { plugins as pluginsList } from \"./plugins-compat-data\";\nimport moduleTransformations from \"./module-transformations\";\nimport { TopLevelOptions, ModulesOption, UseBuiltInsOption } from \"./options\";\nimport { OptionValidator } from \"@babel/helper-validator-option\";\n\nconst corejs2DefaultWebIncludes = [\n \"web.timers\",\n \"web.immediate\",\n \"web.dom.iterable\",\n];\n\nimport type {\n BuiltInsOption,\n CorejsOption,\n ModuleOption,\n Options,\n PluginListOption,\n} from \"./types\";\n\ndeclare const PACKAGE_JSON: { name: string; version: string };\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 Array.from(\n new Set([\n ...allPluginsList,\n ...(type === \"exclude\" ? modulePlugins : []),\n ...(corejs\n ? corejs == 2\n ? [...Object.keys(corejs2Polyfills), ...corejs2DefaultWebIncludes]\n : Object.keys(corejs3Polyfills)\n : []),\n ]),\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)}$`)