Files
babel/packages/babel-preset-env/src/debug.ts
Bogdan Savluk 47ad54a057 convert @babel/preset-env to typescript (#13217)
* babel-preset-env flowts rename

* babel-preset-env flowts convert

* babel-preset-env fixes

* babel-preset-env

* make generate-tsconfig

* Minimize diff

* Fix many type errors

Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2021-06-22 10:58:08 -04:00

33 lines
916 B
TypeScript

import { getInclusionReasons } from "@babel/helper-compilation-targets";
import type { Targets } from "@babel/helper-compilation-targets";
// Outputs a message that shows which target(s) caused an item to be included:
// transform-foo { "edge":"13", "firefox":"49", "ie":"10" }
export const logPlugin = (
item: string,
targetVersions: Targets,
list: { [key: string]: Targets },
) => {
const filteredList = getInclusionReasons(item, targetVersions, list);
const support = list[item];
if (!support) {
console.log(` ${item}`);
return;
}
let formattedTargets = `{`;
let first = true;
for (const target of Object.keys(filteredList)) {
if (!first) formattedTargets += `,`;
first = false;
formattedTargets += ` ${target}`;
if (support[target]) formattedTargets += ` < ${support[target]}`;
}
formattedTargets += ` }`;
console.log(` ${item} ${formattedTargets}`);
};