/
githubmirror
/
babel
Обзор
Документация
Войти
/
githubmirror
/
babel
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v7.29.0
scripts/rollup-plugin-dependency-condition.js
21 строка
629 B
Huáng Jùnliàng
Enable type checking for `scripts` and `babel-worker.cjs` (#17454)
30 июл 2025, 01:26
Не верифицирован
30 июл 2025, 01:26
ac0b069
Код
Авторство
О чём код?
// @ts-check /** * Rollup plugin to conditionally include/exclude dependencies based on the * BABEL_8_BREAKING flag. * @param {boolean} value - The flag to determine inclusion or exclusion. * @returns {import("rollup").Plugin} - The Rollup plugin. */ export default function (value) { const re = value ? /^(.*?-BABEL_8_BREAKING)-false$/ : /^(.*?-BABEL_8_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); }, }; }