Skip to content

Commit

Permalink
[preset-env - debug] Print targets that need each plugin (#13115)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Apr 7, 2021
1 parent 6d89daf commit be1003b
Show file tree
Hide file tree
Showing 208 changed files with 5,665 additions and 5,711 deletions.
74 changes: 14 additions & 60 deletions packages/babel-preset-env/src/debug.js
Expand Up @@ -5,78 +5,32 @@ import {
type Targets,
} from "@babel/helper-compilation-targets";

const wordEnds = (size: number) => {
return size > 1 ? "s" : "";
};

// Outputs a message that shows which target(s) caused an item to be included:
// transform-foo { "edge":"13", "firefox":"49", "ie":"10" }
export const logPluginOrPolyfill = (
export const logPlugin = (
item: string,
targetVersions: Targets,
list: { [key: string]: Targets },
) => {
const filteredList = getInclusionReasons(item, targetVersions, list);

const formattedTargets = JSON.stringify(filteredList)
.replace(/,/g, ", ")
.replace(/^\{"/, '{ "')
.replace(/"\}$/, '" }');

console.log(` ${item} ${formattedTargets}`);
};
const support = list[item];

export const logEntryPolyfills = (
polyfillName: string,
importPolyfillIncluded: boolean,
polyfills: Set<string>,
filename: string,
polyfillTargets: Targets,
allBuiltInsList: { [key: string]: Targets },
) => {
if (!importPolyfillIncluded) {
console.log(`\n[${filename}] Import of ${polyfillName} was not found.`);
return;
}
if (!polyfills.size) {
console.log(
`\n[${filename}] Based on your targets, polyfills were not added.`,
);
if (!support) {
console.log(` ${item}`);
return;
}

console.log(
`\n[${filename}] Replaced ${polyfillName} entries with the following polyfill${wordEnds(
polyfills.size,
)}:`,
);
for (const polyfill of polyfills) {
logPluginOrPolyfill(polyfill, polyfillTargets, allBuiltInsList);
let formattedTargets = `{`;
let first = true;
for (const target of Object.keys(filteredList)) {
if (!first) formattedTargets += `,`;
first = false;
formattedTargets += ` ${target}`;
// $FlowIgnore
if (support[target]) formattedTargets += ` < ${support[target]}`;
}
};
formattedTargets += ` }`;

export const logUsagePolyfills = (
polyfills: Set<string>,
filename: string,
polyfillTargets: Targets,
allBuiltInsList: { [key: string]: Targets },
) => {
// normalize filename to generate consistent preset-env test fixtures
if (process.env.BABEL_ENV === "test") {
filename = filename.replace(/\\/g, "/");
}
if (!polyfills.size) {
console.log(
`\n[${filename}] Based on your code and targets, core-js polyfills were not added.`,
);
return;
}
console.log(
`\n[${filename}] Added following core-js polyfill${wordEnds(
polyfills.size,
)}:`,
);
for (const polyfill of polyfills) {
logPluginOrPolyfill(polyfill, polyfillTargets, allBuiltInsList);
}
console.log(` ${item} ${formattedTargets}`);
};
4 changes: 2 additions & 2 deletions packages/babel-preset-env/src/index.js
@@ -1,7 +1,7 @@
//@flow

import { SemVer, lt } from "semver";
import { logPluginOrPolyfill } from "./debug";
import { logPlugin } from "./debug";
import getOptionSpecificExcludesFor from "./get-option-specific-excludes";
import { removeUnnecessaryItems } from "./filter-items";
import moduleTransformations from "./module-transformations";
Expand Down Expand Up @@ -420,7 +420,7 @@ option \`forceAllTransforms: true\` instead.
console.log(`\nUsing modules transform: ${modules.toString()}`);
console.log("\nUsing plugins:");
pluginNames.forEach(pluginName => {
logPluginOrPolyfill(pluginName, targets, pluginsList);
logPlugin(pluginName, targets, compatData);
});

if (!useBuiltIns) {
Expand Down
Expand Up @@ -16,25 +16,25 @@ Using targets:
Using modules transform: auto

Using plugins:
proposal-numeric-separator { "android":"61", "chrome":"61", "edge":"16", "firefox":"60", "ios":"10.3", "opera":"48", "safari":"10.1", "samsung":"8.2" }
proposal-logical-assignment-operators { "android":"61", "chrome":"61", "edge":"16", "firefox":"60", "ios":"10.3", "node":"13.2", "opera":"48", "safari":"10.1", "samsung":"8.2" }
proposal-nullish-coalescing-operator { "android":"61", "chrome":"61", "edge":"16", "firefox":"60", "ios":"10.3", "node":"13.2", "opera":"48", "safari":"10.1", "samsung":"8.2" }
proposal-optional-chaining { "android":"61", "chrome":"61", "edge":"16", "firefox":"60", "ios":"10.3", "node":"13.2", "opera":"48", "safari":"10.1", "samsung":"8.2" }
proposal-json-strings { "android":"61", "chrome":"61", "edge":"16", "firefox":"60", "ios":"10.3", "opera":"48", "safari":"10.1", "samsung":"8.2" }
proposal-optional-catch-binding { "android":"61", "chrome":"61", "edge":"16", "ios":"10.3", "opera":"48", "safari":"10.1", "samsung":"8.2" }
transform-parameters { "edge":"16" }
proposal-async-generator-functions { "android":"61", "chrome":"61", "edge":"16", "ios":"10.3", "opera":"48", "safari":"10.1" }
proposal-object-rest-spread { "edge":"16", "ios":"10.3", "safari":"10.1" }
transform-dotall-regex { "android":"61", "chrome":"61", "edge":"16", "firefox":"60", "ios":"10.3", "opera":"48", "safari":"10.1" }
proposal-unicode-property-regex { "android":"61", "chrome":"61", "edge":"16", "firefox":"60", "ios":"10.3", "opera":"48", "safari":"10.1", "samsung":"8.2" }
transform-named-capturing-groups-regex { "android":"61", "chrome":"61", "edge":"16", "firefox":"60", "ios":"10.3", "opera":"48", "safari":"10.1", "samsung":"8.2" }
transform-async-to-generator { "ios":"10.3", "safari":"10.1" }
transform-template-literals { "ios":"10.3", "safari":"10.1" }
transform-function-name { "edge":"16" }
transform-unicode-regex { "ios":"10.3", "safari":"10.1" }
transform-block-scoping { "ios":"10.3", "safari":"10.1" }
proposal-export-namespace-from { "android":"61", "chrome":"61", "edge":"16", "firefox":"60", "ios":"10.3", "opera":"48", "safari":"10.1", "samsung":"8.2" }
transform-modules-commonjs { "android":"61", "chrome":"61", "edge":"16", "firefox":"60", "ios":"10.3", "node":"13.2", "opera":"48", "safari":"10.1", "samsung":"8.2" }
proposal-dynamic-import { "android":"61", "chrome":"61", "edge":"16", "firefox":"60", "ios":"10.3", "node":"13.2", "opera":"48", "safari":"10.1", "samsung":"8.2" }
proposal-numeric-separator { android, chrome < 75, edge < 79, firefox < 70, ios < 13, opera < 62, safari < 13, samsung < 11 }
proposal-logical-assignment-operators { android, chrome < 85, edge < 85, firefox < 79, ios < 14, node < 15, opera, safari < 14, samsung }
proposal-nullish-coalescing-operator { android, chrome < 80, edge < 80, firefox < 72, ios < 13.4, node < 14, opera < 67, safari < 13.1, samsung < 13 }
proposal-optional-chaining { android, chrome, edge, firefox < 74, ios < 13.4, node, opera, safari < 13.1, samsung }
proposal-json-strings { android, chrome < 66, edge < 79, firefox < 62, ios < 12, opera < 53, safari < 12, samsung < 9 }
proposal-optional-catch-binding { android, chrome < 66, edge < 79, ios < 11.3, opera < 53, safari < 11.1, samsung < 9 }
transform-parameters { edge < 18 }
proposal-async-generator-functions { android, chrome < 63, edge < 79, ios < 12, opera < 50, safari < 12 }
proposal-object-rest-spread { edge < 79, ios < 11.3, safari < 11.1 }
transform-dotall-regex { android, chrome < 62, edge < 79, firefox < 78, ios < 11.3, opera < 49, safari < 11.1 }
proposal-unicode-property-regex { android, chrome < 64, edge < 79, firefox < 78, ios < 11.3, opera < 51, safari < 11.1, samsung < 9 }
transform-named-capturing-groups-regex { android, chrome < 64, edge < 79, firefox < 78, ios < 11.3, opera < 51, safari < 11.1, samsung < 9 }
transform-async-to-generator { ios < 11, safari < 11 }
transform-template-literals { ios < 13, safari < 13 }
transform-function-name { edge < 79 }
transform-unicode-regex { ios < 12, safari < 12 }
transform-block-scoping { ios < 11, safari < 11 }
proposal-export-namespace-from { android < 72, chrome < 72, edge < 79, firefox < 80, ios, opera < 60, safari, samsung < 11.0 }
transform-modules-commonjs
proposal-dynamic-import

Using polyfills: No polyfills were added, since the `useBuiltIns` option was not set.
Expand Up @@ -16,26 +16,26 @@ Using targets:
Using modules transform: auto

Using plugins:
proposal-numeric-separator { "android":"61", "chrome":"61", "edge":"16", "firefox":"60", "ios":"10.3", "opera":"48", "safari":"10.1", "samsung":"8.2" }
proposal-logical-assignment-operators { "android":"61", "chrome":"61", "edge":"16", "firefox":"60", "ios":"10.3", "node":"13.2", "opera":"48", "safari":"10.1", "samsung":"8.2" }
proposal-nullish-coalescing-operator { "android":"61", "chrome":"61", "edge":"16", "firefox":"60", "ios":"10.3", "node":"13.2", "opera":"48", "safari":"10.1", "samsung":"8.2" }
proposal-optional-chaining { "android":"61", "chrome":"61", "edge":"16", "firefox":"60", "ios":"10.3", "node":"13.2", "opera":"48", "safari":"10.1", "samsung":"8.2" }
proposal-json-strings { "android":"61", "chrome":"61", "edge":"16", "firefox":"60", "ios":"10.3", "opera":"48", "safari":"10.1", "samsung":"8.2" }
proposal-optional-catch-binding { "android":"61", "chrome":"61", "edge":"16", "ios":"10.3", "opera":"48", "safari":"10.1", "samsung":"8.2" }
proposal-async-generator-functions { "android":"61", "chrome":"61", "edge":"16", "ios":"10.3", "opera":"48", "safari":"10.1" }
proposal-object-rest-spread { "edge":"16", "ios":"10.3", "safari":"10.1" }
transform-dotall-regex { "android":"61", "chrome":"61", "edge":"16", "firefox":"60", "ios":"10.3", "opera":"48", "safari":"10.1" }
proposal-unicode-property-regex { "android":"61", "chrome":"61", "edge":"16", "firefox":"60", "ios":"10.3", "opera":"48", "safari":"10.1", "samsung":"8.2" }
transform-named-capturing-groups-regex { "android":"61", "chrome":"61", "edge":"16", "firefox":"60", "ios":"10.3", "opera":"48", "safari":"10.1", "samsung":"8.2" }
transform-unicode-regex { "ios":"10.3", "safari":"10.1" }
proposal-export-namespace-from { "android":"61", "chrome":"61", "edge":"16", "firefox":"60", "ios":"10.3", "opera":"48", "safari":"10.1", "samsung":"8.2" }
bugfix/transform-async-arrows-in-class { "android":"61", "chrome":"61", "edge":"16", "firefox":"60", "ios":"10.3", "node":"13.2", "opera":"48", "safari":"10.1", "samsung":"8.2" }
bugfix/transform-edge-default-parameters { "android":"61", "chrome":"61", "edge":"16", "firefox":"60", "ios":"10.3", "node":"13.2", "opera":"48", "safari":"10.1", "samsung":"8.2" }
bugfix/transform-edge-function-name { "android":"61", "chrome":"61", "edge":"16", "firefox":"60", "ios":"10.3", "node":"13.2", "opera":"48", "safari":"10.1", "samsung":"8.2" }
bugfix/transform-safari-block-shadowing { "android":"61", "chrome":"61", "edge":"16", "firefox":"60", "ios":"10.3", "node":"13.2", "opera":"48", "safari":"10.1", "samsung":"8.2" }
bugfix/transform-safari-for-shadowing { "android":"61", "chrome":"61", "edge":"16", "firefox":"60", "ios":"10.3", "node":"13.2", "opera":"48", "safari":"10.1", "samsung":"8.2" }
bugfix/transform-tagged-template-caching { "android":"61", "chrome":"61", "edge":"16", "firefox":"60", "ios":"10.3", "node":"13.2", "opera":"48", "safari":"10.1", "samsung":"8.2" }
transform-modules-commonjs { "android":"61", "chrome":"61", "edge":"16", "firefox":"60", "ios":"10.3", "node":"13.2", "opera":"48", "safari":"10.1", "samsung":"8.2" }
proposal-dynamic-import { "android":"61", "chrome":"61", "edge":"16", "firefox":"60", "ios":"10.3", "node":"13.2", "opera":"48", "safari":"10.1", "samsung":"8.2" }
proposal-numeric-separator { android, chrome < 75, edge < 79, firefox < 70, ios < 13, opera < 62, safari < 13, samsung < 11 }
proposal-logical-assignment-operators { android, chrome < 85, edge < 85, firefox < 79, ios < 14, node < 15, opera, safari < 14, samsung }
proposal-nullish-coalescing-operator { android, chrome < 80, edge < 80, firefox < 72, ios < 13.4, node < 14, opera < 67, safari < 13.1, samsung < 13 }
proposal-optional-chaining { android, chrome < 80, edge < 80, firefox < 74, ios < 13.4, node < 14, opera < 67, safari < 13.1, samsung < 13 }
proposal-json-strings { android, chrome < 66, edge < 79, firefox < 62, ios < 12, opera < 53, safari < 12, samsung < 9 }
proposal-optional-catch-binding { android, chrome < 66, edge < 79, ios < 11.3, opera < 53, safari < 11.1, samsung < 9 }
proposal-async-generator-functions { android, chrome < 63, edge < 79, ios < 12, opera < 50, safari < 12 }
proposal-object-rest-spread { edge < 79, ios < 11.3, safari < 11.1 }
transform-dotall-regex { android, chrome < 62, edge < 79, firefox < 78, ios < 11.3, opera < 49, safari < 11.1 }
proposal-unicode-property-regex { android, chrome < 64, edge < 79, firefox < 78, ios < 11.3, opera < 51, safari < 11.1, samsung < 9 }
transform-named-capturing-groups-regex { android, chrome < 64, edge < 79, firefox < 78, ios < 11.3, opera < 51, safari < 11.1, samsung < 9 }
transform-unicode-regex { ios < 12, safari < 12 }
proposal-export-namespace-from { android < 72, chrome < 72, edge < 79, firefox < 80, ios, opera < 60, safari, samsung < 11.0 }
bugfix/transform-async-arrows-in-class { ios < 11, safari < 11 }
bugfix/transform-edge-default-parameters { edge < 18 }
bugfix/transform-edge-function-name { edge < 79 }
bugfix/transform-safari-block-shadowing { ios < 11, safari < 11 }
bugfix/transform-safari-for-shadowing { ios < 11, safari < 11 }
bugfix/transform-tagged-template-caching { ios < 13, safari < 13 }
transform-modules-commonjs
proposal-dynamic-import

Using polyfills: No polyfills were added, since the `useBuiltIns` option was not set.
Expand Up @@ -8,39 +8,39 @@ Using targets:
Using modules transform: auto

Using plugins:
proposal-numeric-separator { "chrome":"40" }
proposal-logical-assignment-operators { "chrome":"40" }
proposal-nullish-coalescing-operator { "chrome":"40" }
proposal-optional-chaining { "chrome":"40" }
proposal-json-strings { "chrome":"40" }
proposal-optional-catch-binding { "chrome":"40" }
transform-parameters { "chrome":"40" }
proposal-async-generator-functions { "chrome":"40" }
proposal-object-rest-spread { "chrome":"40" }
transform-dotall-regex { "chrome":"40" }
proposal-unicode-property-regex { "chrome":"40" }
transform-named-capturing-groups-regex { "chrome":"40" }
transform-async-to-generator { "chrome":"40" }
transform-exponentiation-operator { "chrome":"40" }
transform-template-literals { "chrome":"40" }
transform-literals { "chrome":"40" }
transform-function-name { "chrome":"40" }
transform-block-scoped-functions { "chrome":"40" }
transform-classes { "chrome":"40" }
transform-object-super { "chrome":"40" }
transform-shorthand-properties { "chrome":"40" }
transform-duplicate-keys { "chrome":"40" }
transform-computed-properties { "chrome":"40" }
transform-for-of { "chrome":"40" }
transform-sticky-regex { "chrome":"40" }
transform-unicode-escapes { "chrome":"40" }
transform-unicode-regex { "chrome":"40" }
transform-spread { "chrome":"40" }
transform-block-scoping { "chrome":"40" }
transform-new-target { "chrome":"40" }
transform-regenerator { "chrome":"40" }
proposal-export-namespace-from { "chrome":"40" }
transform-modules-commonjs { "chrome":"40" }
proposal-dynamic-import { "chrome":"40" }
proposal-numeric-separator { chrome < 75 }
proposal-logical-assignment-operators { chrome < 85 }
proposal-nullish-coalescing-operator { chrome < 80 }
proposal-optional-chaining { chrome < 80 }
proposal-json-strings { chrome < 66 }
proposal-optional-catch-binding { chrome < 66 }
transform-parameters { chrome < 49 }
proposal-async-generator-functions { chrome < 63 }
proposal-object-rest-spread { chrome < 60 }
transform-dotall-regex { chrome < 62 }
proposal-unicode-property-regex { chrome < 64 }
transform-named-capturing-groups-regex { chrome < 64 }
transform-async-to-generator { chrome < 55 }
transform-exponentiation-operator { chrome < 52 }
transform-template-literals { chrome < 41 }
transform-literals { chrome < 44 }
transform-function-name { chrome < 51 }
transform-block-scoped-functions { chrome < 41 }
transform-classes { chrome < 46 }
transform-object-super { chrome < 46 }
transform-shorthand-properties { chrome < 43 }
transform-duplicate-keys { chrome < 42 }
transform-computed-properties { chrome < 44 }
transform-for-of { chrome < 51 }
transform-sticky-regex { chrome < 49 }
transform-unicode-escapes { chrome < 44 }
transform-unicode-regex { chrome < 50 }
transform-spread { chrome < 46 }
transform-block-scoping { chrome < 49 }
transform-new-target { chrome < 46 }
transform-regenerator { chrome < 50 }
proposal-export-namespace-from { chrome < 72 }
transform-modules-commonjs
proposal-dynamic-import

Using polyfills: No polyfills were added, since the `useBuiltIns` option was not set.
Expand Up @@ -8,16 +8,16 @@ Using targets:
Using modules transform: auto

Using plugins:
proposal-numeric-separator { "chrome":"70" }
proposal-logical-assignment-operators { "chrome":"70" }
proposal-nullish-coalescing-operator { "chrome":"70" }
proposal-optional-chaining { "chrome":"70" }
syntax-json-strings { "chrome":"70" }
syntax-optional-catch-binding { "chrome":"70" }
syntax-async-generators { "chrome":"70" }
syntax-object-rest-spread { "chrome":"70" }
proposal-export-namespace-from { "chrome":"70" }
transform-modules-commonjs { "chrome":"70" }
proposal-dynamic-import { "chrome":"70" }
proposal-numeric-separator { chrome < 75 }
proposal-logical-assignment-operators { chrome < 85 }
proposal-nullish-coalescing-operator { chrome < 80 }
proposal-optional-chaining { chrome < 80 }
syntax-json-strings
syntax-optional-catch-binding
syntax-async-generators
syntax-object-rest-spread
proposal-export-namespace-from { chrome < 72 }
transform-modules-commonjs
proposal-dynamic-import

Using polyfills: No polyfills were added, since the `useBuiltIns` option was not set.
Expand Up @@ -8,24 +8,24 @@ Using targets:
Using modules transform: auto

Using plugins:
proposal-numeric-separator { "edge":"14" }
proposal-logical-assignment-operators { "edge":"14" }
proposal-nullish-coalescing-operator { "edge":"14" }
proposal-optional-chaining { "edge":"14" }
proposal-json-strings { "edge":"14" }
proposal-optional-catch-binding { "edge":"14" }
transform-parameters { "edge":"14" }
proposal-async-generator-functions { "edge":"14" }
proposal-object-rest-spread { "edge":"14" }
transform-dotall-regex { "edge":"14" }
proposal-unicode-property-regex { "edge":"14" }
transform-named-capturing-groups-regex { "edge":"14" }
transform-async-to-generator { "edge":"14" }
transform-for-of { "edge":"14" }
transform-destructuring { "edge":"14" }
proposal-export-namespace-from { "edge":"14" }
bugfix/transform-edge-function-name { "edge":"14" }
transform-modules-commonjs { "edge":"14" }
proposal-dynamic-import { "edge":"14" }
proposal-numeric-separator { edge < 79 }
proposal-logical-assignment-operators { edge < 85 }
proposal-nullish-coalescing-operator { edge < 80 }
proposal-optional-chaining { edge < 80 }
proposal-json-strings { edge < 79 }
proposal-optional-catch-binding { edge < 79 }
transform-parameters { edge < 15 }
proposal-async-generator-functions { edge < 79 }
proposal-object-rest-spread { edge < 79 }
transform-dotall-regex { edge < 79 }
proposal-unicode-property-regex { edge < 79 }
transform-named-capturing-groups-regex { edge < 79 }
transform-async-to-generator { edge < 15 }
transform-for-of { edge < 15 }
transform-destructuring { edge < 15 }
proposal-export-namespace-from { edge < 79 }
bugfix/transform-edge-function-name { edge < 79 }
transform-modules-commonjs
proposal-dynamic-import

Using polyfills: No polyfills were added, since the `useBuiltIns` option was not set.

0 comments on commit be1003b

Please sign in to comment.