@babel/helper-plugin-utils
Advanced tools
+1
-1
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import type {\n PluginAPI,\n PluginObject,\n PluginPass,\n PresetAPI,\n PresetObject,\n} from \"@babel/core\";\n\ntype APIPolyfillFactory<T extends keyof PluginAPI> = (\n api: PluginAPI,\n) => PluginAPI[T];\n\ntype APIPolyfills = {\n assertVersion: APIPolyfillFactory<\"assertVersion\">;\n};\n\nconst apiPolyfills: APIPolyfills = {\n // Not supported by Babel 7 and early versions of Babel 7 beta.\n // It's important that this is polyfilled for older Babel versions\n // since it's needed to report the version mismatch.\n assertVersion: (api: PluginAPI) => (range: number | string) => {\n throwVersionError(range, api.version);\n },\n};\n\nexport function declare<State = object, Option = object>(\n builder: (\n api: PluginAPI,\n options: Option,\n dirname: string,\n ) => PluginObject<State & PluginPass>,\n): (\n api: PluginAPI,\n options: Option,\n dirname: string,\n) => PluginObject<State & PluginPass> {\n return (api, options: Option, dirname: string) => {\n let clonedApi: PluginAPI;\n\n for (const name of Object.keys(\n apiPolyfills,\n ) as (keyof typeof apiPolyfills)[]) {\n if (api[name]) continue;\n\n clonedApi ??= copyApiObject(api);\n clonedApi[name] = apiPolyfills[name](clonedApi);\n }\n\n // @ts-expect-error options || {} may not be assigned to Options\n return builder(clonedApi ?? api, options || {}, dirname);\n };\n}\n\nexport const declarePreset = declare as <Option = object>(\n builder: (api: PresetAPI, options: Option, dirname: string) => PresetObject,\n) => (api: PresetAPI, options: Option, dirname: string) => PresetObject;\n\nfunction copyApiObject(api: PluginAPI): PluginAPI {\n // Babel >= 7 <= beta.41 passed the API as a new object that had\n // babel/core as the prototype. While slightly faster, it also\n // means that the Object.assign copy below fails. Rather than\n // keep complexity, the Babel 6 behavior has been reverted and this\n // normalizes all that for Babel 7.\n let proto = null;\n if (typeof api.version === \"string\" && api.version.startsWith(\"7.\")) {\n proto = Object.getPrototypeOf(api);\n if (\n proto &&\n (!Object.hasOwn(proto, \"version\") ||\n !Object.hasOwn(proto, \"transform\") ||\n !Object.hasOwn(proto, \"template\") ||\n !Object.hasOwn(proto, \"types\"))\n ) {\n proto = null;\n }\n }\n\n return {\n ...proto,\n ...api,\n };\n}\n\nfunction throwVersionError(range: string | number, version: string) {\n if (typeof range === \"number\") {\n if (!Number.isInteger(range)) {\n throw new Error(\"Expected string or integer value.\");\n }\n range = `^${range}.0.0-0`;\n }\n if (typeof range !== \"string\") {\n throw new Error(\"Expected string or integer value.\");\n }\n\n const limit = Error.stackTraceLimit;\n\n if (typeof limit === \"number\" && limit < 25) {\n // Bump up the limit if needed so that users are more likely\n // to be able to see what is calling Babel.\n Error.stackTraceLimit = 25;\n }\n\n let err;\n if (version.startsWith(\"7.\")) {\n err = new Error(\n `Requires Babel \"^7.0.0-beta.41\", but was loaded with \"${version}\". ` +\n `You'll need to update your @babel/core version.`,\n );\n } else {\n err = new Error(\n `Requires Babel \"${range}\", but was loaded with \"${version}\". ` +\n `If you are sure you have a compatible version of @babel/core, ` +\n `it is likely that something in your build process is loading the ` +\n `wrong version. Inspect the stack trace of this error to look for ` +\n `the first entry that doesn't mention \"@babel/core\" or \"babel-core\" ` +\n `to see what is calling Babel.`,\n );\n }\n\n if (typeof limit === \"number\") {\n Error.stackTraceLimit = limit;\n }\n\n throw Object.assign(err, {\n code: \"BABEL_VERSION_UNSUPPORTED\",\n version,\n range,\n } as any);\n}\n"],"names":["apiPolyfills","assertVersion","api","range","throwVersionError","version","declare","builder","options","dirname","clonedApi","name","Object","keys","copyApiObject","declarePreset","proto","startsWith","getPrototypeOf","hasOwn","Number","isInteger","Error","limit","stackTraceLimit","err","assign","code"],"mappings":"AAgBA,MAAMA,YAA0B,GAAG;AAIjCC,EAAAA,aAAa,EAAGC,GAAc,IAAMC,KAAsB,IAAK;AAC7DC,IAAAA,iBAAiB,CAACD,KAAK,EAAED,GAAG,CAACG,OAAO,CAAC,CAAA;AACvC,GAAA;AACF,CAAC,CAAA;AAEM,SAASC,OA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AA;AAEA,EAAA,MAAMX,MAAM,CAACc,MAAM,CAACD,GAAG,EAAE;AACvBE,IAAAA,IAAI,EAAE,2BAA2B;IACjCtB,OAAO;AACPF,IAAAA,KAAAA;AACF,GAAQ,CAAC,CAAA;AACX;;;;"} | ||
| {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import type {\n PluginAPI,\n PluginObject,\n PluginPass,\n PresetAPI,\n PresetObject,\n} from \"@babel/core\";\n\ntype APIPolyfillFactory<T extends keyof PluginAPI> = (\n api: PluginAPI,\n) => PluginAPI[T];\n\ntype APIPolyfills = {\n assertVersion: APIPolyfillFactory<\"assertVersion\">;\n};\n\nconst apiPolyfills: APIPolyfills = {\n // Not supported by Babel 7 and early versions of Babel 7 beta.\n // It's important that this is polyfilled for older Babel versions\n // since it's needed to report the version mismatch.\n assertVersion: (api: PluginAPI) => (range: number | string) => {\n throwVersionError(range, api.version);\n },\n};\n\nexport function declare<State = object, Option = object>(\n builder: (\n api: PluginAPI,\n options: Option,\n dirname: string,\n ) => PluginObject<State & PluginPass>,\n): (\n api: PluginAPI,\n options: Option,\n dirname: string,\n) => PluginObject<State & PluginPass> {\n return (api, options: Option, dirname: string) => {\n let clonedApi: PluginAPI;\n\n for (const name of Object.keys(\n apiPolyfills,\n ) as (keyof typeof apiPolyfills)[]) {\n if (api[name]) continue;\n\n clonedApi ??= copyApiObject(api);\n clonedApi[name] = apiPolyfills[name](clonedApi);\n }\n\n // @ts-expect-error options || {} may not be assigned to Options\n return builder(clonedApi ?? api, options || {}, dirname);\n };\n}\n\nexport const declarePreset = declare as <Option = object>(\n builder: (api: PresetAPI, options: Option, dirname: string) => PresetObject,\n) => (api: PresetAPI, options: Option, dirname: string) => PresetObject;\n\nfunction copyApiObject(api: PluginAPI): PluginAPI {\n // Babel >= 7 <= beta.41 passed the API as a new object that had\n // babel/core as the prototype. While slightly faster, it also\n // means that the Object.assign copy below fails. Rather than\n // keep complexity, the Babel 6 behavior has been reverted and this\n // normalizes all that for Babel 7.\n let proto = null;\n if (typeof api.version === \"string\" && api.version.startsWith(\"7.\")) {\n proto = Object.getPrototypeOf(api);\n if (\n proto &&\n (!Object.hasOwn(proto, \"version\") ||\n !Object.hasOwn(proto, \"transform\") ||\n !Object.hasOwn(proto, \"template\") ||\n !Object.hasOwn(proto, \"types\"))\n ) {\n proto = null;\n }\n }\n\n return {\n ...proto,\n ...api,\n };\n}\n\nfunction throwVersionError(range: string | number, version: string) {\n if (typeof range === \"number\") {\n if (!Number.isInteger(range)) {\n throw new Error(\"Expected string or integer value.\");\n }\n range = `^${range}.0.0-0`;\n }\n if (typeof range !== \"string\") {\n throw new Error(\"Expected string or integer value.\");\n }\n\n const limit = Error.stackTraceLimit;\n\n if (typeof limit === \"number\" && limit < 25) {\n // Bump up the limit if needed so that users are more likely\n // to be able to see what is calling Babel.\n Error.stackTraceLimit = 25;\n }\n\n let err;\n if (version.startsWith(\"7.\")) {\n err = new Error(\n `Requires Babel \"^7.0.0-beta.41\", but was loaded with \"${version}\". ` +\n `You'll need to update your @babel/core version.`,\n );\n } else {\n err = new Error(\n `Requires Babel \"${range}\", but was loaded with \"${version}\". ` +\n `If you are sure you have a compatible version of @babel/core, ` +\n `it is likely that something in your build process is loading the ` +\n `wrong version. Inspect the stack trace of this error to look for ` +\n `the first entry that doesn't mention \"@babel/core\" or \"babel-core\" ` +\n `to see what is calling Babel.`,\n );\n }\n\n if (typeof limit === \"number\") {\n Error.stackTraceLimit = limit;\n }\n\n throw Object.assign(err, {\n code: \"BABEL_VERSION_UNSUPPORTED\",\n version,\n range,\n } as any);\n}\n"],"names":["apiPolyfills","assertVersion","api","range","throwVersionError","version","declare","builder","options","dirname","clonedApi","name","Object","keys","copyApiObject","declarePreset","proto","startsWith","getPrototypeOf","hasOwn","Number","isInteger","Error","limit","stackTraceLimit","err","assign","code"],"mappings":"AAgBA,MAAMA,YAA0B,GAAG;AAIjCC,EAAAA,aAAa,EAAGC,GAAc,IAAMC,KAAsB,IAAK;AAC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c,MAAM,CAACD,GAAG,EAAE;AACvBE,IAAAA,IAAI,EAAE,2BAA2B;IACjCtB,OAAO;AACPF,IAAAA;AACF,GAAQ,CAAC;AACX;;;;"} |
+3
-3
| { | ||
| "name": "@babel/helper-plugin-utils", | ||
| "version": "8.0.0-rc.2", | ||
| "version": "8.0.0-rc.3", | ||
| "description": "General utilities for plugins to use", | ||
@@ -21,6 +21,6 @@ "author": "The Babel Team (https://babel.dev/team)", | ||
| "devDependencies": { | ||
| "@babel/core": "^8.0.0-rc.2" | ||
| "@babel/core": "^8.0.0-rc.3" | ||
| }, | ||
| "peerDependencies": { | ||
| "@babel/core": "^8.0.0-rc.2" | ||
| "@babel/core": "^8.0.0-rc.3" | ||
| }, | ||
@@ -27,0 +27,0 @@ "exports": { |
11664
-1.12%