Debian Codegraph @

packages/babel-preset-env/src/index.ts

raw symbols SCIP
1 import semver, { type SemVer } from "semver";
2 import { logPluginscip-typescript npm @babel/preset-env 7.20.2 src/`debug.ts`/logPlugin. } from "./debug"scip-typescript npm @babel/preset-env 7.20.2 src/`debug.ts`/;
3 import getOptionSpecificExcludesFor from "./get-option-specific-excludes"scip-typescript npm @babel/preset-env 7.20.2 src/`get-option-specific-excludes.ts`/;
4 import {
5 addProposalSyntaxPluginsscip-typescript npm @babel/preset-env 7.20.2 src/`filter-items.ts`/addProposalSyntaxPlugins().,
6 removeUnnecessaryItemsscip-typescript npm @babel/preset-env 7.20.2 src/`filter-items.ts`/removeUnnecessaryItems().,
7 removeUnsupportedItemsscip-typescript npm @babel/preset-env 7.20.2 src/`filter-items.ts`/removeUnsupportedItems().,
8 } from "./filter-items"scip-typescript npm @babel/preset-env 7.20.2 src/`filter-items.ts`/;
9 import moduleTransformations from "./module-transformations"scip-typescript npm @babel/preset-env 7.20.2 src/`module-transformations.ts`/;
10 import normalizeOptionsscip-typescript npm @babel/preset-env 7.20.2 src/`normalize-options.ts`/normalizeOptions(). from "./normalize-options"scip-typescript npm @babel/preset-env 7.20.2 src/`normalize-options.ts`/;
11 import {
12 pluginSyntaxMapscip-typescript npm @babel/preset-env 7.20.2 src/`shipped-proposals.ts`/pluginSyntaxMap.,
13 proposalPluginsscip-typescript npm @babel/preset-env 7.20.2 src/`shipped-proposals.ts`/proposalPlugins.,
14 proposalSyntaxPluginsscip-typescript npm @babel/preset-env 7.20.2 src/`shipped-proposals.ts`/proposalSyntaxPlugins.,
15 } from "./shipped-proposals"scip-typescript npm @babel/preset-env 7.20.2 src/`shipped-proposals.ts`/;
16 import {
17 pluginsscip-typescript npm @babel/preset-env 7.20.2 src/`plugins-compat-data.ts`/plugins. as pluginsListscip-typescript npm @babel/preset-env 7.20.2 src/`plugins-compat-data.ts`/plugins.,
18 pluginsBugfixesscip-typescript npm @babel/preset-env 7.20.2 src/`plugins-compat-data.ts`/pluginsBugfixes. as pluginsBugfixesListscip-typescript npm @babel/preset-env 7.20.2 src/`plugins-compat-data.ts`/pluginsBugfixes.,
19 overlappingPluginsscip-typescript npm @babel/preset-env 7.20.2 src/`plugins-compat-data.ts`/overlappingPlugins.,
20 } from "./plugins-compat-data"scip-typescript npm @babel/preset-env 7.20.2 src/`plugins-compat-data.ts`/;
21
22 import removeRegeneratorEntryPlugin from "./polyfills/regenerator"scip-typescript npm @babel/preset-env 7.20.2 src/polyfills/`regenerator.ts`/;
23 import legacyBabelPolyfillPlugin from "./polyfills/babel-polyfill"scip-typescript npm @babel/preset-env 7.20.2 src/polyfills/`babel-polyfill.ts`/;
24
25 import type { CallerMetadatascip-typescript npm @babel/core 7.20.12 src/config/validation/`options.ts`/CallerMetadata# } from "@babel/core"scip-typescript npm @babel/core 7.20.12 src/`index.ts`/;
26
27 import _pluginCoreJS2scip-typescript npm babel 7.20.15 lib/`third-party-libs.d.ts`/`"babel-plugin-polyfill-corejs2"`/exports. from "babel-plugin-polyfill-corejs2"scip-typescript npm babel 7.20.15 lib/`third-party-libs.d.ts`/`"babel-plugin-polyfill-corejs2"`/;
28 import _pluginCoreJS3scip-typescript npm babel 7.20.15 lib/`third-party-libs.d.ts`/`"babel-plugin-polyfill-corejs3"`/exports. from "babel-plugin-polyfill-corejs3"scip-typescript npm babel 7.20.15 lib/`third-party-libs.d.ts`/`"babel-plugin-polyfill-corejs3"`/;
29 import _pluginRegeneratorscip-typescript npm babel 7.20.15 lib/`third-party-libs.d.ts`/`"babel-plugin-polyfill-regenerator"`/exports. from "babel-plugin-polyfill-regenerator"scip-typescript npm babel 7.20.15 lib/`third-party-libs.d.ts`/`"babel-plugin-polyfill-regenerator"`/;
30 const pluginCoreJS2scip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/pluginCoreJS2. = _pluginCoreJS2scip-typescript npm babel 7.20.15 lib/`third-party-libs.d.ts`/`"babel-plugin-polyfill-corejs2"`/exports..defaultscip-typescript npm babel 7.20.15 lib/`third-party-libs.d.ts`/`"babel-plugin-polyfill-corejs2"`/exports.typeLiteral3:default. || _pluginCoreJS2scip-typescript npm babel 7.20.15 lib/`third-party-libs.d.ts`/`"babel-plugin-polyfill-corejs2"`/exports.;
31 const pluginCoreJS3scip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/pluginCoreJS3. = _pluginCoreJS3scip-typescript npm babel 7.20.15 lib/`third-party-libs.d.ts`/`"babel-plugin-polyfill-corejs3"`/exports..defaultscip-typescript npm babel 7.20.15 lib/`third-party-libs.d.ts`/`"babel-plugin-polyfill-corejs3"`/exports.typeLiteral4:default. || _pluginCoreJS3scip-typescript npm babel 7.20.15 lib/`third-party-libs.d.ts`/`"babel-plugin-polyfill-corejs3"`/exports.;
32 const pluginRegeneratorscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/pluginRegenerator. = _pluginRegeneratorscip-typescript npm babel 7.20.15 lib/`third-party-libs.d.ts`/`"babel-plugin-polyfill-regenerator"`/exports..defaultscip-typescript npm babel 7.20.15 lib/`third-party-libs.d.ts`/`"babel-plugin-polyfill-regenerator"`/exports.typeLiteral5:default. || _pluginRegeneratorscip-typescript npm babel 7.20.15 lib/`third-party-libs.d.ts`/`"babel-plugin-polyfill-regenerator"`/exports.;
33
34 import getTargetsscip-typescript npm @babel/helper-compilation-targets 7.20.7 src/`index.ts`/getTargets()., {
35 prettifyTargetsscip-typescript npm @babel/helper-compilation-targets 7.20.7 src/`pretty.ts`/prettifyTargets().,
36 filterItemsscip-typescript npm @babel/helper-compilation-targets 7.20.7 src/`filter-items.ts`/filterItems().,
37 isRequiredscip-typescript npm @babel/helper-compilation-targets 7.20.7 src/`filter-items.ts`/isRequired().,
38 } from "@babel/helper-compilation-targets"scip-typescript npm @babel/helper-compilation-targets 7.20.7 src/`index.ts`/;
39 import type { Targetsscip-typescript npm @babel/helper-compilation-targets 7.20.7 src/`types.d.ts`/Targets#, InputTargetsscip-typescript npm @babel/helper-compilation-targets 7.20.7 src/`types.d.ts`/InputTargets# } from "@babel/helper-compilation-targets"scip-typescript npm @babel/helper-compilation-targets 7.20.7 src/`index.ts`/;
40 import availablePlugins from "./available-plugins"scip-typescript npm @babel/preset-env 7.20.2 src/`available-plugins.ts`/;
41 import { declarePresetscip-typescript npm @babel/helper-plugin-utils 7.20.2 src/`index.ts`/declarePreset. } from "@babel/helper-plugin-utils"scip-typescript npm @babel/helper-plugin-utils 7.20.2 src/`index.ts`/;
42
43 type ModuleTransformationsTypescip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/ModuleTransformationsType# =
44 typeof import("./module-transformations"scip-typescript npm @babel/preset-env 7.20.2 src/`module-transformations.ts`/).default;
45 import type { BuiltInsOptionscip-typescript npm @babel/preset-env 7.20.2 src/`types.d.ts`/BuiltInsOption#, ModuleOptionscip-typescript npm @babel/preset-env 7.20.2 src/`types.d.ts`/ModuleOption#, Optionsscip-typescript npm @babel/preset-env 7.20.2 src/`types.d.ts`/Options# } from "./types"scip-typescript npm @babel/preset-env 7.20.2 src/`types.d.ts`/;
46
47 // TODO: Remove in Babel 8
48 export function isPluginRequiredscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/isPluginRequired().(targetsscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/isPluginRequired().(targets): Targetsscip-typescript npm @babel/helper-compilation-targets 7.20.7 src/`types.d.ts`/Targets#, supportscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/isPluginRequired().(support): Targetsscip-typescript npm @babel/helper-compilation-targets 7.20.7 src/`types.d.ts`/Targets#) {
49 return isRequiredscip-typescript npm @babel/helper-compilation-targets 7.20.7 src/`filter-items.ts`/isRequired().("fake-name", targetsscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/isPluginRequired().(targets), {
50 compatDatascip-typescript npm @babel/helper-compilation-targets 7.20.7 src/`filter-items.ts`/isRequired().(`{ compatData = pluginsCompatData, includes, excludes, }`)typeLiteral18:compatData.: { "fake-name"scip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/`"fake-name"0`:: supportscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/isPluginRequired().(support) },
51 });
52 }
53
54 function filterStageFromListscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/filterStageFromList().(
55 listscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/filterStageFromList().(list): { [feature: string]: Targetsscip-typescript npm @babel/helper-compilation-targets 7.20.7 src/`types.d.ts`/Targets# },
56 stageListscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/filterStageFromList().(stageList): Setscip-typescript npm typescript 5.9.3 lib/`lib.es2015.collection.d.ts`/Set#<string>,
57 ) {
58 return Objectscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Object#.keysscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/ObjectConstructor#keys().(listscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/filterStageFromList().(list)).reducescip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#reduce().((result, item) => {
59 if (!stageListscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/filterStageFromList().(stageList).hasscip-typescript npm typescript 5.9.3 lib/`lib.es2015.collection.d.ts`/Set#has().(item)) {
60 // @ts-expect-error todo: refine result types
61 result[item] = listscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/filterStageFromList().(list)[item];
62 }
63
64 return result;
65 }, {});
66 }
67
68 const pluginListsscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/pluginLists. = {
69 withProposalsscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/withProposals0:: {
70 withoutBugfixesscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/withoutBugfixes0:: pluginsListscip-typescript npm @babel/preset-env 7.20.2 src/`plugins-compat-data.ts`/plugins.,
71 withBugfixesscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/withBugfixes0:: Objectscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Object#.assignscip-typescript npm typescript 5.9.3 lib/`lib.es2015.core.d.ts`/ObjectConstructor#assign().({}, pluginsListscip-typescript npm @babel/preset-env 7.20.2 src/`plugins-compat-data.ts`/plugins., pluginsBugfixesListscip-typescript npm @babel/preset-env 7.20.2 src/`plugins-compat-data.ts`/pluginsBugfixes.),
72 },
73 withoutProposalsscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/withoutProposals0:: {
74 withoutBugfixesscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/withoutBugfixes1:: filterStageFromListscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/filterStageFromList().(pluginsListscip-typescript npm @babel/preset-env 7.20.2 src/`plugins-compat-data.ts`/plugins., proposalPluginsscip-typescript npm @babel/preset-env 7.20.2 src/`shipped-proposals.ts`/proposalPlugins.),
75 withBugfixesscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/withBugfixes1:: filterStageFromListscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/filterStageFromList().(
76 Objectscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Object#.assignscip-typescript npm typescript 5.9.3 lib/`lib.es2015.core.d.ts`/ObjectConstructor#assign().({}, pluginsListscip-typescript npm @babel/preset-env 7.20.2 src/`plugins-compat-data.ts`/plugins., pluginsBugfixesListscip-typescript npm @babel/preset-env 7.20.2 src/`plugins-compat-data.ts`/pluginsBugfixes.),
77 proposalPluginsscip-typescript npm @babel/preset-env 7.20.2 src/`shipped-proposals.ts`/proposalPlugins.,
78 ),
79 },
80 };
81
82 function getPluginListscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/getPluginList().(proposalsscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/getPluginList().(proposals): boolean, bugfixesscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/getPluginList().(bugfixes): boolean) {
83 if (proposalsscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/getPluginList().(proposals)) {
84 if (bugfixesscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/getPluginList().(bugfixes)) return pluginListsscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/pluginLists..withProposalsscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/withProposals0:.withBugfixesscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/withBugfixes0:;
85 else return pluginListsscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/pluginLists..withProposalsscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/withProposals0:.withoutBugfixesscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/withoutBugfixes0:;
86 } else {
87 if (bugfixesscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/getPluginList().(bugfixes)) return pluginListsscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/pluginLists..withoutProposalsscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/withoutProposals0:.withBugfixesscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/withBugfixes1:;
88 else return pluginListsscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/pluginLists..withoutProposalsscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/withoutProposals0:.withoutBugfixesscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/withoutBugfixes1:;
89 }
90 }
91
92 const getPluginscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/getPlugin. = (pluginName: string) => {
93 const plugin =
94 // @ts-expect-error plugin name is constructed from available plugin list
95 availablePlugins[pluginName]();
96
97 if (!plugin) {
98 throw new Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#(
99 `Could not find plugin "${pluginName}". Ensure there is an entry in ./available-plugins.js for it.`,
100 );
101 }
102
103 return plugin;
104 };
105
106 export const transformIncludesAndExcludesscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/transformIncludesAndExcludes. = (opts: Arrayscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#<string>): any => {
107 return opts.reducescip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#reduce().(
108 (result, opt) => {
109 const target = opt.matchscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/String#match().(/^(es|es6|es7|esnext|web)\./)
110 ? "builtIns"
111 : "plugins";
112 result[target].addscip-typescript npm typescript 5.9.3 lib/`lib.es2015.collection.d.ts`/Set#add().(opt);
113 return result;
114 },
115 {
116 allscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/all0:: opts,
117 pluginsscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/plugins0:: new Setscip-typescript npm typescript 5.9.3 lib/`lib.es2015.collection.d.ts`/Set#(),
118 builtInsscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/builtIns0:: new Setscip-typescript npm typescript 5.9.3 lib/`lib.es2015.collection.d.ts`/Set#(),
119 },
120 );
121 };
122
123 export const getModulesPluginNamesscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/getModulesPluginNames. = ({
124 modules,
125 transformations,
126 shouldTransformESM,
127 shouldTransformDynamicImport,
128 shouldTransformExportNamespaceFrom,
129 shouldParseTopLevelAwait,
130 }: {
131 modules: ModuleOptionscip-typescript npm @babel/preset-env 7.20.2 src/`types.d.ts`/ModuleOption#;
132 transformations: ModuleTransformationsTypescip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/ModuleTransformationsType#;
133 shouldTransformESM: boolean;
134 shouldTransformDynamicImport: boolean;
135 shouldTransformExportNamespaceFrom: boolean;
136 shouldParseTopLevelAwait: boolean;
137 }) => {
138 const modulesPluginNames = [];
139 if (modules !== false && transformations[modules]) {
140 if (shouldTransformESM) {
141 modulesPluginNames.pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().(transformations[modules]);
142 }
143
144 if (
145 shouldTransformDynamicImport &&
146 shouldTransformESM &&
147 modules !== "umd"
148 ) {
149 modulesPluginNames.pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().("transform-dynamic-import");
150 } else {
151 if (shouldTransformDynamicImport) {
152 consolescip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/console..warnscip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/Console#warn().(
153 "Dynamic import can only be supported when transforming ES modules" +
154 " to AMD, CommonJS or SystemJS. Only the parser plugin will be enabled.",
155 );
156 }
157 modulesPluginNames.pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().("syntax-dynamic-import");
158 }
159 } else {
160 modulesPluginNames.pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().("syntax-dynamic-import");
161 }
162
163 if (shouldTransformExportNamespaceFrom) {
164 modulesPluginNames.pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().("transform-export-namespace-from");
165 } else {
166 modulesPluginNames.pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().("syntax-export-namespace-from");
167 }
168
169 if (shouldParseTopLevelAwait) {
170 modulesPluginNames.pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().("syntax-top-level-await");
171 }
172
173 return modulesPluginNames;
174 };
175
176 export const getPolyfillPluginsscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/getPolyfillPlugins. = ({
177 useBuiltIns,
178 corejs,
179 polyfillTargets,
180 include,
181 exclude,
182 proposals,
183 shippedProposals,
184 regenerator,
185 debug,
186 }: {
187 useBuiltIns: BuiltInsOptionscip-typescript npm @babel/preset-env 7.20.2 src/`types.d.ts`/BuiltInsOption#;
188 corejs: SemVer | null | false;
189 polyfillTargets: Targetsscip-typescript npm @babel/helper-compilation-targets 7.20.7 src/`types.d.ts`/Targets#;
190 include: Setscip-typescript npm typescript 5.9.3 lib/`lib.es2015.collection.d.ts`/Set#<string>;
191 exclude: Setscip-typescript npm typescript 5.9.3 lib/`lib.es2015.collection.d.ts`/Set#<string>;
192 proposals: boolean;
193 shippedProposals: boolean;
194 regenerator: boolean;
195 debug: boolean;
196 }) => {
197 const polyfillPlugins = [];
198 if (useBuiltIns === "usage" || useBuiltIns === "entry") {
199 const pluginOptions = {
200 methodscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/method0:: `${useBuiltIns}-global`,
201 versionscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/version0:: corejs ? corejs.toString() : undefined,
202 targetsscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/targets0:: polyfillTargets,
203 includescip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/include0:,
204 excludescip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/exclude0:,
205 proposalsscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/proposals0:,
206 shippedProposalsscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/shippedProposals0:,
207 debugscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/debug0:,
208 };
209
210 if (corejs) {
211 if (useBuiltIns === "usage") {
212 if (corejs.major === 2) {
213 polyfillPlugins.pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().(
214 [pluginCoreJS2scip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/pluginCoreJS2., pluginOptions],
215 [legacyBabelPolyfillPlugin, { usagescip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/usage0:: true }],
216 );
217 } else {
218 polyfillPlugins.pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().(
219 [pluginCoreJS3scip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/pluginCoreJS3., pluginOptions],
220 [legacyBabelPolyfillPlugin, { usagescip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/usage1:: true, deprecatedscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/deprecated0:: true }],
221 );
222 }
223 if (regenerator) {
224 polyfillPlugins.pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().([
225 pluginRegeneratorscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/pluginRegenerator.,
226 { methodscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/method1:: "usage-global", debugscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/debug1: },
227 ]);
228 }
229 } else {
230 if (corejs.major === 2) {
231 polyfillPlugins.pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().(
232 [legacyBabelPolyfillPlugin, { regeneratorscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/regenerator0: }],
233 [pluginCoreJS2scip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/pluginCoreJS2., pluginOptions],
234 );
235 } else {
236 polyfillPlugins.pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().(
237 [pluginCoreJS3scip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/pluginCoreJS3., pluginOptions],
238 [legacyBabelPolyfillPlugin, { deprecatedscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/deprecated1:: true }],
239 );
240 if (!regenerator) {
241 polyfillPlugins.pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().([removeRegeneratorEntryPlugin, pluginOptions]);
242 }
243 }
244 }
245 }
246 }
247 return polyfillPlugins;
248 };
249
250 function getLocalTargetsscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/getLocalTargets().(
251 optionsTargetsscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/getLocalTargets().(optionsTargets): Optionsscip-typescript npm @babel/preset-env 7.20.2 src/`types.d.ts`/Options#["targets"scip-typescript npm @babel/preset-env 7.20.2 src/`types.d.ts`/Options#typeLiteral4:targets.],
252 ignoreBrowserslistConfigscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/getLocalTargets().(ignoreBrowserslistConfig): boolean,
253 configPathscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/getLocalTargets().(configPath): string,
254 browserslistEnvscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/getLocalTargets().(browserslistEnv): string,
255 ) {
256 if (optionsTargetsscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/getLocalTargets().(optionsTargets)?.esmodules && optionsTargetsscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/getLocalTargets().(optionsTargets).browsers) {
257 consolescip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/console..warnscip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/Console#warn().(`
258 @babel/preset-env: esmodules and browsers targets have been specified together.
259 \`browsers\` target, \`${optionsTargetsscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/getLocalTargets().(optionsTargets).browsers.toStringscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/String#toString().()}\` will be ignored.
260 `);
261 }
262
263 return getTargetsscip-typescript npm @babel/helper-compilation-targets 7.20.7 src/`index.ts`/getTargets().(optionsTargetsscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/getLocalTargets().(optionsTargets) as InputTargetsscip-typescript npm @babel/helper-compilation-targets 7.20.7 src/`types.d.ts`/InputTargets#, {
264 ignoreBrowserslistConfigscip-typescript npm @babel/helper-compilation-targets 7.20.7 src/`index.ts`/GetTargetsOption#typeLiteral82:ignoreBrowserslistConfig.,
265 configPathscip-typescript npm @babel/helper-compilation-targets 7.20.7 src/`index.ts`/GetTargetsOption#typeLiteral82:configPath.,
266 browserslistEnvscip-typescript npm @babel/helper-compilation-targets 7.20.7 src/`index.ts`/GetTargetsOption#typeLiteral82:browserslistEnv.,
267 });
268 }
269
270 function supportsStaticESMscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/supportsStaticESM().(callerscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/supportsStaticESM().(caller): CallerMetadatascip-typescript npm @babel/core 7.20.12 src/config/validation/`options.ts`/CallerMetadata# | undefined) {
271 // @ts-expect-error supportsStaticESM is not defined in CallerMetadata
272 return !!callerscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/supportsStaticESM().(caller)?.supportsStaticESM;
273 }
274
275 function supportsDynamicImportscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/supportsDynamicImport().(callerscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/supportsDynamicImport().(caller): CallerMetadatascip-typescript npm @babel/core 7.20.12 src/config/validation/`options.ts`/CallerMetadata# | undefined) {
276 // @ts-expect-error supportsDynamicImport is not defined in CallerMetadata
277 return !!callerscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/supportsDynamicImport().(caller)?.supportsDynamicImport;
278 }
279
280 function supportsExportNamespaceFromscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/supportsExportNamespaceFrom().(callerscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/supportsExportNamespaceFrom().(caller): CallerMetadatascip-typescript npm @babel/core 7.20.12 src/config/validation/`options.ts`/CallerMetadata# | undefined) {
281 // @ts-expect-error supportsExportNamespaceFrom is not defined in CallerMetadata
282 return !!callerscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/supportsExportNamespaceFrom().(caller)?.supportsExportNamespaceFrom;
283 }
284
285 function supportsTopLevelAwaitscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/supportsTopLevelAwait().(callerscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/supportsTopLevelAwait().(caller): CallerMetadatascip-typescript npm @babel/core 7.20.12 src/config/validation/`options.ts`/CallerMetadata# | undefined) {
286 // @ts-expect-error supportsTopLevelAwait is not defined in CallerMetadata
287 return !!callerscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/supportsTopLevelAwait().(caller)?.supportsTopLevelAwait;
288 }
289
290 export default declarePresetscip-typescript npm @babel/helper-plugin-utils 7.20.2 src/`index.ts`/declarePreset.((api, opts: Optionsscip-typescript npm @babel/preset-env 7.20.2 src/`types.d.ts`/Options#) => {
291 api.assertVersionscip-typescript npm @babel/core 7.20.12 src/config/helpers/`config-api.ts`/ConfigAPI#typeLiteral7:assertVersion.(7);
292
293 const babelTargets = api.targets();
294
295 const {
296 bugfixesscip-typescript npm @babel/preset-env 7.20.2 src/`normalize-options.ts`/bugfixes0:,
297 configPathscip-typescript npm @babel/preset-env 7.20.2 src/`normalize-options.ts`/configPath0:,
298 debugscip-typescript npm @babel/preset-env 7.20.2 src/`normalize-options.ts`/debug0:,
299 excludescip-typescript npm @babel/preset-env 7.20.2 src/`normalize-options.ts`/exclude0:: optionsExclude,
300 forceAllTransformsscip-typescript npm @babel/preset-env 7.20.2 src/`normalize-options.ts`/forceAllTransforms0:,
301 ignoreBrowserslistConfigscip-typescript npm @babel/preset-env 7.20.2 src/`normalize-options.ts`/ignoreBrowserslistConfig0:,
302 includescip-typescript npm @babel/preset-env 7.20.2 src/`normalize-options.ts`/include0:: optionsInclude,
303 loosescip-typescript npm @babel/preset-env 7.20.2 src/`normalize-options.ts`/loose0:,
304 modulesscip-typescript npm @babel/preset-env 7.20.2 src/`normalize-options.ts`/modules0:,
305 shippedProposalsscip-typescript npm @babel/preset-env 7.20.2 src/`normalize-options.ts`/shippedProposals0:,
306 specscip-typescript npm @babel/preset-env 7.20.2 src/`normalize-options.ts`/spec0:,
307 targetsscip-typescript npm @babel/preset-env 7.20.2 src/`normalize-options.ts`/targets0:: optionsTargets,
308 useBuiltInsscip-typescript npm @babel/preset-env 7.20.2 src/`normalize-options.ts`/useBuiltIns0:,
309 corejsscip-typescript npm @babel/preset-env 7.20.2 src/`normalize-options.ts`/corejs0:: { versionscip-typescript npm @babel/preset-env 7.20.2 src/`normalize-options.ts`/NormalizedCorejsOption#typeLiteral64:version.: corejs, proposalsscip-typescript npm @babel/preset-env 7.20.2 src/`normalize-options.ts`/NormalizedCorejsOption#typeLiteral64:proposals. },
310 browserslistEnvscip-typescript npm @babel/preset-env 7.20.2 src/`normalize-options.ts`/browserslistEnv0:,
311 } = normalizeOptionsscip-typescript npm @babel/preset-env 7.20.2 src/`normalize-options.ts`/normalizeOptions().(opts);
312
313 let targets = babelTargets;
314
315 if (
316 // @babel/core < 7.13.0 doesn't load targets (api.targets() always
317 // returns {} thanks to @babel/helper-plugin-utils), so we always want
318 // to fallback to the old targets behavior in this case.
319 semver.lt(api.versionscip-typescript npm @babel/core 7.20.12 src/config/helpers/`config-api.ts`/ConfigAPI#typeLiteral7:version., "7.13.0") ||
320 // If any browserslist-related option is specified, fallback to the old
321 // behavior of not using the targets specified in the top-level options.
322 opts.targetsscip-typescript npm @babel/preset-env 7.20.2 src/`types.d.ts`/Options#typeLiteral4:targets. ||
323 opts.configPathscip-typescript npm @babel/preset-env 7.20.2 src/`types.d.ts`/Options#typeLiteral4:configPath. ||
324 opts.browserslistEnvscip-typescript npm @babel/preset-env 7.20.2 src/`types.d.ts`/Options#typeLiteral4:browserslistEnv. ||
325 opts.ignoreBrowserslistConfigscip-typescript npm @babel/preset-env 7.20.2 src/`types.d.ts`/Options#typeLiteral4:ignoreBrowserslistConfig.
326 ) {
327 if (!process.env.BABEL_8_BREAKING) {
328 // eslint-disable-next-line no-var
329 var hasUglifyTarget = false;
330
331 if (optionsTargets?.uglify) {
332 hasUglifyTarget = true;
333 delete optionsTargets.uglify;
334
335 consolescip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/console..warnscip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/Console#warn().(`
336 The uglify target has been deprecated. Set the top level
337 option \`forceAllTransforms: true\` instead.
338 `);
339 }
340 }
341
342 targets = getLocalTargetsscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/getLocalTargets().(
343 optionsTargets,
344 ignoreBrowserslistConfig,
345 configPath,
346 browserslistEnv,
347 );
348 }
349
350 const transformTargets = (
351 process.env.BABEL_8_BREAKING
352 ? forceAllTransforms
353 : forceAllTransforms || hasUglifyTarget
354 )
355 ? ({} as Targetsscip-typescript npm @babel/helper-compilation-targets 7.20.7 src/`types.d.ts`/Targets#)
356 : targets;
357
358 const include = transformIncludesAndExcludesscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/transformIncludesAndExcludes.(optionsInclude);
359 const exclude = transformIncludesAndExcludesscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/transformIncludesAndExcludes.(optionsExclude);
360
361 const compatData = getPluginListscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/getPluginList().(shippedProposals, bugfixes);
362 const shouldSkipExportNamespaceFrom =
363 (modules === "auto" && api.callerscip-typescript npm @babel/core 7.20.12 src/config/helpers/`config-api.ts`/ConfigAPI#typeLiteral7:caller.?.(supportsExportNamespaceFromscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/supportsExportNamespaceFrom().)) ||
364 (modules === false &&
365 !isRequiredscip-typescript npm @babel/helper-compilation-targets 7.20.7 src/`filter-items.ts`/isRequired().("transform-export-namespace-from", transformTargets, {
366 compatDatascip-typescript npm @babel/helper-compilation-targets 7.20.7 src/`filter-items.ts`/isRequired().(`{ compatData = pluginsCompatData, includes, excludes, }`)typeLiteral18:compatData.,
367 includesscip-typescript npm @babel/helper-compilation-targets 7.20.7 src/`filter-items.ts`/isRequired().(`{ compatData = pluginsCompatData, includes, excludes, }`)typeLiteral18:includes.: include.plugins,
368 excludesscip-typescript npm @babel/helper-compilation-targets 7.20.7 src/`filter-items.ts`/isRequired().(`{ compatData = pluginsCompatData, includes, excludes, }`)typeLiteral18:excludes.: exclude.plugins,
369 }));
370 const modulesPluginNames = getModulesPluginNamesscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/getModulesPluginNames.({
371 modules,
372 transformations: moduleTransformations,
373 // TODO: Remove the 'api.caller' check eventually. Just here to prevent
374 // unnecessary breakage in the short term for users on older betas/RCs.
375 shouldTransformESM: modules !== "auto" || !api.callerscip-typescript npm @babel/core 7.20.12 src/config/helpers/`config-api.ts`/ConfigAPI#typeLiteral7:caller.?.(supportsStaticESMscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/supportsStaticESM().),
376 shouldTransformDynamicImport:
377 modules !== "auto" || !api.callerscip-typescript npm @babel/core 7.20.12 src/config/helpers/`config-api.ts`/ConfigAPI#typeLiteral7:caller.?.(supportsDynamicImportscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/supportsDynamicImport().),
378 shouldTransformExportNamespaceFrom: !shouldSkipExportNamespaceFrom,
379 shouldParseTopLevelAwait:
380 !api.callerscip-typescript npm @babel/core 7.20.12 src/config/helpers/`config-api.ts`/ConfigAPI#typeLiteral7:caller. || (api.callerscip-typescript npm @babel/core 7.20.12 src/config/helpers/`config-api.ts`/ConfigAPI#typeLiteral7:caller.(supportsTopLevelAwaitscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/supportsTopLevelAwait().) as boolean),
381 });
382
383 const pluginNames = filterItemsscip-typescript npm @babel/helper-compilation-targets 7.20.7 src/`filter-items.ts`/filterItems().(
384 compatData,
385 include.plugins,
386 exclude.plugins,
387 transformTargets,
388 modulesPluginNames,
389 getOptionSpecificExcludesFor({ loose }),
390 pluginSyntaxMapscip-typescript npm @babel/preset-env 7.20.2 src/`shipped-proposals.ts`/pluginSyntaxMap.,
391 );
392 removeUnnecessaryItemsscip-typescript npm @babel/preset-env 7.20.2 src/`filter-items.ts`/removeUnnecessaryItems().(pluginNames, overlappingPluginsscip-typescript npm @babel/preset-env 7.20.2 src/`plugins-compat-data.ts`/overlappingPlugins.);
393 removeUnsupportedItemsscip-typescript npm @babel/preset-env 7.20.2 src/`filter-items.ts`/removeUnsupportedItems().(pluginNames, api.versionscip-typescript npm @babel/core 7.20.12 src/config/helpers/`config-api.ts`/ConfigAPI#typeLiteral7:version.);
394 if (shippedProposals) {
395 addProposalSyntaxPluginsscip-typescript npm @babel/preset-env 7.20.2 src/`filter-items.ts`/addProposalSyntaxPlugins().(pluginNames, proposalSyntaxPluginsscip-typescript npm @babel/preset-env 7.20.2 src/`shipped-proposals.ts`/proposalSyntaxPlugins.);
396 }
397
398 const polyfillPlugins = getPolyfillPluginsscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/getPolyfillPlugins.({
399 useBuiltIns,
400 corejs,
401 polyfillTargets: targets,
402 include: include.builtIns,
403 exclude: exclude.builtIns,
404 proposals,
405 shippedProposals,
406 regenerator: pluginNames.hasscip-typescript npm typescript 5.9.3 lib/`lib.es2015.collection.d.ts`/Set#has().("transform-regenerator"),
407 debug,
408 });
409
410 const pluginUseBuiltIns = useBuiltIns !== false;
411 const plugins = Arrayscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#.fromscip-typescript npm typescript 5.9.3 lib/`lib.es2015.core.d.ts`/ArrayConstructor#from().(pluginNames)
412 .mapscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#map().(pluginName => {
413 if (
414 pluginName === "transform-class-properties" ||
415 pluginName === "transform-private-methods" ||
416 pluginName === "transform-private-property-in-object"
417 ) {
418 return [
419 getPluginscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/getPlugin.(pluginName),
420 {
421 loosescip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/loose0:: loose
422 ? "#__internal__@babel/preset-env__prefer-true-but-false-is-ok-if-it-prevents-an-error"
423 : "#__internal__@babel/preset-env__prefer-false-but-true-is-ok-if-it-prevents-an-error",
424 },
425 ];
426 }
427 return [
428 getPluginscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/getPlugin.(pluginName),
429 { specscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/spec0:, loosescip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/loose1:, useBuiltInsscip-typescript npm @babel/preset-env 7.20.2 src/`index.ts`/useBuiltIns0:: pluginUseBuiltIns },
430 ];
431 })
432 .concatscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#concat().(polyfillPlugins);
433
434 if (debug) {
435 consolescip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/console..logscip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/Console#log().("@babel/preset-env: `DEBUG` option");
436 consolescip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/console..logscip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/Console#log().("\nUsing targets:");
437 consolescip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/console..logscip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/Console#log().(JSONscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/JSON#.stringifyscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/JSON#stringify().(prettifyTargetsscip-typescript npm @babel/helper-compilation-targets 7.20.7 src/`pretty.ts`/prettifyTargets().(targets), null, 2));
438 consolescip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/console..logscip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/Console#log().(`\nUsing modules transform: ${modules.toStringscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Object#toString().()}`);
439 consolescip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/console..logscip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/Console#log().("\nUsing plugins:");
440 pluginNames.forEachscip-typescript npm typescript 5.9.3 lib/`lib.es2015.collection.d.ts`/Set#forEach().(pluginName => {
441 logPluginscip-typescript npm @babel/preset-env 7.20.2 src/`debug.ts`/logPlugin.(pluginName, targets, compatData);
442 });
443
444 if (!useBuiltIns) {
445 consolescip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/console..logscip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/Console#log().(
446 "\nUsing polyfills: No polyfills were added, since the `useBuiltIns` option was not set.",
447 );
448 }
449 }
450
451 return { pluginsscip-typescript npm @babel/core 7.20.12 src/config/validation/`options.ts`/ValidatedOptions#typeLiteral23:plugins. };
452 });