/
githubmirror
/
babel
Обзор
Документация
Войти
/
githubmirror
/
babel
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
scripts/rollup-plugin-dependency-condition.ts
19 строк
649 B
liuxingbaoyu
chore: Migrate scripts to `.ts` (#17767)
13 фев 2026, 17:26
Не верифицирован
13 фев 2026, 17:26
931ddd6
Код
Авторство
О чём код?
/** * Rollup plugin to conditionally include/exclude dependencies based on the * BABEL_9_BREAKING flag. * @param {boolean} value - The flag to determine inclusion or exclusion. * @returns {import("rollup").Plugin} - The Rollup plugin. */ export default function (value: boolean): import("rollup").Plugin { const re = value ? /^(.*?-BABEL_9_BREAKING)-false$/ : /^(.*?-BABEL_9_BREAKING)-true$/; return { name: "dependency-condition", resolveId(source, importer, options) { const match = source.match(re); if (!match) return null; return this.resolve(`${match[1]}-${value}`, importer, options); }, }; }