import { PromptModuleAPI } from "../promptModuleAPI"; /** * @description 是否使用 babel 来转译 ES 代码,当选项中选择了 ts 时,此插件将被忽略 * 但是当选择了搭配 babel 和 ts 一起使用时,此插件不会被忽略 */ export default function(cli: PromptModuleAPI): void { cli.injectFeature({ name: "Babel", value: "babel", short: "Babel", description: "Transpile modern JavaScript to older versions (for compatibility)", link: "https://babeljs.io/", checked: true, }); cli.onPromptComplete((answers, options) => { if (!options.plugins) { return; } if (!answers.features.includes("babel")) { return; } if (answers.features.includes("babel")) { options.plugins["cli-plugin-babel"] = {}; return; } if (answers.features.includes("ts") && answers.useTsWithBabel) { options.plugins["cli-plugin-babel"] = {}; return; } }); }